documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831
  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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Represens a plane by the equation ax + by + cz + d = 0
  1909. */
  1910. export class Plane {
  1911. private static _TmpMatrix;
  1912. /**
  1913. * Normal of the plane (a,b,c)
  1914. */
  1915. normal: Vector3;
  1916. /**
  1917. * d component of the plane
  1918. */
  1919. d: number;
  1920. /**
  1921. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1922. * @param a a component of the plane
  1923. * @param b b component of the plane
  1924. * @param c c component of the plane
  1925. * @param d d component of the plane
  1926. */
  1927. constructor(a: number, b: number, c: number, d: number);
  1928. /**
  1929. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * @returns a new plane copied from the current Plane.
  1934. */
  1935. clone(): Plane;
  1936. /**
  1937. * @returns the string "Plane".
  1938. */
  1939. getClassName(): string;
  1940. /**
  1941. * @returns the Plane hash code.
  1942. */
  1943. getHashCode(): number;
  1944. /**
  1945. * Normalize the current Plane in place.
  1946. * @returns the updated Plane.
  1947. */
  1948. normalize(): Plane;
  1949. /**
  1950. * Applies a transformation the plane and returns the result
  1951. * @param transformation the transformation matrix to be applied to the plane
  1952. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1953. */
  1954. transform(transformation: DeepImmutable<Matrix>): Plane;
  1955. /**
  1956. * Compute the dot product between the point and the plane normal
  1957. * @param point point to calculate the dot product with
  1958. * @returns the dot product (float) of the point coordinates and the plane normal.
  1959. */
  1960. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1961. /**
  1962. * Updates the current Plane from the plane defined by the three given points.
  1963. * @param point1 one of the points used to contruct the plane
  1964. * @param point2 one of the points used to contruct the plane
  1965. * @param point3 one of the points used to contruct the plane
  1966. * @returns the updated Plane.
  1967. */
  1968. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1969. /**
  1970. * Checks if the plane is facing a given direction
  1971. * @param direction the direction to check if the plane is facing
  1972. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1973. * @returns True is the vector "direction" is the same side than the plane normal.
  1974. */
  1975. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1976. /**
  1977. * Calculates the distance to a point
  1978. * @param point point to calculate distance to
  1979. * @returns the signed distance (float) from the given point to the Plane.
  1980. */
  1981. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1982. /**
  1983. * Creates a plane from an array
  1984. * @param array the array to create a plane from
  1985. * @returns a new Plane from the given array.
  1986. */
  1987. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1988. /**
  1989. * Creates a plane from three points
  1990. * @param point1 point used to create the plane
  1991. * @param point2 point used to create the plane
  1992. * @param point3 point used to create the plane
  1993. * @returns a new Plane defined by the three given points.
  1994. */
  1995. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1996. /**
  1997. * Creates a plane from an origin point and a normal
  1998. * @param origin origin of the plane to be constructed
  1999. * @param normal normal of the plane to be constructed
  2000. * @returns a new Plane the normal vector to this plane at the given origin point.
  2001. * Note : the vector "normal" is updated because normalized.
  2002. */
  2003. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Calculates the distance from a plane and a point
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @param point point to calculate distance to
  2009. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2010. */
  2011. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2012. }
  2013. }
  2014. declare module BABYLON {
  2015. /**
  2016. * Class representing a vector containing 2 coordinates
  2017. */
  2018. export class Vector2 {
  2019. /** defines the first coordinate */
  2020. x: number;
  2021. /** defines the second coordinate */
  2022. y: number;
  2023. /**
  2024. * Creates a new Vector2 from the given x and y coordinates
  2025. * @param x defines the first coordinate
  2026. * @param y defines the second coordinate
  2027. */
  2028. constructor(
  2029. /** defines the first coordinate */
  2030. x?: number,
  2031. /** defines the second coordinate */
  2032. y?: number);
  2033. /**
  2034. * Gets a string with the Vector2 coordinates
  2035. * @returns a string with the Vector2 coordinates
  2036. */
  2037. toString(): string;
  2038. /**
  2039. * Gets class name
  2040. * @returns the string "Vector2"
  2041. */
  2042. getClassName(): string;
  2043. /**
  2044. * Gets current vector hash code
  2045. * @returns the Vector2 hash code as a number
  2046. */
  2047. getHashCode(): number;
  2048. /**
  2049. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2050. * @param array defines the source array
  2051. * @param index defines the offset in source array
  2052. * @returns the current Vector2
  2053. */
  2054. toArray(array: FloatArray, index?: number): Vector2;
  2055. /**
  2056. * Copy the current vector to an array
  2057. * @returns a new array with 2 elements: the Vector2 coordinates.
  2058. */
  2059. asArray(): number[];
  2060. /**
  2061. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2062. * @param source defines the source Vector2
  2063. * @returns the current updated Vector2
  2064. */
  2065. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2066. /**
  2067. * Sets the Vector2 coordinates with the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns the current updated Vector2
  2071. */
  2072. copyFromFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Sets the Vector2 coordinates with the given floats
  2075. * @param x defines the first coordinate
  2076. * @param y defines the second coordinate
  2077. * @returns the current updated Vector2
  2078. */
  2079. set(x: number, y: number): Vector2;
  2080. /**
  2081. * Add another vector with the current one
  2082. * @param otherVector defines the other vector
  2083. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2084. */
  2085. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2088. * @param otherVector defines the other vector
  2089. * @param result defines the target vector
  2090. * @returns the unmodified current Vector2
  2091. */
  2092. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2093. /**
  2094. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2095. * @param otherVector defines the other vector
  2096. * @returns the current updated Vector2
  2097. */
  2098. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2099. /**
  2100. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2101. * @param otherVector defines the other vector
  2102. * @returns a new Vector2
  2103. */
  2104. addVector3(otherVector: Vector3): Vector2;
  2105. /**
  2106. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2
  2109. */
  2110. subtract(otherVector: Vector2): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Multiplies in place the current Vector2 coordinates by the given ones
  2126. * @param otherVector defines the other vector
  2127. * @returns the current updated Vector2
  2128. */
  2129. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns a new Vector2
  2148. */
  2149. multiplyByFloats(x: number, y: number): Vector2;
  2150. /**
  2151. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. divide(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Divides the current Vector2 coordinates by the given ones
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 with current Vector2 negated coordinates
  2171. * @returns a new Vector2
  2172. */
  2173. negate(): Vector2;
  2174. /**
  2175. * Negate this vector in place
  2176. * @returns this
  2177. */
  2178. negateInPlace(): Vector2;
  2179. /**
  2180. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2181. * @param result defines the Vector3 object where to store the result
  2182. * @returns the current Vector2
  2183. */
  2184. negateToRef(result: Vector2): Vector2;
  2185. /**
  2186. * Multiply the Vector2 coordinates by scale
  2187. * @param scale defines the scaling factor
  2188. * @returns the current updated Vector2
  2189. */
  2190. scaleInPlace(scale: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2193. * @param scale defines the scaling factor
  2194. * @returns a new Vector2
  2195. */
  2196. scale(scale: number): Vector2;
  2197. /**
  2198. * Scale the current Vector2 values by a factor to a given Vector2
  2199. * @param scale defines the scale factor
  2200. * @param result defines the Vector2 object where to store the result
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. scaleToRef(scale: number, result: Vector2): Vector2;
  2204. /**
  2205. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2206. * @param scale defines the scale factor
  2207. * @param result defines the Vector2 object where to store the result
  2208. * @returns the unmodified current Vector2
  2209. */
  2210. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2211. /**
  2212. * Gets a boolean if two vectors are equals
  2213. * @param otherVector defines the other vector
  2214. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2215. */
  2216. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2217. /**
  2218. * Gets a boolean if two vectors are equals (using an epsilon value)
  2219. * @param otherVector defines the other vector
  2220. * @param epsilon defines the minimal distance to consider equality
  2221. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2222. */
  2223. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2224. /**
  2225. * Gets a new Vector2 from current Vector2 floored values
  2226. * @returns a new Vector2
  2227. */
  2228. floor(): Vector2;
  2229. /**
  2230. * Gets a new Vector2 from current Vector2 floored values
  2231. * @returns a new Vector2
  2232. */
  2233. fract(): Vector2;
  2234. /**
  2235. * Gets the length of the vector
  2236. * @returns the vector length (float)
  2237. */
  2238. length(): number;
  2239. /**
  2240. * Gets the vector squared length
  2241. * @returns the vector squared length (float)
  2242. */
  2243. lengthSquared(): number;
  2244. /**
  2245. * Normalize the vector
  2246. * @returns the current updated Vector2
  2247. */
  2248. normalize(): Vector2;
  2249. /**
  2250. * Gets a new Vector2 copied from the Vector2
  2251. * @returns a new Vector2
  2252. */
  2253. clone(): Vector2;
  2254. /**
  2255. * Gets a new Vector2(0, 0)
  2256. * @returns a new Vector2
  2257. */
  2258. static Zero(): Vector2;
  2259. /**
  2260. * Gets a new Vector2(1, 1)
  2261. * @returns a new Vector2
  2262. */
  2263. static One(): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set from the given index element of the given array
  2266. * @param array defines the data source
  2267. * @param offset defines the offset in the data source
  2268. * @returns a new Vector2
  2269. */
  2270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2271. /**
  2272. * Sets "result" from the given index element of the given array
  2273. * @param array defines the data source
  2274. * @param offset defines the offset in the data source
  2275. * @param result defines the target vector
  2276. */
  2277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2278. /**
  2279. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2280. * @param value1 defines 1st point of control
  2281. * @param value2 defines 2nd point of control
  2282. * @param value3 defines 3rd point of control
  2283. * @param value4 defines 4th point of control
  2284. * @param amount defines the interpolation factor
  2285. * @returns a new Vector2
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2288. /**
  2289. * 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".
  2290. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2291. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2292. * @param value defines the value to clamp
  2293. * @param min defines the lower limit
  2294. * @param max defines the upper limit
  2295. * @returns a new Vector2
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2298. /**
  2299. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2300. * @param value1 defines the 1st control point
  2301. * @param tangent1 defines the outgoing tangent
  2302. * @param value2 defines the 2nd control point
  2303. * @param tangent2 defines the incoming tangent
  2304. * @param amount defines the interpolation factor
  2305. * @returns a new Vector2
  2306. */
  2307. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2308. /**
  2309. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2310. * @param start defines the start vector
  2311. * @param end defines the end vector
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Gets the dot product of the vector "left" and the vector "right"
  2318. * @param left defines first vector
  2319. * @param right defines second vector
  2320. * @returns the dot product (float)
  2321. */
  2322. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2323. /**
  2324. * Returns a new Vector2 equal to the normalized given vector
  2325. * @param vector defines the vector to normalize
  2326. * @returns a new Vector2
  2327. */
  2328. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2329. /**
  2330. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2331. * @param left defines 1st vector
  2332. * @param right defines 2nd vector
  2333. * @returns a new Vector2
  2334. */
  2335. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2336. /**
  2337. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2338. * @param left defines 1st vector
  2339. * @param right defines 2nd vector
  2340. * @returns a new Vector2
  2341. */
  2342. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2345. * @param vector defines the vector to transform
  2346. * @param transformation defines the matrix to apply
  2347. * @returns a new Vector2
  2348. */
  2349. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2350. /**
  2351. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2352. * @param vector defines the vector to transform
  2353. * @param transformation defines the matrix to apply
  2354. * @param result defines the target vector
  2355. */
  2356. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2357. /**
  2358. * Determines if a given vector is included in a triangle
  2359. * @param p defines the vector to test
  2360. * @param p0 defines 1st triangle point
  2361. * @param p1 defines 2nd triangle point
  2362. * @param p2 defines 3rd triangle point
  2363. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2364. */
  2365. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2366. /**
  2367. * Gets the distance between the vectors "value1" and "value2"
  2368. * @param value1 defines first vector
  2369. * @param value2 defines second vector
  2370. * @returns the distance between vectors
  2371. */
  2372. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2373. /**
  2374. * Returns the squared distance between the vectors "value1" and "value2"
  2375. * @param value1 defines first vector
  2376. * @param value2 defines second vector
  2377. * @returns the squared distance between vectors
  2378. */
  2379. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2380. /**
  2381. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2382. * @param value1 defines first vector
  2383. * @param value2 defines second vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2389. * @param p defines the middle point
  2390. * @param segA defines one point of the segment
  2391. * @param segB defines the other point of the segment
  2392. * @returns the shortest distance
  2393. */
  2394. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2395. }
  2396. /**
  2397. * Class used to store (x,y,z) vector representation
  2398. * A Vector3 is the main object used in 3D geometry
  2399. * It can represent etiher the coordinates of a point the space, either a direction
  2400. * Reminder: js uses a left handed forward facing system
  2401. */
  2402. export class Vector3 {
  2403. /**
  2404. * Defines the first coordinates (on X axis)
  2405. */
  2406. x: number;
  2407. /**
  2408. * Defines the second coordinates (on Y axis)
  2409. */
  2410. y: number;
  2411. /**
  2412. * Defines the third coordinates (on Z axis)
  2413. */
  2414. z: number;
  2415. private static _UpReadOnly;
  2416. private static _ZeroReadOnly;
  2417. /**
  2418. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2419. * @param x defines the first coordinates (on X axis)
  2420. * @param y defines the second coordinates (on Y axis)
  2421. * @param z defines the third coordinates (on Z axis)
  2422. */
  2423. constructor(
  2424. /**
  2425. * Defines the first coordinates (on X axis)
  2426. */
  2427. x?: number,
  2428. /**
  2429. * Defines the second coordinates (on Y axis)
  2430. */
  2431. y?: number,
  2432. /**
  2433. * Defines the third coordinates (on Z axis)
  2434. */
  2435. z?: number);
  2436. /**
  2437. * Creates a string representation of the Vector3
  2438. * @returns a string with the Vector3 coordinates.
  2439. */
  2440. toString(): string;
  2441. /**
  2442. * Gets the class name
  2443. * @returns the string "Vector3"
  2444. */
  2445. getClassName(): string;
  2446. /**
  2447. * Creates the Vector3 hash code
  2448. * @returns a number which tends to be unique between Vector3 instances
  2449. */
  2450. getHashCode(): number;
  2451. /**
  2452. * Creates an array containing three elements : the coordinates of the Vector3
  2453. * @returns a new array of numbers
  2454. */
  2455. asArray(): number[];
  2456. /**
  2457. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2458. * @param array defines the destination array
  2459. * @param index defines the offset in the destination array
  2460. * @returns the current Vector3
  2461. */
  2462. toArray(array: FloatArray, index?: number): Vector3;
  2463. /**
  2464. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2465. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2466. */
  2467. toQuaternion(): Quaternion;
  2468. /**
  2469. * Adds the given vector to the current Vector3
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2474. /**
  2475. * Adds the given coordinates to the current Vector3
  2476. * @param x defines the x coordinate of the operand
  2477. * @param y defines the y coordinate of the operand
  2478. * @param z defines the z coordinate of the operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2482. /**
  2483. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2484. * @param otherVector defines the second operand
  2485. * @returns the resulting Vector3
  2486. */
  2487. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2490. * @param otherVector defines the second operand
  2491. * @param result defines the Vector3 object where to store the result
  2492. * @returns the current Vector3
  2493. */
  2494. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2495. /**
  2496. * Subtract the given vector from the current Vector3
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the resulting Vector3
  2505. */
  2506. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the resulting Vector3
  2520. */
  2521. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2531. /**
  2532. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2533. * @returns a new Vector3
  2534. */
  2535. negate(): Vector3;
  2536. /**
  2537. * Negate this vector in place
  2538. * @returns this
  2539. */
  2540. negateInPlace(): Vector3;
  2541. /**
  2542. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. negateToRef(result: Vector3): Vector3;
  2547. /**
  2548. * Multiplies the Vector3 coordinates by the float "scale"
  2549. * @param scale defines the multiplier factor
  2550. * @returns the current updated Vector3
  2551. */
  2552. scaleInPlace(scale: number): Vector3;
  2553. /**
  2554. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2555. * @param scale defines the multiplier factor
  2556. * @returns a new Vector3
  2557. */
  2558. scale(scale: number): Vector3;
  2559. /**
  2560. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2561. * @param scale defines the multiplier factor
  2562. * @param result defines the Vector3 object where to store the result
  2563. * @returns the current Vector3
  2564. */
  2565. scaleToRef(scale: number, result: Vector3): Vector3;
  2566. /**
  2567. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2568. * @param scale defines the scale factor
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the unmodified current Vector3
  2571. */
  2572. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2573. /**
  2574. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2575. * @param origin defines the origin of the projection ray
  2576. * @param plane defines the plane to project to
  2577. * @returns the projected vector3
  2578. */
  2579. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2580. /**
  2581. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2582. * @param origin defines the origin of the projection ray
  2583. * @param plane defines the plane to project to
  2584. * @param result defines the Vector3 where to store the result
  2585. */
  2586. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2587. /**
  2588. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2589. * @param otherVector defines the second operand
  2590. * @returns true if both vectors are equals
  2591. */
  2592. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2593. /**
  2594. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2595. * @param otherVector defines the second operand
  2596. * @param epsilon defines the minimal distance to define values as equals
  2597. * @returns true if both vectors are distant less than epsilon
  2598. */
  2599. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2600. /**
  2601. * Returns true if the current Vector3 coordinates equals the given floats
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @returns true if both vectors are equals
  2606. */
  2607. equalsToFloats(x: number, y: number, z: number): boolean;
  2608. /**
  2609. * Multiplies the current Vector3 coordinates by the given ones
  2610. * @param otherVector defines the second operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2616. * @param otherVector defines the second operand
  2617. * @returns the new Vector3
  2618. */
  2619. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2620. /**
  2621. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2622. * @param otherVector defines the second operand
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the current Vector3
  2625. */
  2626. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the new Vector3
  2633. */
  2634. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2637. * @param otherVector defines the second operand
  2638. * @returns the new Vector3
  2639. */
  2640. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2643. * @param otherVector defines the second operand
  2644. * @param result defines the Vector3 object where to store the result
  2645. * @returns the current Vector3
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2648. /**
  2649. * Divides the current Vector3 coordinates by the given ones.
  2650. * @param otherVector defines the second operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. divideInPlace(otherVector: Vector3): Vector3;
  2654. /**
  2655. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2656. * @param other defines the second operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2662. * @param other defines the second operand
  2663. * @returns the current updated Vector3
  2664. */
  2665. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2666. /**
  2667. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2684. * Check if is non uniform within a certain amount of decimal places to account for this
  2685. * @param epsilon the amount the values can differ
  2686. * @returns if the the vector is non uniform to a certain number of decimal places
  2687. */
  2688. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2689. /**
  2690. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2691. */
  2692. get isNonUniform(): boolean;
  2693. /**
  2694. * Gets a new Vector3 from current Vector3 floored values
  2695. * @returns a new Vector3
  2696. */
  2697. floor(): Vector3;
  2698. /**
  2699. * Gets a new Vector3 from current Vector3 floored values
  2700. * @returns a new Vector3
  2701. */
  2702. fract(): Vector3;
  2703. /**
  2704. * Gets the length of the Vector3
  2705. * @returns the length of the Vector3
  2706. */
  2707. length(): number;
  2708. /**
  2709. * Gets the squared length of the Vector3
  2710. * @returns squared length of the Vector3
  2711. */
  2712. lengthSquared(): number;
  2713. /**
  2714. * Normalize the current Vector3.
  2715. * Please note that this is an in place operation.
  2716. * @returns the current updated Vector3
  2717. */
  2718. normalize(): Vector3;
  2719. /**
  2720. * Reorders the x y z properties of the vector in place
  2721. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2722. * @returns the current updated vector
  2723. */
  2724. reorderInPlace(order: string): this;
  2725. /**
  2726. * Rotates the vector around 0,0,0 by a quaternion
  2727. * @param quaternion the rotation quaternion
  2728. * @param result vector to store the result
  2729. * @returns the resulting vector
  2730. */
  2731. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2732. /**
  2733. * Rotates a vector around a given point
  2734. * @param quaternion the rotation quaternion
  2735. * @param point the point to rotate around
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2740. /**
  2741. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2742. * The cross product is then orthogonal to both current and "other"
  2743. * @param other defines the right operand
  2744. * @returns the cross product
  2745. */
  2746. cross(other: Vector3): Vector3;
  2747. /**
  2748. * Normalize the current Vector3 with the given input length.
  2749. * Please note that this is an in place operation.
  2750. * @param len the length of the vector
  2751. * @returns the current updated Vector3
  2752. */
  2753. normalizeFromLength(len: number): Vector3;
  2754. /**
  2755. * Normalize the current Vector3 to a new vector
  2756. * @returns the new Vector3
  2757. */
  2758. normalizeToNew(): Vector3;
  2759. /**
  2760. * Normalize the current Vector3 to the reference
  2761. * @param reference define the Vector3 to update
  2762. * @returns the updated Vector3
  2763. */
  2764. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2765. /**
  2766. * Creates a new Vector3 copied from the current Vector3
  2767. * @returns the new Vector3
  2768. */
  2769. clone(): Vector3;
  2770. /**
  2771. * Copies the given vector coordinates to the current Vector3 ones
  2772. * @param source defines the source Vector3
  2773. * @returns the current updated Vector3
  2774. */
  2775. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Copies the given floats to the current Vector3 coordinates
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. set(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given float to the current Vector3 coordinates
  2794. * @param v defines the x, y and z coordinates of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. setAll(v: number): Vector3;
  2798. /**
  2799. * Get the clip factor between two vectors
  2800. * @param vector0 defines the first operand
  2801. * @param vector1 defines the second operand
  2802. * @param axis defines the axis to use
  2803. * @param size defines the size along the axis
  2804. * @returns the clip factor
  2805. */
  2806. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2807. /**
  2808. * Get angle between two vectors
  2809. * @param vector0 angle between vector0 and vector1
  2810. * @param vector1 angle between vector0 and vector1
  2811. * @param normal direction of the normal
  2812. * @return the angle between vector0 and vector1
  2813. */
  2814. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2815. /**
  2816. * Returns a new Vector3 set from the index "offset" of the given array
  2817. * @param array defines the source array
  2818. * @param offset defines the offset in the source array
  2819. * @returns the new Vector3
  2820. */
  2821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2824. * @param array defines the source array
  2825. * @param offset defines the offset in the source array
  2826. * @returns the new Vector3
  2827. * @deprecated Please use FromArray instead.
  2828. */
  2829. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @param result defines the Vector3 where to store the result
  2835. */
  2836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2837. /**
  2838. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2839. * @param array defines the source array
  2840. * @param offset defines the offset in the source array
  2841. * @param result defines the Vector3 where to store the result
  2842. * @deprecated Please use FromArrayToRef instead.
  2843. */
  2844. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the given floats.
  2847. * @param x defines the x coordinate of the source
  2848. * @param y defines the y coordinate of the source
  2849. * @param z defines the z coordinate of the source
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2853. /**
  2854. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2855. * @returns a new empty Vector3
  2856. */
  2857. static Zero(): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2860. * @returns a new unit Vector3
  2861. */
  2862. static One(): Vector3;
  2863. /**
  2864. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2865. * @returns a new up Vector3
  2866. */
  2867. static Up(): Vector3;
  2868. /**
  2869. * Gets a up Vector3 that must not be updated
  2870. */
  2871. static get UpReadOnly(): DeepImmutable<Vector3>;
  2872. /**
  2873. * Gets a zero Vector3 that must not be updated
  2874. */
  2875. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2876. /**
  2877. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2878. * @returns a new down Vector3
  2879. */
  2880. static Down(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2883. * @param rightHandedSystem is the scene right-handed (negative z)
  2884. * @returns a new forward Vector3
  2885. */
  2886. static Forward(rightHandedSystem?: boolean): Vector3;
  2887. /**
  2888. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2889. * @param rightHandedSystem is the scene right-handed (negative-z)
  2890. * @returns a new forward Vector3
  2891. */
  2892. static Backward(rightHandedSystem?: boolean): Vector3;
  2893. /**
  2894. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2895. * @returns a new right Vector3
  2896. */
  2897. static Right(): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2900. * @returns a new left Vector3
  2901. */
  2902. static Left(): Vector3;
  2903. /**
  2904. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2905. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2906. * @param vector defines the Vector3 to transform
  2907. * @param transformation defines the transformation matrix
  2908. * @returns the transformed Vector3
  2909. */
  2910. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2921. * This method computes tranformed coordinates only, not transformed direction vectors
  2922. * @param x define the x coordinate of the source vector
  2923. * @param y define the y coordinate of the source vector
  2924. * @param z define the z coordinate of the source vector
  2925. * @param transformation defines the transformation matrix
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2931. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @returns the new Vector3
  2935. */
  2936. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param x define the x coordinate of the source vector
  2949. * @param y define the y coordinate of the source vector
  2950. * @param z define the z coordinate of the source vector
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2957. * @param value1 defines the first control point
  2958. * @param value2 defines the second control point
  2959. * @param value3 defines the third control point
  2960. * @param value4 defines the fourth control point
  2961. * @param amount defines the amount on the spline to use
  2962. * @returns the new Vector3
  2963. */
  2964. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2965. /**
  2966. * 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"
  2967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2969. * @param value defines the current value
  2970. * @param min defines the lower range value
  2971. * @param max defines the upper range value
  2972. * @returns the new Vector3
  2973. */
  2974. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * 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"
  2977. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2978. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2979. * @param value defines the current value
  2980. * @param min defines the lower range value
  2981. * @param max defines the upper range value
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2985. /**
  2986. * Checks if a given vector is inside a specific range
  2987. * @param v defines the vector to test
  2988. * @param min defines the minimum range
  2989. * @param max defines the maximum range
  2990. */
  2991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2994. * @param value1 defines the first control point
  2995. * @param tangent1 defines the first tangent vector
  2996. * @param value2 defines the second control point
  2997. * @param tangent2 defines the second tangent vector
  2998. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2999. * @returns the new Vector3
  3000. */
  3001. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3004. * @param start defines the start value
  3005. * @param end defines the end value
  3006. * @param amount max defines amount between both (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3018. /**
  3019. * Returns the dot product (float) between the vectors "left" and "right"
  3020. * @param left defines the left operand
  3021. * @param right defines the right operand
  3022. * @returns the dot product
  3023. */
  3024. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3025. /**
  3026. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3027. * The cross product is then orthogonal to both "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the cross product
  3031. */
  3032. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Sets the given vector "result" with the cross product of "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 as the normalization of the given vector
  3043. * @param vector defines the Vector3 to normalize
  3044. * @returns the new Vector3
  3045. */
  3046. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the normalization of the given first vector
  3049. * @param vector defines the Vector3 to normalize
  3050. * @param result defines the Vector3 where to store the result
  3051. */
  3052. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3053. /**
  3054. * Project a Vector3 onto screen space
  3055. * @param vector defines the Vector3 to project
  3056. * @param world defines the world matrix to use
  3057. * @param transform defines the transform (view x projection) matrix to use
  3058. * @param viewport defines the screen viewport to use
  3059. * @returns the new Vector3
  3060. */
  3061. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3062. /** @hidden */
  3063. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3064. /**
  3065. * Unproject from screen space to object space
  3066. * @param source defines the screen space Vector3 to use
  3067. * @param viewportWidth defines the current width of the viewport
  3068. * @param viewportHeight defines the current height of the viewport
  3069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3070. * @param transform defines the transform (view x projection) matrix to use
  3071. * @returns the new Vector3
  3072. */
  3073. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3074. /**
  3075. * Unproject from screen space to object space
  3076. * @param source defines the screen space Vector3 to use
  3077. * @param viewportWidth defines the current width of the viewport
  3078. * @param viewportHeight defines the current height of the viewport
  3079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3080. * @param view defines the view matrix to use
  3081. * @param projection defines the projection matrix to use
  3082. * @returns the new Vector3
  3083. */
  3084. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3085. /**
  3086. * Unproject from screen space to object space
  3087. * @param source defines the screen space Vector3 to use
  3088. * @param viewportWidth defines the current width of the viewport
  3089. * @param viewportHeight defines the current height of the viewport
  3090. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3091. * @param view defines the view matrix to use
  3092. * @param projection defines the projection matrix to use
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3096. /**
  3097. * Unproject from screen space to object space
  3098. * @param sourceX defines the screen space x coordinate to use
  3099. * @param sourceY defines the screen space y coordinate to use
  3100. * @param sourceZ defines the screen space z coordinate to use
  3101. * @param viewportWidth defines the current width of the viewport
  3102. * @param viewportHeight defines the current height of the viewport
  3103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3104. * @param view defines the view matrix to use
  3105. * @param projection defines the projection matrix to use
  3106. * @param result defines the Vector3 where to store the result
  3107. */
  3108. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3109. /**
  3110. * Gets the minimal coordinate values between two Vector3
  3111. * @param left defines the first operand
  3112. * @param right defines the second operand
  3113. * @returns the new Vector3
  3114. */
  3115. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Gets the maximal coordinate values between two Vector3
  3118. * @param left defines the first operand
  3119. * @param right defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Returns the distance between the vectors "value1" and "value2"
  3125. * @param value1 defines the first operand
  3126. * @param value2 defines the second operand
  3127. * @returns the distance
  3128. */
  3129. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3130. /**
  3131. * Returns the squared distance between the vectors "value1" and "value2"
  3132. * @param value1 defines the first operand
  3133. * @param value2 defines the second operand
  3134. * @returns the squared distance
  3135. */
  3136. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 located at the center between "value1" and "value2"
  3139. * @param value1 defines the first operand
  3140. * @param value2 defines the second operand
  3141. * @returns the new Vector3
  3142. */
  3143. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3144. /**
  3145. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3146. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3147. * to something in order to rotate it from its local system to the given target system
  3148. * Note: axis1, axis2 and axis3 are normalized during this operation
  3149. * @param axis1 defines the first axis
  3150. * @param axis2 defines the second axis
  3151. * @param axis3 defines the third axis
  3152. * @returns a new Vector3
  3153. */
  3154. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3155. /**
  3156. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @param ref defines the Vector3 where to store the result
  3161. */
  3162. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3163. }
  3164. /**
  3165. * Vector4 class created for EulerAngle class conversion to Quaternion
  3166. */
  3167. export class Vector4 {
  3168. /** x value of the vector */
  3169. x: number;
  3170. /** y value of the vector */
  3171. y: number;
  3172. /** z value of the vector */
  3173. z: number;
  3174. /** w value of the vector */
  3175. w: number;
  3176. /**
  3177. * Creates a Vector4 object from the given floats.
  3178. * @param x x value of the vector
  3179. * @param y y value of the vector
  3180. * @param z z value of the vector
  3181. * @param w w value of the vector
  3182. */
  3183. constructor(
  3184. /** x value of the vector */
  3185. x: number,
  3186. /** y value of the vector */
  3187. y: number,
  3188. /** z value of the vector */
  3189. z: number,
  3190. /** w value of the vector */
  3191. w: number);
  3192. /**
  3193. * Returns the string with the Vector4 coordinates.
  3194. * @returns a string containing all the vector values
  3195. */
  3196. toString(): string;
  3197. /**
  3198. * Returns the string "Vector4".
  3199. * @returns "Vector4"
  3200. */
  3201. getClassName(): string;
  3202. /**
  3203. * Returns the Vector4 hash code.
  3204. * @returns a unique hash code
  3205. */
  3206. getHashCode(): number;
  3207. /**
  3208. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3209. * @returns the resulting array
  3210. */
  3211. asArray(): number[];
  3212. /**
  3213. * Populates the given array from the given index with the Vector4 coordinates.
  3214. * @param array array to populate
  3215. * @param index index of the array to start at (default: 0)
  3216. * @returns the Vector4.
  3217. */
  3218. toArray(array: FloatArray, index?: number): Vector4;
  3219. /**
  3220. * Adds the given vector to the current Vector4.
  3221. * @param otherVector the vector to add
  3222. * @returns the updated Vector4.
  3223. */
  3224. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3227. * @param otherVector the vector to add
  3228. * @returns the resulting vector
  3229. */
  3230. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3233. * @param otherVector the vector to add
  3234. * @param result the vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Subtract in place the given vector from the current Vector4.
  3240. * @param otherVector the vector to subtract
  3241. * @returns the updated Vector4.
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3246. * @param otherVector the vector to add
  3247. * @returns the new vector with the result
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3252. * @param otherVector the vector to subtract
  3253. * @param result the vector to store the result
  3254. * @returns the current Vector4.
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3259. */
  3260. /**
  3261. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3262. * @param x value to subtract
  3263. * @param y value to subtract
  3264. * @param z value to subtract
  3265. * @param w value to subtract
  3266. * @returns new vector containing the result
  3267. */
  3268. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3269. /**
  3270. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3271. * @param x value to subtract
  3272. * @param y value to subtract
  3273. * @param z value to subtract
  3274. * @param w value to subtract
  3275. * @param result the vector to store the result in
  3276. * @returns the current Vector4.
  3277. */
  3278. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3279. /**
  3280. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3281. * @returns a new vector with the negated values
  3282. */
  3283. negate(): Vector4;
  3284. /**
  3285. * Negate this vector in place
  3286. * @returns this
  3287. */
  3288. negateInPlace(): Vector4;
  3289. /**
  3290. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3291. * @param result defines the Vector3 object where to store the result
  3292. * @returns the current Vector4
  3293. */
  3294. negateToRef(result: Vector4): Vector4;
  3295. /**
  3296. * Multiplies the current Vector4 coordinates by scale (float).
  3297. * @param scale the number to scale with
  3298. * @returns the updated Vector4.
  3299. */
  3300. scaleInPlace(scale: number): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3303. * @param scale the number to scale with
  3304. * @returns a new vector with the result
  3305. */
  3306. scale(scale: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3309. * @param scale the number to scale with
  3310. * @param result a vector to store the result in
  3311. * @returns the current Vector4.
  3312. */
  3313. scaleToRef(scale: number, result: Vector4): Vector4;
  3314. /**
  3315. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3316. * @param scale defines the scale factor
  3317. * @param result defines the Vector4 object where to store the result
  3318. * @returns the unmodified current Vector4
  3319. */
  3320. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3321. /**
  3322. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3323. * @param otherVector the vector to compare against
  3324. * @returns true if they are equal
  3325. */
  3326. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3327. /**
  3328. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3329. * @param otherVector vector to compare against
  3330. * @param epsilon (Default: very small number)
  3331. * @returns true if they are equal
  3332. */
  3333. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3334. /**
  3335. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3336. * @param x x value to compare against
  3337. * @param y y value to compare against
  3338. * @param z z value to compare against
  3339. * @param w w value to compare against
  3340. * @returns true if equal
  3341. */
  3342. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3343. /**
  3344. * Multiplies in place the current Vector4 by the given one.
  3345. * @param otherVector vector to multiple with
  3346. * @returns the updated Vector4.
  3347. */
  3348. multiplyInPlace(otherVector: Vector4): Vector4;
  3349. /**
  3350. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3351. * @param otherVector vector to multiple with
  3352. * @returns resulting new vector
  3353. */
  3354. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3355. /**
  3356. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3357. * @param otherVector vector to multiple with
  3358. * @param result vector to store the result
  3359. * @returns the current Vector4.
  3360. */
  3361. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3364. * @param x x value multiply with
  3365. * @param y y value multiply with
  3366. * @param z z value multiply with
  3367. * @param w w value multiply with
  3368. * @returns resulting new vector
  3369. */
  3370. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3373. * @param otherVector vector to devide with
  3374. * @returns resulting new vector
  3375. */
  3376. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3379. * @param otherVector vector to devide with
  3380. * @param result vector to store the result
  3381. * @returns the current Vector4.
  3382. */
  3383. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones.
  3386. * @param otherVector vector to devide with
  3387. * @returns the updated Vector3.
  3388. */
  3389. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3392. * @param other defines the second operand
  3393. * @returns the current updated Vector4
  3394. */
  3395. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3398. * @param other defines the second operand
  3399. * @returns the current updated Vector4
  3400. */
  3401. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Gets a new Vector4 from current Vector4 floored values
  3404. * @returns a new Vector4
  3405. */
  3406. floor(): Vector4;
  3407. /**
  3408. * Gets a new Vector4 from current Vector3 floored values
  3409. * @returns a new Vector4
  3410. */
  3411. fract(): Vector4;
  3412. /**
  3413. * Returns the Vector4 length (float).
  3414. * @returns the length
  3415. */
  3416. length(): number;
  3417. /**
  3418. * Returns the Vector4 squared length (float).
  3419. * @returns the length squared
  3420. */
  3421. lengthSquared(): number;
  3422. /**
  3423. * Normalizes in place the Vector4.
  3424. * @returns the updated Vector4.
  3425. */
  3426. normalize(): Vector4;
  3427. /**
  3428. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3429. * @returns this converted to a new vector3
  3430. */
  3431. toVector3(): Vector3;
  3432. /**
  3433. * Returns a new Vector4 copied from the current one.
  3434. * @returns the new cloned vector
  3435. */
  3436. clone(): Vector4;
  3437. /**
  3438. * Updates the current Vector4 with the given one coordinates.
  3439. * @param source the source vector to copy from
  3440. * @returns the updated Vector4.
  3441. */
  3442. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Updates the current Vector4 coordinates with the given floats.
  3445. * @param x float to copy from
  3446. * @param y float to copy from
  3447. * @param z float to copy from
  3448. * @param w float to copy from
  3449. * @returns the updated Vector4.
  3450. */
  3451. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3452. /**
  3453. * Updates the current Vector4 coordinates with the given floats.
  3454. * @param x float to set from
  3455. * @param y float to set from
  3456. * @param z float to set from
  3457. * @param w float to set from
  3458. * @returns the updated Vector4.
  3459. */
  3460. set(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Copies the given float to the current Vector3 coordinates
  3463. * @param v defines the x, y, z and w coordinates of the operand
  3464. * @returns the current updated Vector3
  3465. */
  3466. setAll(v: number): Vector4;
  3467. /**
  3468. * Returns a new Vector4 set from the starting index of the given array.
  3469. * @param array the array to pull values from
  3470. * @param offset the offset into the array to start at
  3471. * @returns the new vector
  3472. */
  3473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3474. /**
  3475. * Updates the given vector "result" from the starting index of the given array.
  3476. * @param array the array to pull values from
  3477. * @param offset the offset into the array to start at
  3478. * @param result the vector to store the result in
  3479. */
  3480. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3481. /**
  3482. * Updates the given vector "result" from the starting index of the given Float32Array.
  3483. * @param array the array to pull values from
  3484. * @param offset the offset into the array to start at
  3485. * @param result the vector to store the result in
  3486. */
  3487. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3488. /**
  3489. * Updates the given vector "result" coordinates from the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @param result the vector to the floats in
  3495. */
  3496. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3497. /**
  3498. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3499. * @returns the new vector
  3500. */
  3501. static Zero(): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3504. * @returns the new vector
  3505. */
  3506. static One(): Vector4;
  3507. /**
  3508. * Returns a new normalized Vector4 from the given one.
  3509. * @param vector the vector to normalize
  3510. * @returns the vector
  3511. */
  3512. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3513. /**
  3514. * Updates the given vector "result" from the normalization of the given one.
  3515. * @param vector the vector to normalize
  3516. * @param result the vector to store the result in
  3517. */
  3518. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3519. /**
  3520. * Returns a vector with the minimum values from the left and right vectors
  3521. * @param left left vector to minimize
  3522. * @param right right vector to minimize
  3523. * @returns a new vector with the minimum of the left and right vector values
  3524. */
  3525. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Returns a vector with the maximum values from the left and right vectors
  3528. * @param left left vector to maximize
  3529. * @param right right vector to maximize
  3530. * @returns a new vector with the maximum of the left and right vector values
  3531. */
  3532. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Returns the distance (float) between the vectors "value1" and "value2".
  3535. * @param value1 value to calulate the distance between
  3536. * @param value2 value to calulate the distance between
  3537. * @return the distance between the two vectors
  3538. */
  3539. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3540. /**
  3541. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3542. * @param value1 value to calulate the distance between
  3543. * @param value2 value to calulate the distance between
  3544. * @return the distance between the two vectors squared
  3545. */
  3546. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3547. /**
  3548. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3549. * @param value1 value to calulate the center between
  3550. * @param value2 value to calulate the center between
  3551. * @return the center between the two vectors
  3552. */
  3553. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3554. /**
  3555. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3556. * This methods computes transformed normalized direction vectors only.
  3557. * @param vector the vector to transform
  3558. * @param transformation the transformation matrix to apply
  3559. * @returns the new vector
  3560. */
  3561. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3562. /**
  3563. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @param result the vector to store the result in
  3568. */
  3569. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param x value to transform
  3574. * @param y value to transform
  3575. * @param z value to transform
  3576. * @param w value to transform
  3577. * @param transformation the transformation matrix to apply
  3578. * @param result the vector to store the results in
  3579. */
  3580. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3581. /**
  3582. * Creates a new Vector4 from a Vector3
  3583. * @param source defines the source data
  3584. * @param w defines the 4th component (default is 0)
  3585. * @returns a new Vector4
  3586. */
  3587. static FromVector3(source: Vector3, w?: number): Vector4;
  3588. }
  3589. /**
  3590. * Class used to store quaternion data
  3591. * @see https://en.wikipedia.org/wiki/Quaternion
  3592. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3593. */
  3594. export class Quaternion {
  3595. /** defines the first component (0 by default) */
  3596. x: number;
  3597. /** defines the second component (0 by default) */
  3598. y: number;
  3599. /** defines the third component (0 by default) */
  3600. z: number;
  3601. /** defines the fourth component (1.0 by default) */
  3602. w: number;
  3603. /**
  3604. * Creates a new Quaternion from the given floats
  3605. * @param x defines the first component (0 by default)
  3606. * @param y defines the second component (0 by default)
  3607. * @param z defines the third component (0 by default)
  3608. * @param w defines the fourth component (1.0 by default)
  3609. */
  3610. constructor(
  3611. /** defines the first component (0 by default) */
  3612. x?: number,
  3613. /** defines the second component (0 by default) */
  3614. y?: number,
  3615. /** defines the third component (0 by default) */
  3616. z?: number,
  3617. /** defines the fourth component (1.0 by default) */
  3618. w?: number);
  3619. /**
  3620. * Gets a string representation for the current quaternion
  3621. * @returns a string with the Quaternion coordinates
  3622. */
  3623. toString(): string;
  3624. /**
  3625. * Gets the class name of the quaternion
  3626. * @returns the string "Quaternion"
  3627. */
  3628. getClassName(): string;
  3629. /**
  3630. * Gets a hash code for this quaternion
  3631. * @returns the quaternion hash code
  3632. */
  3633. getHashCode(): number;
  3634. /**
  3635. * Copy the quaternion to an array
  3636. * @returns a new array populated with 4 elements from the quaternion coordinates
  3637. */
  3638. asArray(): number[];
  3639. /**
  3640. * Check if two quaternions are equals
  3641. * @param otherQuaternion defines the second operand
  3642. * @return true if the current quaternion and the given one coordinates are strictly equals
  3643. */
  3644. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3645. /**
  3646. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3647. * @param otherQuaternion defines the other quaternion
  3648. * @param epsilon defines the minimal distance to consider equality
  3649. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3650. */
  3651. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3652. /**
  3653. * Clone the current quaternion
  3654. * @returns a new quaternion copied from the current one
  3655. */
  3656. clone(): Quaternion;
  3657. /**
  3658. * Copy a quaternion to the current one
  3659. * @param other defines the other quaternion
  3660. * @returns the updated current quaternion
  3661. */
  3662. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Updates the current quaternion with the given float coordinates
  3665. * @param x defines the x coordinate
  3666. * @param y defines the y coordinate
  3667. * @param z defines the z coordinate
  3668. * @param w defines the w coordinate
  3669. * @returns the updated current quaternion
  3670. */
  3671. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3672. /**
  3673. * Updates the current quaternion from the given float coordinates
  3674. * @param x defines the x coordinate
  3675. * @param y defines the y coordinate
  3676. * @param z defines the z coordinate
  3677. * @param w defines the w coordinate
  3678. * @returns the updated current quaternion
  3679. */
  3680. set(x: number, y: number, z: number, w: number): Quaternion;
  3681. /**
  3682. * Adds two quaternions
  3683. * @param other defines the second operand
  3684. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3685. */
  3686. add(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Add a quaternion to the current one
  3689. * @param other defines the quaternion to add
  3690. * @returns the current quaternion
  3691. */
  3692. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Subtract two quaternions
  3695. * @param other defines the second operand
  3696. * @returns a new quaternion as the subtraction result of the given one from the current one
  3697. */
  3698. subtract(other: Quaternion): Quaternion;
  3699. /**
  3700. * Multiplies the current quaternion by a scale factor
  3701. * @param value defines the scale factor
  3702. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3703. */
  3704. scale(value: number): Quaternion;
  3705. /**
  3706. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3707. * @param scale defines the scale factor
  3708. * @param result defines the Quaternion object where to store the result
  3709. * @returns the unmodified current quaternion
  3710. */
  3711. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3712. /**
  3713. * Multiplies in place the current quaternion by a scale factor
  3714. * @param value defines the scale factor
  3715. * @returns the current modified quaternion
  3716. */
  3717. scaleInPlace(value: number): Quaternion;
  3718. /**
  3719. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3720. * @param scale defines the scale factor
  3721. * @param result defines the Quaternion object where to store the result
  3722. * @returns the unmodified current quaternion
  3723. */
  3724. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Multiplies two quaternions
  3727. * @param q1 defines the second operand
  3728. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3729. */
  3730. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3733. * @param q1 defines the second operand
  3734. * @param result defines the target quaternion
  3735. * @returns the current quaternion
  3736. */
  3737. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @returns the currentupdated quaternion
  3742. */
  3743. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3744. /**
  3745. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3746. * @param ref defines the target quaternion
  3747. * @returns the current quaternion
  3748. */
  3749. conjugateToRef(ref: Quaternion): Quaternion;
  3750. /**
  3751. * Conjugates in place (1-q) the current quaternion
  3752. * @returns the current updated quaternion
  3753. */
  3754. conjugateInPlace(): Quaternion;
  3755. /**
  3756. * Conjugates in place (1-q) the current quaternion
  3757. * @returns a new quaternion
  3758. */
  3759. conjugate(): Quaternion;
  3760. /**
  3761. * Gets length of current quaternion
  3762. * @returns the quaternion length (float)
  3763. */
  3764. length(): number;
  3765. /**
  3766. * Normalize in place the current quaternion
  3767. * @returns the current updated quaternion
  3768. */
  3769. normalize(): Quaternion;
  3770. /**
  3771. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3772. * @param order is a reserved parameter and is ignore for now
  3773. * @returns a new Vector3 containing the Euler angles
  3774. */
  3775. toEulerAngles(order?: string): Vector3;
  3776. /**
  3777. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3778. * @param result defines the vector which will be filled with the Euler angles
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns the current unchanged quaternion
  3781. */
  3782. toEulerAnglesToRef(result: Vector3): Quaternion;
  3783. /**
  3784. * Updates the given rotation matrix with the current quaternion values
  3785. * @param result defines the target matrix
  3786. * @returns the current unchanged quaternion
  3787. */
  3788. toRotationMatrix(result: Matrix): Quaternion;
  3789. /**
  3790. * Updates the current quaternion from the given rotation matrix values
  3791. * @param matrix defines the source matrix
  3792. * @returns the current updated quaternion
  3793. */
  3794. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from a rotation matrix
  3797. * @param matrix defines the source matrix
  3798. * @returns a new quaternion created from the given rotation matrix values
  3799. */
  3800. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3801. /**
  3802. * Updates the given quaternion with the given rotation matrix values
  3803. * @param matrix defines the source matrix
  3804. * @param result defines the target quaternion
  3805. */
  3806. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3807. /**
  3808. * Returns the dot product (float) between the quaternions "left" and "right"
  3809. * @param left defines the left operand
  3810. * @param right defines the right operand
  3811. * @returns the dot product
  3812. */
  3813. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3814. /**
  3815. * Checks if the two quaternions are close to each other
  3816. * @param quat0 defines the first quaternion to check
  3817. * @param quat1 defines the second quaternion to check
  3818. * @returns true if the two quaternions are close to each other
  3819. */
  3820. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3821. /**
  3822. * Creates an empty quaternion
  3823. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3824. */
  3825. static Zero(): Quaternion;
  3826. /**
  3827. * Inverse a given quaternion
  3828. * @param q defines the source quaternion
  3829. * @returns a new quaternion as the inverted current quaternion
  3830. */
  3831. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Inverse a given quaternion
  3834. * @param q defines the source quaternion
  3835. * @param result the quaternion the result will be stored in
  3836. * @returns the result quaternion
  3837. */
  3838. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3839. /**
  3840. * Creates an identity quaternion
  3841. * @returns the identity quaternion
  3842. */
  3843. static Identity(): Quaternion;
  3844. /**
  3845. * Gets a boolean indicating if the given quaternion is identity
  3846. * @param quaternion defines the quaternion to check
  3847. * @returns true if the quaternion is identity
  3848. */
  3849. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3850. /**
  3851. * Creates a quaternion from a rotation around an axis
  3852. * @param axis defines the axis to use
  3853. * @param angle defines the angle to use
  3854. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3855. */
  3856. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3857. /**
  3858. * Creates a rotation around an axis and stores it into the given quaternion
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @param result defines the target quaternion
  3862. * @returns the target quaternion
  3863. */
  3864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3865. /**
  3866. * Creates a new quaternion from data stored into an array
  3867. * @param array defines the data source
  3868. * @param offset defines the offset in the source array where the data starts
  3869. * @returns a new quaternion
  3870. */
  3871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3872. /**
  3873. * Updates the given quaternion "result" from the starting index of the given array.
  3874. * @param array the array to pull values from
  3875. * @param offset the offset into the array to start at
  3876. * @param result the quaternion to store the result in
  3877. */
  3878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3879. /**
  3880. * Create a quaternion from Euler rotation angles
  3881. * @param x Pitch
  3882. * @param y Yaw
  3883. * @param z Roll
  3884. * @returns the new Quaternion
  3885. */
  3886. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3887. /**
  3888. * Updates a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @param result the quaternion to store the result
  3893. * @returns the updated quaternion
  3894. */
  3895. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3896. /**
  3897. * Create a quaternion from Euler rotation vector
  3898. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3899. * @returns the new Quaternion
  3900. */
  3901. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3902. /**
  3903. * Updates a quaternion from Euler rotation vector
  3904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3905. * @param result the quaternion to store the result
  3906. * @returns the updated quaternion
  3907. */
  3908. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3911. * @param yaw defines the rotation around Y axis
  3912. * @param pitch defines the rotation around X axis
  3913. * @param roll defines the rotation around Z axis
  3914. * @returns the new quaternion
  3915. */
  3916. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3917. /**
  3918. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @param result defines the target quaternion
  3923. */
  3924. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3925. /**
  3926. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3927. * @param alpha defines the rotation around first axis
  3928. * @param beta defines the rotation around second axis
  3929. * @param gamma defines the rotation around third axis
  3930. * @returns the new quaternion
  3931. */
  3932. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @param result defines the target quaternion
  3939. */
  3940. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3941. /**
  3942. * 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)
  3943. * @param axis1 defines the first axis
  3944. * @param axis2 defines the second axis
  3945. * @param axis3 defines the third axis
  3946. * @returns the new quaternion
  3947. */
  3948. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3949. /**
  3950. * 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
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @param ref defines the target quaternion
  3955. */
  3956. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3957. /**
  3958. * Interpolates between two quaternions
  3959. * @param left defines first quaternion
  3960. * @param right defines second quaternion
  3961. * @param amount defines the gradient to use
  3962. * @returns the new interpolated quaternion
  3963. */
  3964. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3965. /**
  3966. * Interpolates between two quaternions and stores it into a target quaternion
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @param result defines the target quaternion
  3971. */
  3972. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3973. /**
  3974. * Interpolate between two quaternions using Hermite interpolation
  3975. * @param value1 defines first quaternion
  3976. * @param tangent1 defines the incoming tangent
  3977. * @param value2 defines second quaternion
  3978. * @param tangent2 defines the outgoing tangent
  3979. * @param amount defines the target quaternion
  3980. * @returns the new interpolated quaternion
  3981. */
  3982. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3983. }
  3984. /**
  3985. * Class used to store matrix data (4x4)
  3986. */
  3987. export class Matrix {
  3988. private static _updateFlagSeed;
  3989. private static _identityReadOnly;
  3990. private _isIdentity;
  3991. private _isIdentityDirty;
  3992. private _isIdentity3x2;
  3993. private _isIdentity3x2Dirty;
  3994. /**
  3995. * Gets the update flag of the matrix which is an unique number for the matrix.
  3996. * It will be incremented every time the matrix data change.
  3997. * You can use it to speed the comparison between two versions of the same matrix.
  3998. */
  3999. updateFlag: number;
  4000. private readonly _m;
  4001. /**
  4002. * Gets the internal data of the matrix
  4003. */
  4004. get m(): DeepImmutable<Float32Array>;
  4005. /** @hidden */
  4006. _markAsUpdated(): void;
  4007. /** @hidden */
  4008. private _updateIdentityStatus;
  4009. /**
  4010. * Creates an empty matrix (filled with zeros)
  4011. */
  4012. constructor();
  4013. /**
  4014. * Check if the current matrix is identity
  4015. * @returns true is the matrix is the identity matrix
  4016. */
  4017. isIdentity(): boolean;
  4018. /**
  4019. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4020. * @returns true is the matrix is the identity matrix
  4021. */
  4022. isIdentityAs3x2(): boolean;
  4023. /**
  4024. * Gets the determinant of the matrix
  4025. * @returns the matrix determinant
  4026. */
  4027. determinant(): number;
  4028. /**
  4029. * Returns the matrix as a Float32Array
  4030. * @returns the matrix underlying array
  4031. */
  4032. toArray(): DeepImmutable<Float32Array>;
  4033. /**
  4034. * Returns the matrix as a Float32Array
  4035. * @returns the matrix underlying array.
  4036. */
  4037. asArray(): DeepImmutable<Float32Array>;
  4038. /**
  4039. * Inverts the current matrix in place
  4040. * @returns the current inverted matrix
  4041. */
  4042. invert(): Matrix;
  4043. /**
  4044. * Sets all the matrix elements to zero
  4045. * @returns the current matrix
  4046. */
  4047. reset(): Matrix;
  4048. /**
  4049. * Adds the current matrix with a second one
  4050. * @param other defines the matrix to add
  4051. * @returns a new matrix as the addition of the current matrix and the given one
  4052. */
  4053. add(other: DeepImmutable<Matrix>): Matrix;
  4054. /**
  4055. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4056. * @param other defines the matrix to add
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4061. /**
  4062. * Adds in place the given matrix to the current matrix
  4063. * @param other defines the second operand
  4064. * @returns the current updated matrix
  4065. */
  4066. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4067. /**
  4068. * Sets the given matrix to the current inverted Matrix
  4069. * @param other defines the target matrix
  4070. * @returns the unmodified current matrix
  4071. */
  4072. invertToRef(other: Matrix): Matrix;
  4073. /**
  4074. * add a value at the specified position in the current Matrix
  4075. * @param index the index of the value within the matrix. between 0 and 15.
  4076. * @param value the value to be added
  4077. * @returns the current updated matrix
  4078. */
  4079. addAtIndex(index: number, value: number): Matrix;
  4080. /**
  4081. * mutiply the specified position in the current Matrix by a value
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. multiplyAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * Inserts the translation vector (using 3 floats) in the current matrix
  4089. * @param x defines the 1st component of the translation
  4090. * @param y defines the 2nd component of the translation
  4091. * @param z defines the 3rd component of the translation
  4092. * @returns the current updated matrix
  4093. */
  4094. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4095. /**
  4096. * Adds the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Inserts the translation vector in the current matrix
  4105. * @param vector3 defines the translation to insert
  4106. * @returns the current updated matrix
  4107. */
  4108. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4109. /**
  4110. * Gets the translation value of the current matrix
  4111. * @returns a new Vector3 as the extracted translation from the matrix
  4112. */
  4113. getTranslation(): Vector3;
  4114. /**
  4115. * Fill a Vector3 with the extracted translation from the matrix
  4116. * @param result defines the Vector3 where to store the translation
  4117. * @returns the current matrix
  4118. */
  4119. getTranslationToRef(result: Vector3): Matrix;
  4120. /**
  4121. * Remove rotation and scaling part from the matrix
  4122. * @returns the updated matrix
  4123. */
  4124. removeRotationAndScaling(): Matrix;
  4125. /**
  4126. * Multiply two matrices
  4127. * @param other defines the second operand
  4128. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4129. */
  4130. multiply(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Copy the current matrix from the given one
  4133. * @param other defines the source matrix
  4134. * @returns the current updated matrix
  4135. */
  4136. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Populates the given array from the starting index with the current matrix values
  4139. * @param array defines the target array
  4140. * @param offset defines the offset in the target array where to start storing values
  4141. * @returns the current matrix
  4142. */
  4143. copyToArray(array: Float32Array, offset?: number): Matrix;
  4144. /**
  4145. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4146. * @param other defines the second operand
  4147. * @param result defines the matrix where to store the multiplication
  4148. * @returns the current matrix
  4149. */
  4150. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4151. /**
  4152. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the array where to store the multiplication
  4155. * @param offset defines the offset in the target array where to start storing values
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4159. /**
  4160. * Check equality between this matrix and a second one
  4161. * @param value defines the second matrix to compare
  4162. * @returns true is the current matrix and the given one values are strictly equal
  4163. */
  4164. equals(value: DeepImmutable<Matrix>): boolean;
  4165. /**
  4166. * Clone the current matrix
  4167. * @returns a new matrix from the current matrix
  4168. */
  4169. clone(): Matrix;
  4170. /**
  4171. * Returns the name of the current matrix class
  4172. * @returns the string "Matrix"
  4173. */
  4174. getClassName(): string;
  4175. /**
  4176. * Gets the hash code of the current matrix
  4177. * @returns the hash code
  4178. */
  4179. getHashCode(): number;
  4180. /**
  4181. * Decomposes the current Matrix into a translation, rotation and scaling components
  4182. * @param scale defines the scale vector3 given as a reference to update
  4183. * @param rotation defines the rotation quaternion given as a reference to update
  4184. * @param translation defines the translation vector3 given as a reference to update
  4185. * @returns true if operation was successful
  4186. */
  4187. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4188. /**
  4189. * Gets specific row of the matrix
  4190. * @param index defines the number of the row to get
  4191. * @returns the index-th row of the current matrix as a new Vector4
  4192. */
  4193. getRow(index: number): Nullable<Vector4>;
  4194. /**
  4195. * Sets the index-th row of the current matrix to the vector4 values
  4196. * @param index defines the number of the row to set
  4197. * @param row defines the target vector4
  4198. * @returns the updated current matrix
  4199. */
  4200. setRow(index: number, row: Vector4): Matrix;
  4201. /**
  4202. * Compute the transpose of the matrix
  4203. * @returns the new transposed matrix
  4204. */
  4205. transpose(): Matrix;
  4206. /**
  4207. * Compute the transpose of the matrix and store it in a given matrix
  4208. * @param result defines the target matrix
  4209. * @returns the current matrix
  4210. */
  4211. transposeToRef(result: Matrix): Matrix;
  4212. /**
  4213. * Sets the index-th row of the current matrix with the given 4 x float values
  4214. * @param index defines the row index
  4215. * @param x defines the x component to set
  4216. * @param y defines the y component to set
  4217. * @param z defines the z component to set
  4218. * @param w defines the w component to set
  4219. * @returns the updated current matrix
  4220. */
  4221. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4222. /**
  4223. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4224. * @param scale defines the scale factor
  4225. * @returns a new matrix
  4226. */
  4227. scale(scale: number): Matrix;
  4228. /**
  4229. * Scale the current matrix values by a factor to a given result matrix
  4230. * @param scale defines the scale factor
  4231. * @param result defines the matrix to store the result
  4232. * @returns the current matrix
  4233. */
  4234. scaleToRef(scale: number, result: Matrix): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor and add the result to a given matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the Matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4244. * @param ref matrix to store the result
  4245. */
  4246. toNormalMatrix(ref: Matrix): void;
  4247. /**
  4248. * Gets only rotation part of the current matrix
  4249. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4250. */
  4251. getRotationMatrix(): Matrix;
  4252. /**
  4253. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4254. * @param result defines the target matrix to store data to
  4255. * @returns the current matrix
  4256. */
  4257. getRotationMatrixToRef(result: Matrix): Matrix;
  4258. /**
  4259. * Toggles model matrix from being right handed to left handed in place and vice versa
  4260. */
  4261. toggleModelMatrixHandInPlace(): void;
  4262. /**
  4263. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4264. */
  4265. toggleProjectionMatrixHandInPlace(): void;
  4266. /**
  4267. * Creates a matrix from an array
  4268. * @param array defines the source array
  4269. * @param offset defines an offset in the source array
  4270. * @returns a new Matrix set from the starting index of the given array
  4271. */
  4272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4273. /**
  4274. * Copy the content of an array into a given matrix
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @param result defines the target matrix
  4278. */
  4279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4280. /**
  4281. * Stores an array into a matrix after having multiplied each component by a given factor
  4282. * @param array defines the source array
  4283. * @param offset defines the offset in the source array
  4284. * @param scale defines the scaling factor
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4288. /**
  4289. * Gets an identity matrix that must not be updated
  4290. */
  4291. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4292. /**
  4293. * Stores a list of values (16) inside a given matrix
  4294. * @param initialM11 defines 1st value of 1st row
  4295. * @param initialM12 defines 2nd value of 1st row
  4296. * @param initialM13 defines 3rd value of 1st row
  4297. * @param initialM14 defines 4th value of 1st row
  4298. * @param initialM21 defines 1st value of 2nd row
  4299. * @param initialM22 defines 2nd value of 2nd row
  4300. * @param initialM23 defines 3rd value of 2nd row
  4301. * @param initialM24 defines 4th value of 2nd row
  4302. * @param initialM31 defines 1st value of 3rd row
  4303. * @param initialM32 defines 2nd value of 3rd row
  4304. * @param initialM33 defines 3rd value of 3rd row
  4305. * @param initialM34 defines 4th value of 3rd row
  4306. * @param initialM41 defines 1st value of 4th row
  4307. * @param initialM42 defines 2nd value of 4th row
  4308. * @param initialM43 defines 3rd value of 4th row
  4309. * @param initialM44 defines 4th value of 4th row
  4310. * @param result defines the target matrix
  4311. */
  4312. 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;
  4313. /**
  4314. * Creates new matrix from a list of values (16)
  4315. * @param initialM11 defines 1st value of 1st row
  4316. * @param initialM12 defines 2nd value of 1st row
  4317. * @param initialM13 defines 3rd value of 1st row
  4318. * @param initialM14 defines 4th value of 1st row
  4319. * @param initialM21 defines 1st value of 2nd row
  4320. * @param initialM22 defines 2nd value of 2nd row
  4321. * @param initialM23 defines 3rd value of 2nd row
  4322. * @param initialM24 defines 4th value of 2nd row
  4323. * @param initialM31 defines 1st value of 3rd row
  4324. * @param initialM32 defines 2nd value of 3rd row
  4325. * @param initialM33 defines 3rd value of 3rd row
  4326. * @param initialM34 defines 4th value of 3rd row
  4327. * @param initialM41 defines 1st value of 4th row
  4328. * @param initialM42 defines 2nd value of 4th row
  4329. * @param initialM43 defines 3rd value of 4th row
  4330. * @param initialM44 defines 4th value of 4th row
  4331. * @returns the new matrix
  4332. */
  4333. 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;
  4334. /**
  4335. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4336. * @param scale defines the scale vector3
  4337. * @param rotation defines the rotation quaternion
  4338. * @param translation defines the translation vector3
  4339. * @returns a new matrix
  4340. */
  4341. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4342. /**
  4343. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @param result defines the target matrix
  4348. */
  4349. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4350. /**
  4351. * Creates a new identity matrix
  4352. * @returns a new identity matrix
  4353. */
  4354. static Identity(): Matrix;
  4355. /**
  4356. * Creates a new identity matrix and stores the result in a given matrix
  4357. * @param result defines the target matrix
  4358. */
  4359. static IdentityToRef(result: Matrix): void;
  4360. /**
  4361. * Creates a new zero matrix
  4362. * @returns a new zero matrix
  4363. */
  4364. static Zero(): Matrix;
  4365. /**
  4366. * Creates a new rotation matrix for "angle" radians around the X axis
  4367. * @param angle defines the angle (in radians) to use
  4368. * @return the new matrix
  4369. */
  4370. static RotationX(angle: number): Matrix;
  4371. /**
  4372. * Creates a new matrix as the invert of a given matrix
  4373. * @param source defines the source matrix
  4374. * @returns the new matrix
  4375. */
  4376. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4377. /**
  4378. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4379. * @param angle defines the angle (in radians) to use
  4380. * @param result defines the target matrix
  4381. */
  4382. static RotationXToRef(angle: number, result: Matrix): void;
  4383. /**
  4384. * Creates a new rotation matrix for "angle" radians around the Y axis
  4385. * @param angle defines the angle (in radians) to use
  4386. * @return the new matrix
  4387. */
  4388. static RotationY(angle: number): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4391. * @param angle defines the angle (in radians) to use
  4392. * @param result defines the target matrix
  4393. */
  4394. static RotationYToRef(angle: number, result: Matrix): void;
  4395. /**
  4396. * Creates a new rotation matrix for "angle" radians around the Z axis
  4397. * @param angle defines the angle (in radians) to use
  4398. * @return the new matrix
  4399. */
  4400. static RotationZ(angle: number): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationZToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the given axis
  4409. * @param axis defines the axis to use
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @param result defines the target matrix
  4419. */
  4420. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4421. /**
  4422. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4423. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4424. * @param from defines the vector to align
  4425. * @param to defines the vector to align to
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a rotation matrix
  4431. * @param yaw defines the yaw angle in radians (Y axis)
  4432. * @param pitch defines the pitch angle in radians (X axis)
  4433. * @param roll defines the roll angle in radians (X axis)
  4434. * @returns the new rotation matrix
  4435. */
  4436. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4437. /**
  4438. * Creates a rotation matrix and stores it in a given matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4445. /**
  4446. * Creates a scaling matrix
  4447. * @param x defines the scale factor on X axis
  4448. * @param y defines the scale factor on Y axis
  4449. * @param z defines the scale factor on Z axis
  4450. * @returns the new matrix
  4451. */
  4452. static Scaling(x: number, y: number, z: number): Matrix;
  4453. /**
  4454. * Creates a scaling matrix and stores it in a given matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @param result defines the target matrix
  4459. */
  4460. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4461. /**
  4462. * Creates a translation matrix
  4463. * @param x defines the translation on X axis
  4464. * @param y defines the translation on Y axis
  4465. * @param z defines the translationon Z axis
  4466. * @returns the new matrix
  4467. */
  4468. static Translation(x: number, y: number, z: number): Matrix;
  4469. /**
  4470. * Creates a translation matrix and stores it in a given matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @param result defines the target matrix
  4475. */
  4476. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4477. /**
  4478. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4479. * @param startValue defines the start value
  4480. * @param endValue defines the end value
  4481. * @param gradient defines the gradient factor
  4482. * @returns the new matrix
  4483. */
  4484. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4485. /**
  4486. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @param result defines the Matrix object where to store data
  4491. */
  4492. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4493. /**
  4494. * Builds a new matrix whose values are computed by:
  4495. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4496. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4497. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4498. * @param startValue defines the first matrix
  4499. * @param endValue defines the second matrix
  4500. * @param gradient defines the gradient between the two matrices
  4501. * @returns the new matrix
  4502. */
  4503. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4504. /**
  4505. * Update a matrix to values which are computed by:
  4506. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4507. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4508. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4509. * @param startValue defines the first matrix
  4510. * @param endValue defines the second matrix
  4511. * @param gradient defines the gradient between the two matrices
  4512. * @param result defines the target matrix
  4513. */
  4514. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4515. /**
  4516. * 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"
  4517. * This function works in left handed mode
  4518. * @param eye defines the final position of the entity
  4519. * @param target defines where the entity should look at
  4520. * @param up defines the up vector for the entity
  4521. * @returns the new matrix
  4522. */
  4523. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4524. /**
  4525. * 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".
  4526. * This function works in left handed mode
  4527. * @param eye defines the final position of the entity
  4528. * @param target defines where the entity should look at
  4529. * @param up defines the up vector for the entity
  4530. * @param result defines the target matrix
  4531. */
  4532. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * 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"
  4535. * This function works in right handed mode
  4536. * @param eye defines the final position of the entity
  4537. * @param target defines where the entity should look at
  4538. * @param up defines the up vector for the entity
  4539. * @returns the new matrix
  4540. */
  4541. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4542. /**
  4543. * 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".
  4544. * This function works in right handed mode
  4545. * @param eye defines the final position of the entity
  4546. * @param target defines where the entity should look at
  4547. * @param up defines the up vector for the entity
  4548. * @param result defines the target matrix
  4549. */
  4550. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Create a left-handed orthographic projection matrix
  4553. * @param width defines the viewport width
  4554. * @param height defines the viewport height
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a left-handed orthographic projection matrix
  4558. */
  4559. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Store a left-handed orthographic projection to a given matrix
  4562. * @param width defines the viewport width
  4563. * @param height defines the viewport height
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. */
  4568. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4569. /**
  4570. * Create a left-handed orthographic projection matrix
  4571. * @param left defines the viewport left coordinate
  4572. * @param right defines the viewport right coordinate
  4573. * @param bottom defines the viewport bottom coordinate
  4574. * @param top defines the viewport top coordinate
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @returns a new matrix as a left-handed orthographic projection matrix
  4578. */
  4579. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4580. /**
  4581. * Stores a left-handed orthographic projection into a given matrix
  4582. * @param left defines the viewport left coordinate
  4583. * @param right defines the viewport right coordinate
  4584. * @param bottom defines the viewport bottom coordinate
  4585. * @param top defines the viewport top coordinate
  4586. * @param znear defines the near clip plane
  4587. * @param zfar defines the far clip plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4591. /**
  4592. * Creates a right-handed orthographic projection matrix
  4593. * @param left defines the viewport left coordinate
  4594. * @param right defines the viewport right coordinate
  4595. * @param bottom defines the viewport bottom coordinate
  4596. * @param top defines the viewport top coordinate
  4597. * @param znear defines the near clip plane
  4598. * @param zfar defines the far clip plane
  4599. * @returns a new matrix as a right-handed orthographic projection matrix
  4600. */
  4601. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4602. /**
  4603. * Stores a right-handed orthographic projection into a given matrix
  4604. * @param left defines the viewport left coordinate
  4605. * @param right defines the viewport right coordinate
  4606. * @param bottom defines the viewport bottom coordinate
  4607. * @param top defines the viewport top coordinate
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Creates a left-handed perspective projection matrix
  4615. * @param width defines the viewport width
  4616. * @param height defines the viewport height
  4617. * @param znear defines the near clip plane
  4618. * @param zfar defines the far clip plane
  4619. * @returns a new matrix as a left-handed perspective projection matrix
  4620. */
  4621. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4622. /**
  4623. * Creates a left-handed perspective projection matrix
  4624. * @param fov defines the horizontal field of view
  4625. * @param aspect defines the aspect ratio
  4626. * @param znear defines the near clip plane
  4627. * @param zfar defines the far clip plane
  4628. * @returns a new matrix as a left-handed perspective projection matrix
  4629. */
  4630. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4631. /**
  4632. * Stores a left-handed perspective projection into a given matrix
  4633. * @param fov defines the horizontal field of view
  4634. * @param aspect defines the aspect ratio
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @param result defines the target matrix
  4638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4639. */
  4640. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4641. /**
  4642. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4643. * @param fov defines the horizontal field of view
  4644. * @param aspect defines the aspect ratio
  4645. * @param znear defines the near clip plane
  4646. * @param zfar not used as infinity is used as far clip
  4647. * @param result defines the target matrix
  4648. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4649. */
  4650. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4651. /**
  4652. * Creates a right-handed perspective projection matrix
  4653. * @param fov defines the horizontal field of view
  4654. * @param aspect defines the aspect ratio
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a right-handed perspective projection matrix
  4658. */
  4659. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Stores a right-handed perspective projection into a given matrix
  4662. * @param fov defines the horizontal field of view
  4663. * @param aspect defines the aspect ratio
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4668. */
  4669. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4670. /**
  4671. * Stores a right-handed perspective projection into a given matrix
  4672. * @param fov defines the horizontal field of view
  4673. * @param aspect defines the aspect ratio
  4674. * @param znear defines the near clip plane
  4675. * @param zfar not used as infinity is used as far clip
  4676. * @param result defines the target matrix
  4677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4678. */
  4679. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4680. /**
  4681. * Stores a perspective projection for WebVR info a given matrix
  4682. * @param fov defines the field of view
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4687. */
  4688. static PerspectiveFovWebVRToRef(fov: {
  4689. upDegrees: number;
  4690. downDegrees: number;
  4691. leftDegrees: number;
  4692. rightDegrees: number;
  4693. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4694. /**
  4695. * Computes a complete transformation matrix
  4696. * @param viewport defines the viewport to use
  4697. * @param world defines the world matrix
  4698. * @param view defines the view matrix
  4699. * @param projection defines the projection matrix
  4700. * @param zmin defines the near clip plane
  4701. * @param zmax defines the far clip plane
  4702. * @returns the transformation matrix
  4703. */
  4704. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4705. /**
  4706. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4707. * @param matrix defines the matrix to use
  4708. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4709. */
  4710. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4711. /**
  4712. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4713. * @param matrix defines the matrix to use
  4714. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4715. */
  4716. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4717. /**
  4718. * Compute the transpose of a given matrix
  4719. * @param matrix defines the matrix to transpose
  4720. * @returns the new matrix
  4721. */
  4722. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4723. /**
  4724. * Compute the transpose of a matrix and store it in a target matrix
  4725. * @param matrix defines the matrix to transpose
  4726. * @param result defines the target matrix
  4727. */
  4728. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4729. /**
  4730. * Computes a reflection matrix from a plane
  4731. * @param plane defines the reflection plane
  4732. * @returns a new matrix
  4733. */
  4734. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4735. /**
  4736. * Computes a reflection matrix from a plane
  4737. * @param plane defines the reflection plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4741. /**
  4742. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4743. * @param xaxis defines the value of the 1st axis
  4744. * @param yaxis defines the value of the 2nd axis
  4745. * @param zaxis defines the value of the 3rd axis
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4749. /**
  4750. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4751. * @param quat defines the quaternion to use
  4752. * @param result defines the target matrix
  4753. */
  4754. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4755. }
  4756. /**
  4757. * @hidden
  4758. */
  4759. export class TmpVectors {
  4760. static Vector2: Vector2[];
  4761. static Vector3: Vector3[];
  4762. static Vector4: Vector4[];
  4763. static Quaternion: Quaternion[];
  4764. static Matrix: Matrix[];
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /**
  4769. * Defines potential orientation for back face culling
  4770. */
  4771. export enum Orientation {
  4772. /**
  4773. * Clockwise
  4774. */
  4775. CW = 0,
  4776. /** Counter clockwise */
  4777. CCW = 1
  4778. }
  4779. /** Class used to represent a Bezier curve */
  4780. export class BezierCurve {
  4781. /**
  4782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4783. * @param t defines the time
  4784. * @param x1 defines the left coordinate on X axis
  4785. * @param y1 defines the left coordinate on Y axis
  4786. * @param x2 defines the right coordinate on X axis
  4787. * @param y2 defines the right coordinate on Y axis
  4788. * @returns the interpolated value
  4789. */
  4790. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4791. }
  4792. /**
  4793. * Defines angle representation
  4794. */
  4795. export class Angle {
  4796. private _radians;
  4797. /**
  4798. * Creates an Angle object of "radians" radians (float).
  4799. * @param radians the angle in radians
  4800. */
  4801. constructor(radians: number);
  4802. /**
  4803. * Get value in degrees
  4804. * @returns the Angle value in degrees (float)
  4805. */
  4806. degrees(): number;
  4807. /**
  4808. * Get value in radians
  4809. * @returns the Angle value in radians (float)
  4810. */
  4811. radians(): number;
  4812. /**
  4813. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4814. * @param a defines first vector
  4815. * @param b defines second vector
  4816. * @returns a new Angle
  4817. */
  4818. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4819. /**
  4820. * Gets a new Angle object from the given float in radians
  4821. * @param radians defines the angle value in radians
  4822. * @returns a new Angle
  4823. */
  4824. static FromRadians(radians: number): Angle;
  4825. /**
  4826. * Gets a new Angle object from the given float in degrees
  4827. * @param degrees defines the angle value in degrees
  4828. * @returns a new Angle
  4829. */
  4830. static FromDegrees(degrees: number): Angle;
  4831. }
  4832. /**
  4833. * This represents an arc in a 2d space.
  4834. */
  4835. export class Arc2 {
  4836. /** Defines the start point of the arc */
  4837. startPoint: Vector2;
  4838. /** Defines the mid point of the arc */
  4839. midPoint: Vector2;
  4840. /** Defines the end point of the arc */
  4841. endPoint: Vector2;
  4842. /**
  4843. * Defines the center point of the arc.
  4844. */
  4845. centerPoint: Vector2;
  4846. /**
  4847. * Defines the radius of the arc.
  4848. */
  4849. radius: number;
  4850. /**
  4851. * Defines the angle of the arc (from mid point to end point).
  4852. */
  4853. angle: Angle;
  4854. /**
  4855. * Defines the start angle of the arc (from start point to middle point).
  4856. */
  4857. startAngle: Angle;
  4858. /**
  4859. * Defines the orientation of the arc (clock wise/counter clock wise).
  4860. */
  4861. orientation: Orientation;
  4862. /**
  4863. * Creates an Arc object from the three given points : start, middle and end.
  4864. * @param startPoint Defines the start point of the arc
  4865. * @param midPoint Defines the midlle point of the arc
  4866. * @param endPoint Defines the end point of the arc
  4867. */
  4868. constructor(
  4869. /** Defines the start point of the arc */
  4870. startPoint: Vector2,
  4871. /** Defines the mid point of the arc */
  4872. midPoint: Vector2,
  4873. /** Defines the end point of the arc */
  4874. endPoint: Vector2);
  4875. }
  4876. /**
  4877. * Represents a 2D path made up of multiple 2D points
  4878. */
  4879. export class Path2 {
  4880. private _points;
  4881. private _length;
  4882. /**
  4883. * If the path start and end point are the same
  4884. */
  4885. closed: boolean;
  4886. /**
  4887. * Creates a Path2 object from the starting 2D coordinates x and y.
  4888. * @param x the starting points x value
  4889. * @param y the starting points y value
  4890. */
  4891. constructor(x: number, y: number);
  4892. /**
  4893. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4894. * @param x the added points x value
  4895. * @param y the added points y value
  4896. * @returns the updated Path2.
  4897. */
  4898. addLineTo(x: number, y: number): Path2;
  4899. /**
  4900. * 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.
  4901. * @param midX middle point x value
  4902. * @param midY middle point y value
  4903. * @param endX end point x value
  4904. * @param endY end point y value
  4905. * @param numberOfSegments (default: 36)
  4906. * @returns the updated Path2.
  4907. */
  4908. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4909. /**
  4910. * Closes the Path2.
  4911. * @returns the Path2.
  4912. */
  4913. close(): Path2;
  4914. /**
  4915. * Gets the sum of the distance between each sequential point in the path
  4916. * @returns the Path2 total length (float).
  4917. */
  4918. length(): number;
  4919. /**
  4920. * Gets the points which construct the path
  4921. * @returns the Path2 internal array of points.
  4922. */
  4923. getPoints(): Vector2[];
  4924. /**
  4925. * Retreives the point at the distance aways from the starting point
  4926. * @param normalizedLengthPosition the length along the path to retreive the point from
  4927. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4928. */
  4929. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4930. /**
  4931. * Creates a new path starting from an x and y position
  4932. * @param x starting x value
  4933. * @param y starting y value
  4934. * @returns a new Path2 starting at the coordinates (x, y).
  4935. */
  4936. static StartingAt(x: number, y: number): Path2;
  4937. }
  4938. /**
  4939. * Represents a 3D path made up of multiple 3D points
  4940. */
  4941. export class Path3D {
  4942. /**
  4943. * an array of Vector3, the curve axis of the Path3D
  4944. */
  4945. path: Vector3[];
  4946. private _curve;
  4947. private _distances;
  4948. private _tangents;
  4949. private _normals;
  4950. private _binormals;
  4951. private _raw;
  4952. private _alignTangentsWithPath;
  4953. private readonly _pointAtData;
  4954. /**
  4955. * new Path3D(path, normal, raw)
  4956. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4957. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4958. * @param path an array of Vector3, the curve axis of the Path3D
  4959. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4960. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4961. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4962. */
  4963. constructor(
  4964. /**
  4965. * an array of Vector3, the curve axis of the Path3D
  4966. */
  4967. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4968. /**
  4969. * Returns the Path3D array of successive Vector3 designing its curve.
  4970. * @returns the Path3D array of successive Vector3 designing its curve.
  4971. */
  4972. getCurve(): Vector3[];
  4973. /**
  4974. * Returns the Path3D array of successive Vector3 designing its curve.
  4975. * @returns the Path3D array of successive Vector3 designing its curve.
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the path.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns an array populated with tangent vectors on each Path3D curve point.
  4984. * @returns an array populated with tangent vectors on each Path3D curve point.
  4985. */
  4986. getTangents(): Vector3[];
  4987. /**
  4988. * Returns an array populated with normal vectors on each Path3D curve point.
  4989. * @returns an array populated with normal vectors on each Path3D curve point.
  4990. */
  4991. getNormals(): Vector3[];
  4992. /**
  4993. * Returns an array populated with binormal vectors on each Path3D curve point.
  4994. * @returns an array populated with binormal vectors on each Path3D curve point.
  4995. */
  4996. getBinormals(): Vector3[];
  4997. /**
  4998. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4999. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5000. */
  5001. getDistances(): number[];
  5002. /**
  5003. * Returns an interpolated point along this path
  5004. * @param position the position of the point along this path, from 0.0 to 1.0
  5005. * @returns a new Vector3 as the point
  5006. */
  5007. getPointAt(position: number): Vector3;
  5008. /**
  5009. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5010. * @param position the position of the point along this path, from 0.0 to 1.0
  5011. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5012. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5013. */
  5014. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5019. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5020. */
  5021. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5026. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5027. */
  5028. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5033. */
  5034. getDistanceAt(position: number): number;
  5035. /**
  5036. * Returns the array index of the previous point of an interpolated point along this path
  5037. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5038. * @returns the array index
  5039. */
  5040. getPreviousPointIndexAt(position: number): number;
  5041. /**
  5042. * 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)
  5043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5044. * @returns the sub position
  5045. */
  5046. getSubPositionAt(position: number): number;
  5047. /**
  5048. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5049. * @param target the vector of which to get the closest position to
  5050. * @returns the position of the closest virtual point on this path to the target vector
  5051. */
  5052. getClosestPositionTo(target: Vector3): number;
  5053. /**
  5054. * Returns a sub path (slice) of this path
  5055. * @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
  5056. * @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
  5057. * @returns a sub path (slice) of this path
  5058. */
  5059. slice(start?: number, end?: number): Path3D;
  5060. /**
  5061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5062. * @param path path which all values are copied into the curves points
  5063. * @param firstNormal which should be projected onto the curve
  5064. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5065. * @returns the same object updated.
  5066. */
  5067. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5068. private _compute;
  5069. private _getFirstNonNullVector;
  5070. private _getLastNonNullVector;
  5071. private _normalVector;
  5072. /**
  5073. * Updates the point at data for an interpolated point along this curve
  5074. * @param position the position of the point along this curve, from 0.0 to 1.0
  5075. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5076. * @returns the (updated) point at data
  5077. */
  5078. private _updatePointAtData;
  5079. /**
  5080. * Updates the point at data from the specified parameters
  5081. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5082. * @param point the interpolated point
  5083. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5084. */
  5085. private _setPointAtData;
  5086. /**
  5087. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5088. */
  5089. private _updateInterpolationMatrix;
  5090. }
  5091. /**
  5092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5093. * A Curve3 is designed from a series of successive Vector3.
  5094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5095. */
  5096. export class Curve3 {
  5097. private _points;
  5098. private _length;
  5099. /**
  5100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5102. * @param v1 (Vector3) the control point
  5103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5104. * @param nbPoints (integer) the wanted number of points in the curve
  5105. * @returns the created Curve3
  5106. */
  5107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5108. /**
  5109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5111. * @param v1 (Vector3) the first control point
  5112. * @param v2 (Vector3) the second control point
  5113. * @param v3 (Vector3) the end point of the Cubic Bezier
  5114. * @param nbPoints (integer) the wanted number of points in the curve
  5115. * @returns the created Curve3
  5116. */
  5117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5118. /**
  5119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5120. * @param p1 (Vector3) the origin point of the Hermite Spline
  5121. * @param t1 (Vector3) the tangent vector at the origin point
  5122. * @param p2 (Vector3) the end point of the Hermite Spline
  5123. * @param t2 (Vector3) the tangent vector at the end point
  5124. * @param nbPoints (integer) the wanted number of points in the curve
  5125. * @returns the created Curve3
  5126. */
  5127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5128. /**
  5129. * Returns a Curve3 object along a CatmullRom Spline curve :
  5130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5131. * @param nbPoints (integer) the wanted number of points between each curve control points
  5132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5140. * @param points points which make up the curve
  5141. */
  5142. constructor(points: Vector3[]);
  5143. /**
  5144. * @returns the Curve3 stored array of successive Vector3
  5145. */
  5146. getPoints(): Vector3[];
  5147. /**
  5148. * @returns the computed length (float) of the curve.
  5149. */
  5150. length(): number;
  5151. /**
  5152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5154. * curveA and curveB keep unchanged.
  5155. * @param curve the curve to continue from this curve
  5156. * @returns the newly constructed curve
  5157. */
  5158. continue(curve: DeepImmutable<Curve3>): Curve3;
  5159. private _computeLength;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * This represents the main contract an easing function should follow.
  5165. * Easing functions are used throughout the animation system.
  5166. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5167. */
  5168. export interface IEasingFunction {
  5169. /**
  5170. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5171. * of the easing function.
  5172. * The link below provides some of the most common examples of easing functions.
  5173. * @see https://easings.net/
  5174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5175. * @returns the corresponding value on the curve defined by the easing function
  5176. */
  5177. ease(gradient: number): number;
  5178. }
  5179. /**
  5180. * Base class used for every default easing function.
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class EasingFunction implements IEasingFunction {
  5184. /**
  5185. * Interpolation follows the mathematical formula associated with the easing function.
  5186. */
  5187. static readonly EASINGMODE_EASEIN: number;
  5188. /**
  5189. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5190. */
  5191. static readonly EASINGMODE_EASEOUT: number;
  5192. /**
  5193. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5194. */
  5195. static readonly EASINGMODE_EASEINOUT: number;
  5196. private _easingMode;
  5197. /**
  5198. * Sets the easing mode of the current function.
  5199. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5200. */
  5201. setEasingMode(easingMode: number): void;
  5202. /**
  5203. * Gets the current easing mode.
  5204. * @returns the easing mode
  5205. */
  5206. getEasingMode(): number;
  5207. /**
  5208. * @hidden
  5209. */
  5210. easeInCore(gradient: number): number;
  5211. /**
  5212. * Given an input gradient between 0 and 1, this returns the corresponding value
  5213. * of the easing function.
  5214. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5215. * @returns the corresponding value on the curve defined by the easing function
  5216. */
  5217. ease(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a circle shape (see link below).
  5221. * @see https://easings.net/#easeInCirc
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class CircleEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a ease back shape (see link below).
  5230. * @see https://easings.net/#easeInBack
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BackEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the amplitude of the function */
  5235. amplitude: number;
  5236. /**
  5237. * Instantiates a back ease easing
  5238. * @see https://easings.net/#easeInBack
  5239. * @param amplitude Defines the amplitude of the function
  5240. */
  5241. constructor(
  5242. /** Defines the amplitude of the function */
  5243. amplitude?: number);
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a bouncing shape (see link below).
  5249. * @see https://easings.net/#easeInBounce
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class BounceEase extends EasingFunction implements IEasingFunction {
  5253. /** Defines the number of bounces */
  5254. bounces: number;
  5255. /** Defines the amplitude of the bounce */
  5256. bounciness: number;
  5257. /**
  5258. * Instantiates a bounce easing
  5259. * @see https://easings.net/#easeInBounce
  5260. * @param bounces Defines the number of bounces
  5261. * @param bounciness Defines the amplitude of the bounce
  5262. */
  5263. constructor(
  5264. /** Defines the number of bounces */
  5265. bounces?: number,
  5266. /** Defines the amplitude of the bounce */
  5267. bounciness?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 3 shape (see link below).
  5273. * @see https://easings.net/#easeInCubic
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class CubicEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with an elastic shape (see link below).
  5282. * @see https://easings.net/#easeInElastic
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the number of oscillations*/
  5287. oscillations: number;
  5288. /** Defines the amplitude of the oscillations*/
  5289. springiness: number;
  5290. /**
  5291. * Instantiates an elastic easing function
  5292. * @see https://easings.net/#easeInElastic
  5293. * @param oscillations Defines the number of oscillations
  5294. * @param springiness Defines the amplitude of the oscillations
  5295. */
  5296. constructor(
  5297. /** Defines the number of oscillations*/
  5298. oscillations?: number,
  5299. /** Defines the amplitude of the oscillations*/
  5300. springiness?: number);
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an exponential shape (see link below).
  5306. * @see https://easings.net/#easeInExpo
  5307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the exponent of the function */
  5311. exponent: number;
  5312. /**
  5313. * Instantiates an exponential easing function
  5314. * @see https://easings.net/#easeInExpo
  5315. * @param exponent Defines the exponent of the function
  5316. */
  5317. constructor(
  5318. /** Defines the exponent of the function */
  5319. exponent?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a power shape (see link below).
  5325. * @see https://easings.net/#easeInQuad
  5326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class PowerEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the power of the function */
  5330. power: number;
  5331. /**
  5332. * Instantiates an power base easing function
  5333. * @see https://easings.net/#easeInQuad
  5334. * @param power Defines the power of the function
  5335. */
  5336. constructor(
  5337. /** Defines the power of the function */
  5338. power?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with a power of 2 shape (see link below).
  5344. * @see https://easings.net/#easeInQuad
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a power of 4 shape (see link below).
  5353. * @see https://easings.net/#easeInQuart
  5354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5357. /** @hidden */
  5358. easeInCore(gradient: number): number;
  5359. }
  5360. /**
  5361. * Easing function with a power of 5 shape (see link below).
  5362. * @see https://easings.net/#easeInQuint
  5363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5364. */
  5365. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a sin shape (see link below).
  5371. * @see https://easings.net/#easeInSine
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class SineEase extends EasingFunction implements IEasingFunction {
  5375. /** @hidden */
  5376. easeInCore(gradient: number): number;
  5377. }
  5378. /**
  5379. * Easing function with a bezier shape (see link below).
  5380. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5382. */
  5383. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5384. /** Defines the x component of the start tangent in the bezier curve */
  5385. x1: number;
  5386. /** Defines the y component of the start tangent in the bezier curve */
  5387. y1: number;
  5388. /** Defines the x component of the end tangent in the bezier curve */
  5389. x2: number;
  5390. /** Defines the y component of the end tangent in the bezier curve */
  5391. y2: number;
  5392. /**
  5393. * Instantiates a bezier function
  5394. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5395. * @param x1 Defines the x component of the start tangent in the bezier curve
  5396. * @param y1 Defines the y component of the start tangent in the bezier curve
  5397. * @param x2 Defines the x component of the end tangent in the bezier curve
  5398. * @param y2 Defines the y component of the end tangent in the bezier curve
  5399. */
  5400. constructor(
  5401. /** Defines the x component of the start tangent in the bezier curve */
  5402. x1?: number,
  5403. /** Defines the y component of the start tangent in the bezier curve */
  5404. y1?: number,
  5405. /** Defines the x component of the end tangent in the bezier curve */
  5406. x2?: number,
  5407. /** Defines the y component of the end tangent in the bezier curve */
  5408. y2?: number);
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. /**
  5415. * Class used to hold a RBG color
  5416. */
  5417. export class Color3 {
  5418. /**
  5419. * Defines the red component (between 0 and 1, default is 0)
  5420. */
  5421. r: number;
  5422. /**
  5423. * Defines the green component (between 0 and 1, default is 0)
  5424. */
  5425. g: number;
  5426. /**
  5427. * Defines the blue component (between 0 and 1, default is 0)
  5428. */
  5429. b: number;
  5430. /**
  5431. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5432. * @param r defines the red component (between 0 and 1, default is 0)
  5433. * @param g defines the green component (between 0 and 1, default is 0)
  5434. * @param b defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. constructor(
  5437. /**
  5438. * Defines the red component (between 0 and 1, default is 0)
  5439. */
  5440. r?: number,
  5441. /**
  5442. * Defines the green component (between 0 and 1, default is 0)
  5443. */
  5444. g?: number,
  5445. /**
  5446. * Defines the blue component (between 0 and 1, default is 0)
  5447. */
  5448. b?: number);
  5449. /**
  5450. * Creates a string with the Color3 current values
  5451. * @returns the string representation of the Color3 object
  5452. */
  5453. toString(): string;
  5454. /**
  5455. * Returns the string "Color3"
  5456. * @returns "Color3"
  5457. */
  5458. getClassName(): string;
  5459. /**
  5460. * Compute the Color3 hash code
  5461. * @returns an unique number that can be used to hash Color3 objects
  5462. */
  5463. getHashCode(): number;
  5464. /**
  5465. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5466. * @param array defines the array where to store the r,g,b components
  5467. * @param index defines an optional index in the target array to define where to start storing values
  5468. * @returns the current Color3 object
  5469. */
  5470. toArray(array: FloatArray, index?: number): Color3;
  5471. /**
  5472. * Returns a new Color4 object from the current Color3 and the given alpha
  5473. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5474. * @returns a new Color4 object
  5475. */
  5476. toColor4(alpha?: number): Color4;
  5477. /**
  5478. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Returns the luminance value
  5484. * @returns a float value
  5485. */
  5486. toLuminance(): number;
  5487. /**
  5488. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5489. * @param otherColor defines the second operand
  5490. * @returns the new Color3 object
  5491. */
  5492. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5495. * @param otherColor defines the second operand
  5496. * @param result defines the Color3 object where to store the result
  5497. * @returns the current Color3
  5498. */
  5499. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5500. /**
  5501. * Determines equality between Color3 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgb values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color3>): boolean;
  5506. /**
  5507. * Determines equality between the current Color3 object and a set of r,b,g values
  5508. * @param r defines the red component to check
  5509. * @param g defines the green component to check
  5510. * @param b defines the blue component to check
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equalsFloats(r: number, g: number, b: number): boolean;
  5514. /**
  5515. * Multiplies in place each rgb value by scale
  5516. * @param scale defines the scaling factor
  5517. * @returns the updated Color3
  5518. */
  5519. scale(scale: number): Color3;
  5520. /**
  5521. * Multiplies the rgb values by scale and stores the result into "result"
  5522. * @param scale defines the scaling factor
  5523. * @param result defines the Color3 object where to store the result
  5524. * @returns the unmodified current Color3
  5525. */
  5526. scaleToRef(scale: number, result: Color3): Color3;
  5527. /**
  5528. * Scale the current Color3 values by a factor and add the result to a given Color3
  5529. * @param scale defines the scale factor
  5530. * @param result defines color to store the result into
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into
  5539. * @returns the original Color3
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5542. /**
  5543. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5544. * @param otherColor defines the second operand
  5545. * @returns the new Color3
  5546. */
  5547. add(otherColor: DeepImmutable<Color3>): Color3;
  5548. /**
  5549. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5550. * @param otherColor defines the second operand
  5551. * @param result defines Color3 object to store the result into
  5552. * @returns the unmodified current Color3
  5553. */
  5554. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5555. /**
  5556. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5557. * @param otherColor defines the second operand
  5558. * @returns the new Color3
  5559. */
  5560. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5561. /**
  5562. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5563. * @param otherColor defines the second operand
  5564. * @param result defines Color3 object to store the result into
  5565. * @returns the unmodified current Color3
  5566. */
  5567. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5568. /**
  5569. * Copy the current object
  5570. * @returns a new Color3 copied the current one
  5571. */
  5572. clone(): Color3;
  5573. /**
  5574. * Copies the rgb values from the source in the current Color3
  5575. * @param source defines the source Color3 object
  5576. * @returns the updated Color3 object
  5577. */
  5578. copyFrom(source: DeepImmutable<Color3>): Color3;
  5579. /**
  5580. * Updates the Color3 rgb values from the given floats
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @returns the current Color3 object
  5585. */
  5586. copyFromFloats(r: number, g: number, b: number): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. set(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Compute the Color3 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color3 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color3 converted from the current one to linear space
  5602. * @returns a new Color3 object
  5603. */
  5604. toLinearSpace(): Color3;
  5605. /**
  5606. * Converts current color in rgb space to HSV values
  5607. * @returns a new color3 representing the HSV values
  5608. */
  5609. toHSV(): Color3;
  5610. /**
  5611. * Converts current color in rgb space to HSV values
  5612. * @param result defines the Color3 where to store the HSV values
  5613. */
  5614. toHSVToRef(result: Color3): void;
  5615. /**
  5616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5617. * @param convertedColor defines the Color3 object where to store the linear space version
  5618. * @returns the unmodified Color3
  5619. */
  5620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5621. /**
  5622. * Computes a new Color3 converted from the current one to gamma space
  5623. * @returns a new Color3 object
  5624. */
  5625. toGammaSpace(): Color3;
  5626. /**
  5627. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5628. * @param convertedColor defines the Color3 object where to store the gamma space version
  5629. * @returns the unmodified Color3
  5630. */
  5631. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5632. private static _BlackReadOnly;
  5633. /**
  5634. * Convert Hue, saturation and value to a Color3 (RGB)
  5635. * @param hue defines the hue
  5636. * @param saturation defines the saturation
  5637. * @param value defines the value
  5638. * @param result defines the Color3 where to store the RGB values
  5639. */
  5640. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5641. /**
  5642. * Creates a new Color3 from the string containing valid hexadecimal values
  5643. * @param hex defines a string containing valid hexadecimal values
  5644. * @returns a new Color3 object
  5645. */
  5646. static FromHexString(hex: string): Color3;
  5647. /**
  5648. * Creates a new Color3 from the starting index of the given array
  5649. * @param array defines the source array
  5650. * @param offset defines an offset in the source array
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5654. /**
  5655. * Creates a new Color3 from integer values (< 256)
  5656. * @param r defines the red component to read from (value between 0 and 255)
  5657. * @param g defines the green component to read from (value between 0 and 255)
  5658. * @param b defines the blue component to read from (value between 0 and 255)
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromInts(r: number, g: number, b: number): Color3;
  5662. /**
  5663. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5664. * @param start defines the start Color3 value
  5665. * @param end defines the end Color3 value
  5666. * @param amount defines the gradient value between start and end
  5667. * @returns a new Color3 object
  5668. */
  5669. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param left defines the start value
  5673. * @param right defines the end value
  5674. * @param amount defines the gradient factor
  5675. * @param result defines the Color3 object where to store the result
  5676. */
  5677. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5678. /**
  5679. * Returns a Color3 value containing a red color
  5680. * @returns a new Color3 object
  5681. */
  5682. static Red(): Color3;
  5683. /**
  5684. * Returns a Color3 value containing a green color
  5685. * @returns a new Color3 object
  5686. */
  5687. static Green(): Color3;
  5688. /**
  5689. * Returns a Color3 value containing a blue color
  5690. * @returns a new Color3 object
  5691. */
  5692. static Blue(): Color3;
  5693. /**
  5694. * Returns a Color3 value containing a black color
  5695. * @returns a new Color3 object
  5696. */
  5697. static Black(): Color3;
  5698. /**
  5699. * Gets a Color3 value containing a black color that must not be updated
  5700. */
  5701. static get BlackReadOnly(): DeepImmutable<Color3>;
  5702. /**
  5703. * Returns a Color3 value containing a white color
  5704. * @returns a new Color3 object
  5705. */
  5706. static White(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a purple color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Purple(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a magenta color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Magenta(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a yellow color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Yellow(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a gray color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Gray(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a teal color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Teal(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a random color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Random(): Color3;
  5737. }
  5738. /**
  5739. * Class used to hold a RBGA color
  5740. */
  5741. export class Color4 {
  5742. /**
  5743. * Defines the red component (between 0 and 1, default is 0)
  5744. */
  5745. r: number;
  5746. /**
  5747. * Defines the green component (between 0 and 1, default is 0)
  5748. */
  5749. g: number;
  5750. /**
  5751. * Defines the blue component (between 0 and 1, default is 0)
  5752. */
  5753. b: number;
  5754. /**
  5755. * Defines the alpha component (between 0 and 1, default is 1)
  5756. */
  5757. a: number;
  5758. /**
  5759. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5760. * @param r defines the red component (between 0 and 1, default is 0)
  5761. * @param g defines the green component (between 0 and 1, default is 0)
  5762. * @param b defines the blue component (between 0 and 1, default is 0)
  5763. * @param a defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. constructor(
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r?: number,
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g?: number,
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b?: number,
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a?: number);
  5782. /**
  5783. * Adds in place the given Color4 values to the current Color4 object
  5784. * @param right defines the second operand
  5785. * @returns the current updated Color4 object
  5786. */
  5787. addInPlace(right: DeepImmutable<Color4>): Color4;
  5788. /**
  5789. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5790. * @returns the new array
  5791. */
  5792. asArray(): number[];
  5793. /**
  5794. * Stores from the starting index in the given array the Color4 successive values
  5795. * @param array defines the array where to store the r,g,b components
  5796. * @param index defines an optional index in the target array to define where to start storing values
  5797. * @returns the current Color4 object
  5798. */
  5799. toArray(array: number[], index?: number): Color4;
  5800. /**
  5801. * Determines equality between Color4 objects
  5802. * @param otherColor defines the second operand
  5803. * @returns true if the rgba values are equal to the given ones
  5804. */
  5805. equals(otherColor: DeepImmutable<Color4>): boolean;
  5806. /**
  5807. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5808. * @param right defines the second operand
  5809. * @returns a new Color4 object
  5810. */
  5811. add(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5814. * @param right defines the second operand
  5815. * @returns a new Color4 object
  5816. */
  5817. subtract(right: DeepImmutable<Color4>): Color4;
  5818. /**
  5819. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5820. * @param right defines the second operand
  5821. * @param result defines the Color4 object where to store the result
  5822. * @returns the current Color4 object
  5823. */
  5824. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5825. /**
  5826. * Creates a new Color4 with the current Color4 values multiplied by scale
  5827. * @param scale defines the scaling factor to apply
  5828. * @returns a new Color4 object
  5829. */
  5830. scale(scale: number): Color4;
  5831. /**
  5832. * Multiplies the current Color4 values by scale and stores the result in "result"
  5833. * @param scale defines the scaling factor to apply
  5834. * @param result defines the Color4 object where to store the result
  5835. * @returns the current unmodified Color4
  5836. */
  5837. scaleToRef(scale: number, result: Color4): Color4;
  5838. /**
  5839. * Scale the current Color4 values by a factor and add the result to a given Color4
  5840. * @param scale defines the scale factor
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the unmodified current Color4
  5843. */
  5844. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Clamps the rgb values by the min and max values and stores the result into "result"
  5847. * @param min defines minimum clamping value (default is 0)
  5848. * @param max defines maximum clamping value (default is 1)
  5849. * @param result defines color to store the result into.
  5850. * @returns the cuurent Color4
  5851. */
  5852. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5853. /**
  5854. * Multipy an Color4 value by another and return a new Color4 object
  5855. * @param color defines the Color4 value to multiply by
  5856. * @returns a new Color4 object
  5857. */
  5858. multiply(color: Color4): Color4;
  5859. /**
  5860. * Multipy a Color4 value by another and push the result in a reference value
  5861. * @param color defines the Color4 value to multiply by
  5862. * @param result defines the Color4 to fill the result in
  5863. * @returns the result Color4
  5864. */
  5865. multiplyToRef(color: Color4, result: Color4): Color4;
  5866. /**
  5867. * Creates a string with the Color4 current values
  5868. * @returns the string representation of the Color4 object
  5869. */
  5870. toString(): string;
  5871. /**
  5872. * Returns the string "Color4"
  5873. * @returns "Color4"
  5874. */
  5875. getClassName(): string;
  5876. /**
  5877. * Compute the Color4 hash code
  5878. * @returns an unique number that can be used to hash Color4 objects
  5879. */
  5880. getHashCode(): number;
  5881. /**
  5882. * Creates a new Color4 copied from the current one
  5883. * @returns a new Color4 object
  5884. */
  5885. clone(): Color4;
  5886. /**
  5887. * Copies the given Color4 values into the current one
  5888. * @param source defines the source Color4 object
  5889. * @returns the current updated Color4 object
  5890. */
  5891. copyFrom(source: Color4): Color4;
  5892. /**
  5893. * Copies the given float values into the current one
  5894. * @param r defines the red component to read from
  5895. * @param g defines the green component to read from
  5896. * @param b defines the blue component to read from
  5897. * @param a defines the alpha component to read from
  5898. * @returns the current updated Color4 object
  5899. */
  5900. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5901. /**
  5902. * Copies the given float values into the current one
  5903. * @param r defines the red component to read from
  5904. * @param g defines the green component to read from
  5905. * @param b defines the blue component to read from
  5906. * @param a defines the alpha component to read from
  5907. * @returns the current updated Color4 object
  5908. */
  5909. set(r: number, g: number, b: number, a: number): Color4;
  5910. /**
  5911. * Compute the Color4 hexadecimal code as a string
  5912. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5913. * @returns a string containing the hexadecimal representation of the Color4 object
  5914. */
  5915. toHexString(returnAsColor3?: boolean): string;
  5916. /**
  5917. * Computes a new Color4 converted from the current one to linear space
  5918. * @returns a new Color4 object
  5919. */
  5920. toLinearSpace(): Color4;
  5921. /**
  5922. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5923. * @param convertedColor defines the Color4 object where to store the linear space version
  5924. * @returns the unmodified Color4
  5925. */
  5926. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5927. /**
  5928. * Computes a new Color4 converted from the current one to gamma space
  5929. * @returns a new Color4 object
  5930. */
  5931. toGammaSpace(): Color4;
  5932. /**
  5933. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5934. * @param convertedColor defines the Color4 object where to store the gamma space version
  5935. * @returns the unmodified Color4
  5936. */
  5937. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 from the string containing valid hexadecimal values
  5940. * @param hex defines a string containing valid hexadecimal values
  5941. * @returns a new Color4 object
  5942. */
  5943. static FromHexString(hex: string): Color4;
  5944. /**
  5945. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5946. * @param left defines the start value
  5947. * @param right defines the end value
  5948. * @param amount defines the gradient factor
  5949. * @returns a new Color4 object
  5950. */
  5951. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5952. /**
  5953. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @param result defines the Color4 object where to store data
  5958. */
  5959. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5960. /**
  5961. * Creates a new Color4 from a Color3 and an alpha value
  5962. * @param color3 defines the source Color3 to read from
  5963. * @param alpha defines the alpha component (1.0 by default)
  5964. * @returns a new Color4 object
  5965. */
  5966. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5967. /**
  5968. * Creates a new Color4 from the starting index element of the given array
  5969. * @param array defines the source array to read from
  5970. * @param offset defines the offset in the source array
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5974. /**
  5975. * Creates a new Color3 from integer values (< 256)
  5976. * @param r defines the red component to read from (value between 0 and 255)
  5977. * @param g defines the green component to read from (value between 0 and 255)
  5978. * @param b defines the blue component to read from (value between 0 and 255)
  5979. * @param a defines the alpha component to read from (value between 0 and 255)
  5980. * @returns a new Color3 object
  5981. */
  5982. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Check the content of a given array and convert it to an array containing RGBA data
  5985. * If the original array was already containing count * 4 values then it is returned directly
  5986. * @param colors defines the array to check
  5987. * @param count defines the number of RGBA data to expect
  5988. * @returns an array containing count * 4 values (RGBA)
  5989. */
  5990. static CheckColors4(colors: number[], count: number): number[];
  5991. }
  5992. /**
  5993. * @hidden
  5994. */
  5995. export class TmpColors {
  5996. static Color3: Color3[];
  5997. static Color4: Color4[];
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * Defines an interface which represents an animation key frame
  6003. */
  6004. export interface IAnimationKey {
  6005. /**
  6006. * Frame of the key frame
  6007. */
  6008. frame: number;
  6009. /**
  6010. * Value at the specifies key frame
  6011. */
  6012. value: any;
  6013. /**
  6014. * The input tangent for the cubic hermite spline
  6015. */
  6016. inTangent?: any;
  6017. /**
  6018. * The output tangent for the cubic hermite spline
  6019. */
  6020. outTangent?: any;
  6021. /**
  6022. * The animation interpolation type
  6023. */
  6024. interpolation?: AnimationKeyInterpolation;
  6025. }
  6026. /**
  6027. * Enum for the animation key frame interpolation type
  6028. */
  6029. export enum AnimationKeyInterpolation {
  6030. /**
  6031. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6032. */
  6033. STEP = 1
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Represents the range of an animation
  6039. */
  6040. export class AnimationRange {
  6041. /**The name of the animation range**/
  6042. name: string;
  6043. /**The starting frame of the animation */
  6044. from: number;
  6045. /**The ending frame of the animation*/
  6046. to: number;
  6047. /**
  6048. * Initializes the range of an animation
  6049. * @param name The name of the animation range
  6050. * @param from The starting frame of the animation
  6051. * @param to The ending frame of the animation
  6052. */
  6053. constructor(
  6054. /**The name of the animation range**/
  6055. name: string,
  6056. /**The starting frame of the animation */
  6057. from: number,
  6058. /**The ending frame of the animation*/
  6059. to: number);
  6060. /**
  6061. * Makes a copy of the animation range
  6062. * @returns A copy of the animation range
  6063. */
  6064. clone(): AnimationRange;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * Composed of a frame, and an action function
  6070. */
  6071. export class AnimationEvent {
  6072. /** The frame for which the event is triggered **/
  6073. frame: number;
  6074. /** The event to perform when triggered **/
  6075. action: (currentFrame: number) => void;
  6076. /** Specifies if the event should be triggered only once**/
  6077. onlyOnce?: boolean | undefined;
  6078. /**
  6079. * Specifies if the animation event is done
  6080. */
  6081. isDone: boolean;
  6082. /**
  6083. * Initializes the animation event
  6084. * @param frame The frame for which the event is triggered
  6085. * @param action The event to perform when triggered
  6086. * @param onlyOnce Specifies if the event should be triggered only once
  6087. */
  6088. constructor(
  6089. /** The frame for which the event is triggered **/
  6090. frame: number,
  6091. /** The event to perform when triggered **/
  6092. action: (currentFrame: number) => void,
  6093. /** Specifies if the event should be triggered only once**/
  6094. onlyOnce?: boolean | undefined);
  6095. /** @hidden */
  6096. _clone(): AnimationEvent;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Interface used to define a behavior
  6102. */
  6103. export interface Behavior<T> {
  6104. /** gets or sets behavior's name */
  6105. name: string;
  6106. /**
  6107. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6108. */
  6109. init(): void;
  6110. /**
  6111. * Called when the behavior is attached to a target
  6112. * @param target defines the target where the behavior is attached to
  6113. */
  6114. attach(target: T): void;
  6115. /**
  6116. * Called when the behavior is detached from its target
  6117. */
  6118. detach(): void;
  6119. }
  6120. /**
  6121. * Interface implemented by classes supporting behaviors
  6122. */
  6123. export interface IBehaviorAware<T> {
  6124. /**
  6125. * Attach a behavior
  6126. * @param behavior defines the behavior to attach
  6127. * @returns the current host
  6128. */
  6129. addBehavior(behavior: Behavior<T>): T;
  6130. /**
  6131. * Remove a behavior from the current object
  6132. * @param behavior defines the behavior to detach
  6133. * @returns the current host
  6134. */
  6135. removeBehavior(behavior: Behavior<T>): T;
  6136. /**
  6137. * Gets a behavior using its name to search
  6138. * @param name defines the name to search
  6139. * @returns the behavior or null if not found
  6140. */
  6141. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * Defines an array and its length.
  6147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6148. */
  6149. export interface ISmartArrayLike<T> {
  6150. /**
  6151. * The data of the array.
  6152. */
  6153. data: Array<T>;
  6154. /**
  6155. * The active length of the array.
  6156. */
  6157. length: number;
  6158. }
  6159. /**
  6160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6161. */
  6162. export class SmartArray<T> implements ISmartArrayLike<T> {
  6163. /**
  6164. * The full set of data from the array.
  6165. */
  6166. data: Array<T>;
  6167. /**
  6168. * The active length of the array.
  6169. */
  6170. length: number;
  6171. protected _id: number;
  6172. /**
  6173. * Instantiates a Smart Array.
  6174. * @param capacity defines the default capacity of the array.
  6175. */
  6176. constructor(capacity: number);
  6177. /**
  6178. * Pushes a value at the end of the active data.
  6179. * @param value defines the object to push in the array.
  6180. */
  6181. push(value: T): void;
  6182. /**
  6183. * Iterates over the active data and apply the lambda to them.
  6184. * @param func defines the action to apply on each value.
  6185. */
  6186. forEach(func: (content: T) => void): void;
  6187. /**
  6188. * Sorts the full sets of data.
  6189. * @param compareFn defines the comparison function to apply.
  6190. */
  6191. sort(compareFn: (a: T, b: T) => number): void;
  6192. /**
  6193. * Resets the active data to an empty array.
  6194. */
  6195. reset(): void;
  6196. /**
  6197. * Releases all the data from the array as well as the array.
  6198. */
  6199. dispose(): void;
  6200. /**
  6201. * Concats the active data with a given array.
  6202. * @param array defines the data to concatenate with.
  6203. */
  6204. concat(array: any): void;
  6205. /**
  6206. * Returns the position of a value in the active data.
  6207. * @param value defines the value to find the index for
  6208. * @returns the index if found in the active data otherwise -1
  6209. */
  6210. indexOf(value: T): number;
  6211. /**
  6212. * Returns whether an element is part of the active data.
  6213. * @param value defines the value to look for
  6214. * @returns true if found in the active data otherwise false
  6215. */
  6216. contains(value: T): boolean;
  6217. private static _GlobalId;
  6218. }
  6219. /**
  6220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6221. * The data in this array can only be present once
  6222. */
  6223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6224. private _duplicateId;
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6228. * @param value defines the object to push in the array.
  6229. */
  6230. push(value: T): void;
  6231. /**
  6232. * Pushes a value at the end of the active data.
  6233. * If the data is already present, it won t be added again
  6234. * @param value defines the object to push in the array.
  6235. * @returns true if added false if it was already present
  6236. */
  6237. pushNoDuplicate(value: T): boolean;
  6238. /**
  6239. * Resets the active data to an empty array.
  6240. */
  6241. reset(): void;
  6242. /**
  6243. * Concats the active data with a given array.
  6244. * This ensures no dupplicate will be present in the result.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concatWithNoDuplicate(array: any): void;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * @ignore
  6253. * This is a list of all the different input types that are available in the application.
  6254. * Fo instance: ArcRotateCameraGamepadInput...
  6255. */
  6256. export var CameraInputTypes: {};
  6257. /**
  6258. * This is the contract to implement in order to create a new input class.
  6259. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6260. */
  6261. export interface ICameraInput<TCamera extends Camera> {
  6262. /**
  6263. * Defines the camera the input is attached to.
  6264. */
  6265. camera: Nullable<TCamera>;
  6266. /**
  6267. * Gets the class name of the current intput.
  6268. * @returns the class name
  6269. */
  6270. getClassName(): string;
  6271. /**
  6272. * Get the friendly name associated with the input class.
  6273. * @returns the input friendly name
  6274. */
  6275. getSimpleName(): string;
  6276. /**
  6277. * Attach the input controls to a specific dom element to get the input from.
  6278. * @param element Defines the element the controls should be listened from
  6279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6280. */
  6281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6282. /**
  6283. * Detach the current controls from the specified dom element.
  6284. * @param element Defines the element to stop listening the inputs from
  6285. */
  6286. detachControl(element: Nullable<HTMLElement>): void;
  6287. /**
  6288. * Update the current camera state depending on the inputs that have been used this frame.
  6289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6290. */
  6291. checkInputs?: () => void;
  6292. }
  6293. /**
  6294. * Represents a map of input types to input instance or input index to input instance.
  6295. */
  6296. export interface CameraInputsMap<TCamera extends Camera> {
  6297. /**
  6298. * Accessor to the input by input type.
  6299. */
  6300. [name: string]: ICameraInput<TCamera>;
  6301. /**
  6302. * Accessor to the input by input index.
  6303. */
  6304. [idx: number]: ICameraInput<TCamera>;
  6305. }
  6306. /**
  6307. * This represents the input manager used within a camera.
  6308. * It helps dealing with all the different kind of input attached to a camera.
  6309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6310. */
  6311. export class CameraInputsManager<TCamera extends Camera> {
  6312. /**
  6313. * Defines the list of inputs attahed to the camera.
  6314. */
  6315. attached: CameraInputsMap<TCamera>;
  6316. /**
  6317. * Defines the dom element the camera is collecting inputs from.
  6318. * This is null if the controls have not been attached.
  6319. */
  6320. attachedElement: Nullable<HTMLElement>;
  6321. /**
  6322. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. noPreventDefault: boolean;
  6325. /**
  6326. * Defined the camera the input manager belongs to.
  6327. */
  6328. camera: TCamera;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs: () => void;
  6334. /**
  6335. * Instantiate a new Camera Input Manager.
  6336. * @param camera Defines the camera the input manager blongs to
  6337. */
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. /**
  6352. * Remove a specific input type from a camera
  6353. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6354. * @param inputType the type of the input to remove
  6355. */
  6356. removeByType(inputType: string): void;
  6357. private _addCheckInputs;
  6358. /**
  6359. * Attach the input controls to the currently attached dom element to listen the events from.
  6360. * @param input Defines the input to attach
  6361. */
  6362. attachInput(input: ICameraInput<TCamera>): void;
  6363. /**
  6364. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6365. * @param element Defines the dom element to collect the events from
  6366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6367. */
  6368. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6369. /**
  6370. * Detach the current manager inputs controls from a specific dom element.
  6371. * @param element Defines the dom element to collect the events from
  6372. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6373. */
  6374. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6375. /**
  6376. * Rebuild the dynamic inputCheck function from the current list of
  6377. * defined inputs in the manager.
  6378. */
  6379. rebuildInputCheck(): void;
  6380. /**
  6381. * Remove all attached input methods from a camera
  6382. */
  6383. clear(): void;
  6384. /**
  6385. * Serialize the current input manager attached to a camera.
  6386. * This ensures than once parsed,
  6387. * the input associated to the camera will be identical to the current ones
  6388. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6389. */
  6390. serialize(serializedCamera: any): void;
  6391. /**
  6392. * Parses an input manager serialized JSON to restore the previous list of inputs
  6393. * and states associated to a camera.
  6394. * @param parsedCamera Defines the JSON to parse
  6395. */
  6396. parse(parsedCamera: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * Class used to store data that will be store in GPU memory
  6402. */
  6403. export class Buffer {
  6404. private _engine;
  6405. private _buffer;
  6406. /** @hidden */
  6407. _data: Nullable<DataArray>;
  6408. private _updatable;
  6409. private _instanced;
  6410. private _divisor;
  6411. /**
  6412. * Gets the byte stride.
  6413. */
  6414. readonly byteStride: number;
  6415. /**
  6416. * Constructor
  6417. * @param engine the engine
  6418. * @param data the data to use for this buffer
  6419. * @param updatable whether the data is updatable
  6420. * @param stride the stride (optional)
  6421. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6422. * @param instanced whether the buffer is instanced (optional)
  6423. * @param useBytes set to true if the stride in in bytes (optional)
  6424. * @param divisor sets an optional divisor for instances (1 by default)
  6425. */
  6426. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6427. /**
  6428. * Create a new VertexBuffer based on the current buffer
  6429. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6430. * @param offset defines offset in the buffer (0 by default)
  6431. * @param size defines the size in floats of attributes (position is 3 for instance)
  6432. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6433. * @param instanced defines if the vertex buffer contains indexed data
  6434. * @param useBytes defines if the offset and stride are in bytes *
  6435. * @param divisor sets an optional divisor for instances (1 by default)
  6436. * @returns the new vertex buffer
  6437. */
  6438. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6439. /**
  6440. * Gets a boolean indicating if the Buffer is updatable?
  6441. * @returns true if the buffer is updatable
  6442. */
  6443. isUpdatable(): boolean;
  6444. /**
  6445. * Gets current buffer's data
  6446. * @returns a DataArray or null
  6447. */
  6448. getData(): Nullable<DataArray>;
  6449. /**
  6450. * Gets underlying native buffer
  6451. * @returns underlying native buffer
  6452. */
  6453. getBuffer(): Nullable<DataBuffer>;
  6454. /**
  6455. * Gets the stride in float32 units (i.e. byte stride / 4).
  6456. * May not be an integer if the byte stride is not divisible by 4.
  6457. * @returns the stride in float32 units
  6458. * @deprecated Please use byteStride instead.
  6459. */
  6460. getStrideSize(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: Nullable<DataArray>): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /**
  6469. * Update current buffer data
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates the data directly.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param vertexCount the vertex count (optional)
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6481. /**
  6482. * Release all resources
  6483. */
  6484. dispose(): void;
  6485. }
  6486. /**
  6487. * Specialized buffer used to store vertex data
  6488. */
  6489. export class VertexBuffer {
  6490. /** @hidden */
  6491. _buffer: Buffer;
  6492. private _kind;
  6493. private _size;
  6494. private _ownsBuffer;
  6495. private _instanced;
  6496. private _instanceDivisor;
  6497. /**
  6498. * The byte type.
  6499. */
  6500. static readonly BYTE: number;
  6501. /**
  6502. * The unsigned byte type.
  6503. */
  6504. static readonly UNSIGNED_BYTE: number;
  6505. /**
  6506. * The short type.
  6507. */
  6508. static readonly SHORT: number;
  6509. /**
  6510. * The unsigned short type.
  6511. */
  6512. static readonly UNSIGNED_SHORT: number;
  6513. /**
  6514. * The integer type.
  6515. */
  6516. static readonly INT: number;
  6517. /**
  6518. * The unsigned integer type.
  6519. */
  6520. static readonly UNSIGNED_INT: number;
  6521. /**
  6522. * The float type.
  6523. */
  6524. static readonly FLOAT: number;
  6525. /**
  6526. * Gets or sets the instance divisor when in instanced mode
  6527. */
  6528. get instanceDivisor(): number;
  6529. set instanceDivisor(value: number);
  6530. /**
  6531. * Gets the byte stride.
  6532. */
  6533. readonly byteStride: number;
  6534. /**
  6535. * Gets the byte offset.
  6536. */
  6537. readonly byteOffset: number;
  6538. /**
  6539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6540. */
  6541. readonly normalized: boolean;
  6542. /**
  6543. * Gets the data type of each component in the array.
  6544. */
  6545. readonly type: number;
  6546. /**
  6547. * Constructor
  6548. * @param engine the engine
  6549. * @param data the data to use for this vertex buffer
  6550. * @param kind the vertex buffer kind
  6551. * @param updatable whether the data is updatable
  6552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6553. * @param stride the stride (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param offset the offset of the data (optional)
  6556. * @param size the number of components (optional)
  6557. * @param type the type of the component (optional)
  6558. * @param normalized whether the data contains normalized data (optional)
  6559. * @param useBytes set to true if stride and offset are in bytes (optional)
  6560. * @param divisor defines the instance divisor to use (1 by default)
  6561. */
  6562. 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);
  6563. /** @hidden */
  6564. _rebuild(): void;
  6565. /**
  6566. * Returns the kind of the VertexBuffer (string)
  6567. * @returns a string
  6568. */
  6569. getKind(): string;
  6570. /**
  6571. * Gets a boolean indicating if the VertexBuffer is updatable?
  6572. * @returns true if the buffer is updatable
  6573. */
  6574. isUpdatable(): boolean;
  6575. /**
  6576. * Gets current buffer's data
  6577. * @returns a DataArray or null
  6578. */
  6579. getData(): Nullable<DataArray>;
  6580. /**
  6581. * Gets underlying native buffer
  6582. * @returns underlying native buffer
  6583. */
  6584. getBuffer(): Nullable<DataBuffer>;
  6585. /**
  6586. * Gets the stride in float32 units (i.e. byte stride / 4).
  6587. * May not be an integer if the byte stride is not divisible by 4.
  6588. * @returns the stride in float32 units
  6589. * @deprecated Please use byteStride instead.
  6590. */
  6591. getStrideSize(): number;
  6592. /**
  6593. * Returns the offset as a multiple of the type byte length.
  6594. * @returns the offset in bytes
  6595. * @deprecated Please use byteOffset instead.
  6596. */
  6597. getOffset(): number;
  6598. /**
  6599. * Returns the number of components per vertex attribute (integer)
  6600. * @returns the size in float
  6601. */
  6602. getSize(): number;
  6603. /**
  6604. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6605. * @returns true if this buffer is instanced
  6606. */
  6607. getIsInstanced(): boolean;
  6608. /**
  6609. * Returns the instancing divisor, zero for non-instanced (integer).
  6610. * @returns a number
  6611. */
  6612. getInstanceDivisor(): number;
  6613. /**
  6614. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6615. * @param data defines the data to store
  6616. */
  6617. create(data?: DataArray): void;
  6618. /**
  6619. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6620. * This function will create a new buffer if the current one is not updatable
  6621. * @param data defines the data to store
  6622. */
  6623. update(data: DataArray): void;
  6624. /**
  6625. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6626. * Returns the directly updated WebGLBuffer.
  6627. * @param data the new data
  6628. * @param offset the new offset
  6629. * @param useBytes set to true if the offset is in bytes
  6630. */
  6631. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6632. /**
  6633. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6634. */
  6635. dispose(): void;
  6636. /**
  6637. * Enumerates each value of this vertex buffer as numbers.
  6638. * @param count the number of values to enumerate
  6639. * @param callback the callback function called for each value
  6640. */
  6641. forEach(count: number, callback: (value: number, index: number) => void): void;
  6642. /**
  6643. * Positions
  6644. */
  6645. static readonly PositionKind: string;
  6646. /**
  6647. * Normals
  6648. */
  6649. static readonly NormalKind: string;
  6650. /**
  6651. * Tangents
  6652. */
  6653. static readonly TangentKind: string;
  6654. /**
  6655. * Texture coordinates
  6656. */
  6657. static readonly UVKind: string;
  6658. /**
  6659. * Texture coordinates 2
  6660. */
  6661. static readonly UV2Kind: string;
  6662. /**
  6663. * Texture coordinates 3
  6664. */
  6665. static readonly UV3Kind: string;
  6666. /**
  6667. * Texture coordinates 4
  6668. */
  6669. static readonly UV4Kind: string;
  6670. /**
  6671. * Texture coordinates 5
  6672. */
  6673. static readonly UV5Kind: string;
  6674. /**
  6675. * Texture coordinates 6
  6676. */
  6677. static readonly UV6Kind: string;
  6678. /**
  6679. * Colors
  6680. */
  6681. static readonly ColorKind: string;
  6682. /**
  6683. * Matrix indices (for bones)
  6684. */
  6685. static readonly MatricesIndicesKind: string;
  6686. /**
  6687. * Matrix weights (for bones)
  6688. */
  6689. static readonly MatricesWeightsKind: string;
  6690. /**
  6691. * Additional matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesExtraKind: string;
  6694. /**
  6695. * Additional matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsExtraKind: string;
  6698. /**
  6699. * Deduces the stride given a kind.
  6700. * @param kind The kind string to deduce
  6701. * @returns The deduced stride
  6702. */
  6703. static DeduceStride(kind: string): number;
  6704. /**
  6705. * Gets the byte length of the given type.
  6706. * @param type the type
  6707. * @returns the number of bytes
  6708. */
  6709. static GetTypeByteLength(type: number): number;
  6710. /**
  6711. * Enumerates each value of the given parameters as numbers.
  6712. * @param data the data to enumerate
  6713. * @param byteOffset the byte offset of the data
  6714. * @param byteStride the byte stride of the data
  6715. * @param componentCount the number of components per element
  6716. * @param componentType the type of the component
  6717. * @param count the number of values to enumerate
  6718. * @param normalized whether the data is normalized
  6719. * @param callback the callback function called for each value
  6720. */
  6721. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6722. private static _GetFloatValue;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. /**
  6727. * @hidden
  6728. */
  6729. export class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * Class used to store bounding sphere information
  6741. */
  6742. export class BoundingSphere {
  6743. /**
  6744. * Gets the center of the bounding sphere in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Radius of the bounding sphere in local space
  6749. */
  6750. radius: number;
  6751. /**
  6752. * Gets the center of the bounding sphere in world space
  6753. */
  6754. readonly centerWorld: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in world space
  6757. */
  6758. radiusWorld: number;
  6759. /**
  6760. * Gets the minimum vector in local space
  6761. */
  6762. readonly minimum: Vector3;
  6763. /**
  6764. * Gets the maximum vector in local space
  6765. */
  6766. readonly maximum: Vector3;
  6767. private _worldMatrix;
  6768. private static readonly TmpVector3;
  6769. /**
  6770. * Creates a new bounding sphere
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding sphere by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingSphere;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */
  6795. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6796. /**
  6797. * Tests if the bounding sphere is intersecting the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an intersection
  6800. */
  6801. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if the bounding sphere center is in between the frustum planes.
  6804. * Used for optimistic fast inclusion.
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if the sphere center is in between the frustum planes
  6807. */
  6808. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if a point is inside the bounding sphere
  6811. * @param point defines the point to test
  6812. * @returns true if the point is inside the bounding sphere
  6813. */
  6814. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6815. /**
  6816. * Checks if two sphere intersct
  6817. * @param sphere0 sphere 0
  6818. * @param sphere1 sphere 1
  6819. * @returns true if the speres intersect
  6820. */
  6821. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6822. }
  6823. }
  6824. declare module BABYLON {
  6825. /**
  6826. * Class used to store bounding box information
  6827. */
  6828. export class BoundingBox implements ICullable {
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in local space
  6831. */
  6832. readonly vectors: Vector3[];
  6833. /**
  6834. * Gets the center of the bounding box in local space
  6835. */
  6836. readonly center: Vector3;
  6837. /**
  6838. * Gets the center of the bounding box in world space
  6839. */
  6840. readonly centerWorld: Vector3;
  6841. /**
  6842. * Gets the extend size in local space
  6843. */
  6844. readonly extendSize: Vector3;
  6845. /**
  6846. * Gets the extend size in world space
  6847. */
  6848. readonly extendSizeWorld: Vector3;
  6849. /**
  6850. * Gets the OBB (object bounding box) directions
  6851. */
  6852. readonly directions: Vector3[];
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in world space
  6855. */
  6856. readonly vectorsWorld: Vector3[];
  6857. /**
  6858. * Gets the minimum vector in world space
  6859. */
  6860. readonly minimumWorld: Vector3;
  6861. /**
  6862. * Gets the maximum vector in world space
  6863. */
  6864. readonly maximumWorld: Vector3;
  6865. /**
  6866. * Gets the minimum vector in local space
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * Gets the maximum vector in local space
  6871. */
  6872. readonly maximum: Vector3;
  6873. private _worldMatrix;
  6874. private static readonly TmpVector3;
  6875. /**
  6876. * @hidden
  6877. */
  6878. _tag: number;
  6879. /**
  6880. * Creates a new bounding box
  6881. * @param min defines the minimum vector (in local space)
  6882. * @param max defines the maximum vector (in local space)
  6883. * @param worldMatrix defines the new world matrix
  6884. */
  6885. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6886. /**
  6887. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6888. * @param min defines the new minimum vector (in local space)
  6889. * @param max defines the new maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6893. /**
  6894. * Scale the current bounding box by applying a scale factor
  6895. * @param factor defines the scale factor to apply
  6896. * @returns the current bounding box
  6897. */
  6898. scale(factor: number): BoundingBox;
  6899. /**
  6900. * Gets the world matrix of the bounding box
  6901. * @returns a matrix
  6902. */
  6903. getWorldMatrix(): DeepImmutable<Matrix>;
  6904. /** @hidden */
  6905. _update(world: DeepImmutable<Matrix>): void;
  6906. /**
  6907. * Tests if the bounding box is intersecting the frustum planes
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. /**
  6913. * Tests if the bounding box is entirely inside the frustum planes
  6914. * @param frustumPlanes defines the frustum planes to test
  6915. * @returns true if there is an inclusion
  6916. */
  6917. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6918. /**
  6919. * Tests if a point is inside the bounding box
  6920. * @param point defines the point to test
  6921. * @returns true if the point is inside the bounding box
  6922. */
  6923. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6924. /**
  6925. * Tests if the bounding box intersects with a bounding sphere
  6926. * @param sphere defines the sphere to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6930. /**
  6931. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6932. * @param min defines the min vector to use
  6933. * @param max defines the max vector to use
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6937. /**
  6938. * Tests if two bounding boxes are intersections
  6939. * @param box0 defines the first box to test
  6940. * @param box1 defines the second box to test
  6941. * @returns true if there is an intersection
  6942. */
  6943. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6944. /**
  6945. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6946. * @param minPoint defines the minimum vector of the bounding box
  6947. * @param maxPoint defines the maximum vector of the bounding box
  6948. * @param sphereCenter defines the sphere center
  6949. * @param sphereRadius defines the sphere radius
  6950. * @returns true if there is an intersection
  6951. */
  6952. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6953. /**
  6954. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @return true if there is an inclusion
  6958. */
  6959. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an intersection
  6965. */
  6966. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /** @hidden */
  6971. export class Collider {
  6972. /** Define if a collision was found */
  6973. collisionFound: boolean;
  6974. /**
  6975. * Define last intersection point in local space
  6976. */
  6977. intersectionPoint: Vector3;
  6978. /**
  6979. * Define last collided mesh
  6980. */
  6981. collidedMesh: Nullable<AbstractMesh>;
  6982. private _collisionPoint;
  6983. private _planeIntersectionPoint;
  6984. private _tempVector;
  6985. private _tempVector2;
  6986. private _tempVector3;
  6987. private _tempVector4;
  6988. private _edge;
  6989. private _baseToVertex;
  6990. private _destinationPoint;
  6991. private _slidePlaneNormal;
  6992. private _displacementVector;
  6993. /** @hidden */
  6994. _radius: Vector3;
  6995. /** @hidden */
  6996. _retry: number;
  6997. private _velocity;
  6998. private _basePoint;
  6999. private _epsilon;
  7000. /** @hidden */
  7001. _velocityWorldLength: number;
  7002. /** @hidden */
  7003. _basePointWorld: Vector3;
  7004. private _velocityWorld;
  7005. private _normalizedVelocity;
  7006. /** @hidden */
  7007. _initialVelocity: Vector3;
  7008. /** @hidden */
  7009. _initialPosition: Vector3;
  7010. private _nearestDistance;
  7011. private _collisionMask;
  7012. get collisionMask(): number;
  7013. set collisionMask(mask: number);
  7014. /**
  7015. * Gets the plane normal used to compute the sliding response (in local space)
  7016. */
  7017. get slidePlaneNormal(): Vector3;
  7018. /** @hidden */
  7019. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7020. /** @hidden */
  7021. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7022. /** @hidden */
  7023. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7024. /** @hidden */
  7025. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7026. /** @hidden */
  7027. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _getResponse(pos: Vector3, vel: Vector3): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. /**
  7034. * Interface for cullable objects
  7035. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7036. */
  7037. export interface ICullable {
  7038. /**
  7039. * Checks if the object or part of the object is in the frustum
  7040. * @param frustumPlanes Camera near/planes
  7041. * @returns true if the object is in frustum otherwise false
  7042. */
  7043. isInFrustum(frustumPlanes: Plane[]): boolean;
  7044. /**
  7045. * Checks if a cullable object (mesh...) is in the camera frustum
  7046. * Unlike isInFrustum this cheks the full bounding box
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7051. }
  7052. /**
  7053. * Info for a bounding data of a mesh
  7054. */
  7055. export class BoundingInfo implements ICullable {
  7056. /**
  7057. * Bounding box for the mesh
  7058. */
  7059. readonly boundingBox: BoundingBox;
  7060. /**
  7061. * Bounding sphere for the mesh
  7062. */
  7063. readonly boundingSphere: BoundingSphere;
  7064. private _isLocked;
  7065. private static readonly TmpVector3;
  7066. /**
  7067. * Constructs bounding info
  7068. * @param minimum min vector of the bounding box/sphere
  7069. * @param maximum max vector of the bounding box/sphere
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * min vector of the bounding box/sphere
  7082. */
  7083. get minimum(): Vector3;
  7084. /**
  7085. * max vector of the bounding box/sphere
  7086. */
  7087. get maximum(): Vector3;
  7088. /**
  7089. * If the info is locked and won't be updated to avoid perf overhead
  7090. */
  7091. get isLocked(): boolean;
  7092. set isLocked(value: boolean);
  7093. /**
  7094. * Updates the bounding sphere and box
  7095. * @param world world matrix to be used to update
  7096. */
  7097. update(world: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7100. * @param center New center of the bounding info
  7101. * @param extend New extend of the bounding info
  7102. * @returns the current bounding info
  7103. */
  7104. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7105. /**
  7106. * Scale the current bounding info by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding info
  7109. */
  7110. scale(factor: number): BoundingInfo;
  7111. /**
  7112. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7113. * @param frustumPlanes defines the frustum to test
  7114. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7115. * @returns true if the bounding info is in the frustum planes
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7118. /**
  7119. * Gets the world distance between the min and max points of the bounding box
  7120. */
  7121. get diagonalLength(): number;
  7122. /**
  7123. * Checks if a cullable object (mesh...) is in the camera frustum
  7124. * Unlike isInFrustum this cheks the full bounding box
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7129. /** @hidden */
  7130. _checkCollision(collider: Collider): boolean;
  7131. /**
  7132. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7134. * @param point the point to check intersection with
  7135. * @returns if the point intersects
  7136. */
  7137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7138. /**
  7139. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param boundingInfo the bounding info to check intersection with
  7142. * @param precise if the intersection should be done using OBB
  7143. * @returns if the bounding info intersects
  7144. */
  7145. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Extracts minimum and maximum values from a list of indexed positions
  7151. * @param positions defines the positions to use
  7152. * @param indices defines the indices to the positions
  7153. * @param indexStart defines the start index
  7154. * @param indexCount defines the end index
  7155. * @param bias defines bias value to add to the result
  7156. * @return minimum and maximum values
  7157. */
  7158. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7159. minimum: Vector3;
  7160. maximum: Vector3;
  7161. };
  7162. /**
  7163. * Extracts minimum and maximum values from a list of positions
  7164. * @param positions defines the positions to use
  7165. * @param start defines the start index in the positions array
  7166. * @param count defines the number of positions to handle
  7167. * @param bias defines bias value to add to the result
  7168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7169. * @return minimum and maximum values
  7170. */
  7171. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7172. minimum: Vector3;
  7173. maximum: Vector3;
  7174. };
  7175. }
  7176. declare module BABYLON {
  7177. /** @hidden */
  7178. export class WebGLDataBuffer extends DataBuffer {
  7179. private _buffer;
  7180. constructor(resource: WebGLBuffer);
  7181. get underlyingResource(): any;
  7182. }
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLPipelineContext implements IPipelineContext {
  7187. engine: ThinEngine;
  7188. program: Nullable<WebGLProgram>;
  7189. context?: WebGLRenderingContext;
  7190. vertexShader?: WebGLShader;
  7191. fragmentShader?: WebGLShader;
  7192. isParallelCompiled: boolean;
  7193. onCompiled?: () => void;
  7194. transformFeedback?: WebGLTransformFeedback | null;
  7195. vertexCompilationError: Nullable<string>;
  7196. fragmentCompilationError: Nullable<string>;
  7197. programLinkError: Nullable<string>;
  7198. programValidationError: Nullable<string>;
  7199. get isAsync(): boolean;
  7200. get isReady(): boolean;
  7201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7202. _getVertexShaderCode(): string | null;
  7203. _getFragmentShaderCode(): string | null;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. get useUbo(): boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. get isSync(): boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module BABYLON {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module BABYLON {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module BABYLON {
  7626. interface ThinEngine {
  7627. /**
  7628. * Creates a depth stencil cube texture.
  7629. * This is only available in WebGL 2.
  7630. * @param size The size of face edge in the cube texture.
  7631. * @param options The options defining the cube texture.
  7632. * @returns The cube texture
  7633. */
  7634. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /**
  7653. * Creates a cube texture
  7654. * @param rootUrl defines the url where the files to load is located
  7655. * @param scene defines the current scene
  7656. * @param files defines the list of files to load (1 per face)
  7657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /**
  7666. * Creates a cube texture
  7667. * @param rootUrl defines the url where the files to load is located
  7668. * @param scene defines the current scene
  7669. * @param files defines the list of files to load (1 per face)
  7670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /** @hidden */
  7682. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7683. /** @hidden */
  7684. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7687. /** @hidden */
  7688. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /**
  7690. * @hidden
  7691. */
  7692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Class for creating a cube texture
  7698. */
  7699. export class CubeTexture extends BaseTexture {
  7700. private _delayedOnLoad;
  7701. /**
  7702. * Observable triggered once the texture has been loaded.
  7703. */
  7704. onLoadObservable: Observable<CubeTexture>;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. set boundingBoxSize(value: Vector3);
  7723. /**
  7724. * Returns the bounding box size
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. get boundingBoxSize(): Vector3;
  7728. protected _rotationY: number;
  7729. /**
  7730. * Sets texture matrix rotation angle around Y axis in radians.
  7731. */
  7732. set rotationY(value: number);
  7733. /**
  7734. * Gets texture matrix rotation angle around Y axis radians.
  7735. */
  7736. get rotationY(): number;
  7737. /**
  7738. * Are mip maps generated for this texture or not.
  7739. */
  7740. get noMipmap(): boolean;
  7741. private _noMipmap;
  7742. private _files;
  7743. protected _forcedExtension: Nullable<string>;
  7744. private _extensions;
  7745. private _textureMatrix;
  7746. private _format;
  7747. private _createPolynomials;
  7748. /** @hidden */
  7749. _prefiltered: boolean;
  7750. /**
  7751. * Creates a cube texture from an array of image urls
  7752. * @param files defines an array of image urls
  7753. * @param scene defines the hosting scene
  7754. * @param noMipmap specifies if mip maps are not used
  7755. * @returns a cube texture
  7756. */
  7757. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7758. /**
  7759. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7760. * @param url defines the url of the prefiltered texture
  7761. * @param scene defines the scene the texture is attached to
  7762. * @param forcedExtension defines the extension of the file if different from the url
  7763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7764. * @return the prefiltered texture
  7765. */
  7766. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7767. /**
  7768. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7769. * as prefiltered data.
  7770. * @param rootUrl defines the url of the texture or the root name of the six images
  7771. * @param null defines the scene or engine the texture is attached to
  7772. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7773. * @param noMipmap defines if mipmaps should be created or not
  7774. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7775. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7776. * @param onError defines a callback triggered in case of error during load
  7777. * @param format defines the internal format to use for the texture once loaded
  7778. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7779. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7783. * @return the cube texture
  7784. */
  7785. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7786. /**
  7787. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7788. */
  7789. get isPrefiltered(): boolean;
  7790. /**
  7791. * Get the current class name of the texture useful for serialization or dynamic coding.
  7792. * @returns "CubeTexture"
  7793. */
  7794. getClassName(): string;
  7795. /**
  7796. * Update the url (and optional buffer) of this texture if url was null during construction.
  7797. * @param url the url of the texture
  7798. * @param forcedExtension defines the extension to use
  7799. * @param onLoad callback called when the texture is loaded (defaults to null)
  7800. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7801. */
  7802. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7803. /**
  7804. * Delays loading of the cube texture
  7805. * @param forcedExtension defines the extension to use
  7806. */
  7807. delayLoad(forcedExtension?: string): void;
  7808. /**
  7809. * Returns the reflection texture matrix
  7810. * @returns the reflection texture matrix
  7811. */
  7812. getReflectionTextureMatrix(): Matrix;
  7813. /**
  7814. * Sets the reflection texture matrix
  7815. * @param value Reflection texture matrix
  7816. */
  7817. setReflectionTextureMatrix(value: Matrix): void;
  7818. /**
  7819. * Parses text to create a cube texture
  7820. * @param parsedTexture define the serialized text to read from
  7821. * @param scene defines the hosting scene
  7822. * @param rootUrl defines the root url of the cube texture
  7823. * @returns a cube texture
  7824. */
  7825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7826. /**
  7827. * Makes a clone, or deep copy, of the cube texture
  7828. * @returns a new cube texture
  7829. */
  7830. clone(): CubeTexture;
  7831. }
  7832. }
  7833. declare module BABYLON {
  7834. /**
  7835. * Manages the defines for the Material
  7836. */
  7837. export class MaterialDefines {
  7838. /** @hidden */
  7839. protected _keys: string[];
  7840. private _isDirty;
  7841. /** @hidden */
  7842. _renderId: number;
  7843. /** @hidden */
  7844. _areLightsDirty: boolean;
  7845. /** @hidden */
  7846. _areLightsDisposed: boolean;
  7847. /** @hidden */
  7848. _areAttributesDirty: boolean;
  7849. /** @hidden */
  7850. _areTexturesDirty: boolean;
  7851. /** @hidden */
  7852. _areFresnelDirty: boolean;
  7853. /** @hidden */
  7854. _areMiscDirty: boolean;
  7855. /** @hidden */
  7856. _areImageProcessingDirty: boolean;
  7857. /** @hidden */
  7858. _normals: boolean;
  7859. /** @hidden */
  7860. _uvs: boolean;
  7861. /** @hidden */
  7862. _needNormals: boolean;
  7863. /** @hidden */
  7864. _needUVs: boolean;
  7865. [id: string]: any;
  7866. /**
  7867. * Specifies if the material needs to be re-calculated
  7868. */
  7869. get isDirty(): boolean;
  7870. /**
  7871. * Marks the material to indicate that it has been re-calculated
  7872. */
  7873. markAsProcessed(): void;
  7874. /**
  7875. * Marks the material to indicate that it needs to be re-calculated
  7876. */
  7877. markAsUnprocessed(): void;
  7878. /**
  7879. * Marks the material to indicate all of its defines need to be re-calculated
  7880. */
  7881. markAllAsDirty(): void;
  7882. /**
  7883. * Marks the material to indicate that image processing needs to be re-calculated
  7884. */
  7885. markAsImageProcessingDirty(): void;
  7886. /**
  7887. * Marks the material to indicate the lights need to be re-calculated
  7888. * @param disposed Defines whether the light is dirty due to dispose or not
  7889. */
  7890. markAsLightDirty(disposed?: boolean): void;
  7891. /**
  7892. * Marks the attribute state as changed
  7893. */
  7894. markAsAttributesDirty(): void;
  7895. /**
  7896. * Marks the texture state as changed
  7897. */
  7898. markAsTexturesDirty(): void;
  7899. /**
  7900. * Marks the fresnel state as changed
  7901. */
  7902. markAsFresnelDirty(): void;
  7903. /**
  7904. * Marks the misc state as changed
  7905. */
  7906. markAsMiscDirty(): void;
  7907. /**
  7908. * Rebuilds the material defines
  7909. */
  7910. rebuild(): void;
  7911. /**
  7912. * Specifies if two material defines are equal
  7913. * @param other - A material define instance to compare to
  7914. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7915. */
  7916. isEqual(other: MaterialDefines): boolean;
  7917. /**
  7918. * Clones this instance's defines to another instance
  7919. * @param other - material defines to clone values to
  7920. */
  7921. cloneTo(other: MaterialDefines): void;
  7922. /**
  7923. * Resets the material define values
  7924. */
  7925. reset(): void;
  7926. /**
  7927. * Converts the material define values to a string
  7928. * @returns - String of material define information
  7929. */
  7930. toString(): string;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7937. * 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;
  7938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7939. */
  7940. export class ColorCurves {
  7941. private _dirty;
  7942. private _tempColor;
  7943. private _globalCurve;
  7944. private _highlightsCurve;
  7945. private _midtonesCurve;
  7946. private _shadowsCurve;
  7947. private _positiveCurve;
  7948. private _negativeCurve;
  7949. private _globalHue;
  7950. private _globalDensity;
  7951. private _globalSaturation;
  7952. private _globalExposure;
  7953. /**
  7954. * Gets the global Hue value.
  7955. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7956. */
  7957. get globalHue(): number;
  7958. /**
  7959. * Sets the global Hue value.
  7960. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7961. */
  7962. set globalHue(value: number);
  7963. /**
  7964. * Gets the global Density value.
  7965. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get globalDensity(): number;
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set globalDensity(value: number);
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. get globalSaturation(): number;
  7980. /**
  7981. * Sets the global Saturation value.
  7982. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7983. */
  7984. set globalSaturation(value: number);
  7985. /**
  7986. * Gets the global Exposure value.
  7987. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7988. */
  7989. get globalExposure(): number;
  7990. /**
  7991. * Sets the global Exposure value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7993. */
  7994. set globalExposure(value: number);
  7995. private _highlightsHue;
  7996. private _highlightsDensity;
  7997. private _highlightsSaturation;
  7998. private _highlightsExposure;
  7999. /**
  8000. * Gets the highlights Hue value.
  8001. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8002. */
  8003. get highlightsHue(): number;
  8004. /**
  8005. * Sets the highlights Hue value.
  8006. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8007. */
  8008. set highlightsHue(value: number);
  8009. /**
  8010. * Gets the highlights Density value.
  8011. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get highlightsDensity(): number;
  8015. /**
  8016. * Sets the highlights Density value.
  8017. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set highlightsDensity(value: number);
  8021. /**
  8022. * Gets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. get highlightsSaturation(): number;
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8029. */
  8030. set highlightsSaturation(value: number);
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8034. */
  8035. get highlightsExposure(): number;
  8036. /**
  8037. * Sets the highlights Exposure value.
  8038. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8039. */
  8040. set highlightsExposure(value: number);
  8041. private _midtonesHue;
  8042. private _midtonesDensity;
  8043. private _midtonesSaturation;
  8044. private _midtonesExposure;
  8045. /**
  8046. * Gets the midtones Hue value.
  8047. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8048. */
  8049. get midtonesHue(): number;
  8050. /**
  8051. * Sets the midtones Hue value.
  8052. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8053. */
  8054. set midtonesHue(value: number);
  8055. /**
  8056. * Gets the midtones Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get midtonesDensity(): number;
  8061. /**
  8062. * Sets the midtones Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set midtonesDensity(value: number);
  8067. /**
  8068. * Gets the midtones Saturation value.
  8069. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8070. */
  8071. get midtonesSaturation(): number;
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8075. */
  8076. set midtonesSaturation(value: number);
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8080. */
  8081. get midtonesExposure(): number;
  8082. /**
  8083. * Sets the midtones Exposure value.
  8084. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8085. */
  8086. set midtonesExposure(value: number);
  8087. private _shadowsHue;
  8088. private _shadowsDensity;
  8089. private _shadowsSaturation;
  8090. private _shadowsExposure;
  8091. /**
  8092. * Gets the shadows Hue value.
  8093. * 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).
  8094. */
  8095. get shadowsHue(): number;
  8096. /**
  8097. * Sets the shadows Hue value.
  8098. * 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).
  8099. */
  8100. set shadowsHue(value: number);
  8101. /**
  8102. * Gets the shadows Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. get shadowsDensity(): number;
  8107. /**
  8108. * Sets the shadows Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. set shadowsDensity(value: number);
  8113. /**
  8114. * Gets the shadows Saturation value.
  8115. * 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.
  8116. */
  8117. get shadowsSaturation(): number;
  8118. /**
  8119. * Sets the shadows Saturation value.
  8120. * 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.
  8121. */
  8122. set shadowsSaturation(value: number);
  8123. /**
  8124. * Gets the shadows Exposure value.
  8125. * 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.
  8126. */
  8127. get shadowsExposure(): number;
  8128. /**
  8129. * Sets the shadows Exposure value.
  8130. * 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.
  8131. */
  8132. set shadowsExposure(value: number);
  8133. /**
  8134. * Returns the class name
  8135. * @returns The class name
  8136. */
  8137. getClassName(): string;
  8138. /**
  8139. * Binds the color curves to the shader.
  8140. * @param colorCurves The color curve to bind
  8141. * @param effect The effect to bind to
  8142. * @param positiveUniform The positive uniform shader parameter
  8143. * @param neutralUniform The neutral uniform shader parameter
  8144. * @param negativeUniform The negative uniform shader parameter
  8145. */
  8146. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8147. /**
  8148. * Prepare the list of uniforms associated with the ColorCurves effects.
  8149. * @param uniformsList The list of uniforms used in the effect
  8150. */
  8151. static PrepareUniforms(uniformsList: string[]): void;
  8152. /**
  8153. * Returns color grading data based on a hue, density, saturation and exposure value.
  8154. * @param filterHue The hue of the color filter.
  8155. * @param filterDensity The density of the color filter.
  8156. * @param saturation The saturation.
  8157. * @param exposure The exposure.
  8158. * @param result The result data container.
  8159. */
  8160. private getColorGradingDataToRef;
  8161. /**
  8162. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8163. * @param value The input slider value in range [-100,100].
  8164. * @returns Adjusted value.
  8165. */
  8166. private static applyColorGradingSliderNonlinear;
  8167. /**
  8168. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8169. * @param hue The hue (H) input.
  8170. * @param saturation The saturation (S) input.
  8171. * @param brightness The brightness (B) input.
  8172. * @result An RGBA color represented as Vector4.
  8173. */
  8174. private static fromHSBToRef;
  8175. /**
  8176. * Returns a value clamped between min and max
  8177. * @param value The value to clamp
  8178. * @param min The minimum of value
  8179. * @param max The maximum of value
  8180. * @returns The clamped value.
  8181. */
  8182. private static clamp;
  8183. /**
  8184. * Clones the current color curve instance.
  8185. * @return The cloned curves
  8186. */
  8187. clone(): ColorCurves;
  8188. /**
  8189. * Serializes the current color curve instance to a json representation.
  8190. * @return a JSON representation
  8191. */
  8192. serialize(): any;
  8193. /**
  8194. * Parses the color curve from a json representation.
  8195. * @param source the JSON source to parse
  8196. * @return The parsed curves
  8197. */
  8198. static Parse(source: any): ColorCurves;
  8199. }
  8200. }
  8201. declare module BABYLON {
  8202. /**
  8203. * Interface to follow in your material defines to integrate easily the
  8204. * Image proccessing functions.
  8205. * @hidden
  8206. */
  8207. export interface IImageProcessingConfigurationDefines {
  8208. IMAGEPROCESSING: boolean;
  8209. VIGNETTE: boolean;
  8210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8211. VIGNETTEBLENDMODEOPAQUE: boolean;
  8212. TONEMAPPING: boolean;
  8213. TONEMAPPING_ACES: boolean;
  8214. CONTRAST: boolean;
  8215. EXPOSURE: boolean;
  8216. COLORCURVES: boolean;
  8217. COLORGRADING: boolean;
  8218. COLORGRADING3D: boolean;
  8219. SAMPLER3DGREENDEPTH: boolean;
  8220. SAMPLER3DBGRMAP: boolean;
  8221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8222. }
  8223. /**
  8224. * @hidden
  8225. */
  8226. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8227. IMAGEPROCESSING: boolean;
  8228. VIGNETTE: boolean;
  8229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8230. VIGNETTEBLENDMODEOPAQUE: boolean;
  8231. TONEMAPPING: boolean;
  8232. TONEMAPPING_ACES: boolean;
  8233. CONTRAST: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. EXPOSURE: boolean;
  8241. constructor();
  8242. }
  8243. /**
  8244. * This groups together the common properties used for image processing either in direct forward pass
  8245. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8246. * or not.
  8247. */
  8248. export class ImageProcessingConfiguration {
  8249. /**
  8250. * Default tone mapping applied in BabylonJS.
  8251. */
  8252. static readonly TONEMAPPING_STANDARD: number;
  8253. /**
  8254. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8255. * to other engines rendering to increase portability.
  8256. */
  8257. static readonly TONEMAPPING_ACES: number;
  8258. /**
  8259. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8260. */
  8261. colorCurves: Nullable<ColorCurves>;
  8262. private _colorCurvesEnabled;
  8263. /**
  8264. * Gets wether the color curves effect is enabled.
  8265. */
  8266. get colorCurvesEnabled(): boolean;
  8267. /**
  8268. * Sets wether the color curves effect is enabled.
  8269. */
  8270. set colorCurvesEnabled(value: boolean);
  8271. private _colorGradingTexture;
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. get colorGradingTexture(): Nullable<BaseTexture>;
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. set colorGradingTexture(value: Nullable<BaseTexture>);
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. get colorGradingEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color grading effect is enabled.
  8287. */
  8288. set colorGradingEnabled(value: boolean);
  8289. private _colorGradingWithGreenDepth;
  8290. /**
  8291. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8292. */
  8293. get colorGradingWithGreenDepth(): boolean;
  8294. /**
  8295. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8296. */
  8297. set colorGradingWithGreenDepth(value: boolean);
  8298. private _colorGradingBGR;
  8299. /**
  8300. * Gets wether the color grading texture contains BGR values.
  8301. */
  8302. get colorGradingBGR(): boolean;
  8303. /**
  8304. * Sets wether the color grading texture contains BGR values.
  8305. */
  8306. set colorGradingBGR(value: boolean);
  8307. /** @hidden */
  8308. _exposure: number;
  8309. /**
  8310. * Gets the Exposure used in the effect.
  8311. */
  8312. get exposure(): number;
  8313. /**
  8314. * Sets the Exposure used in the effect.
  8315. */
  8316. set exposure(value: number);
  8317. private _toneMappingEnabled;
  8318. /**
  8319. * Gets wether the tone mapping effect is enabled.
  8320. */
  8321. get toneMappingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the tone mapping effect is enabled.
  8324. */
  8325. set toneMappingEnabled(value: boolean);
  8326. private _toneMappingType;
  8327. /**
  8328. * Gets the type of tone mapping effect.
  8329. */
  8330. get toneMappingType(): number;
  8331. /**
  8332. * Sets the type of tone mapping effect used in BabylonJS.
  8333. */
  8334. set toneMappingType(value: number);
  8335. protected _contrast: number;
  8336. /**
  8337. * Gets the contrast used in the effect.
  8338. */
  8339. get contrast(): number;
  8340. /**
  8341. * Sets the contrast used in the effect.
  8342. */
  8343. set contrast(value: number);
  8344. /**
  8345. * Vignette stretch size.
  8346. */
  8347. vignetteStretch: number;
  8348. /**
  8349. * Vignette centre X Offset.
  8350. */
  8351. vignetteCentreX: number;
  8352. /**
  8353. * Vignette centre Y Offset.
  8354. */
  8355. vignetteCentreY: number;
  8356. /**
  8357. * Vignette weight or intensity of the vignette effect.
  8358. */
  8359. vignetteWeight: number;
  8360. /**
  8361. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8362. * if vignetteEnabled is set to true.
  8363. */
  8364. vignetteColor: Color4;
  8365. /**
  8366. * Camera field of view used by the Vignette effect.
  8367. */
  8368. vignetteCameraFov: number;
  8369. private _vignetteBlendMode;
  8370. /**
  8371. * Gets the vignette blend mode allowing different kind of effect.
  8372. */
  8373. get vignetteBlendMode(): number;
  8374. /**
  8375. * Sets the vignette blend mode allowing different kind of effect.
  8376. */
  8377. set vignetteBlendMode(value: number);
  8378. private _vignetteEnabled;
  8379. /**
  8380. * Gets wether the vignette effect is enabled.
  8381. */
  8382. get vignetteEnabled(): boolean;
  8383. /**
  8384. * Sets wether the vignette effect is enabled.
  8385. */
  8386. set vignetteEnabled(value: boolean);
  8387. private _applyByPostProcess;
  8388. /**
  8389. * Gets wether the image processing is applied through a post process or not.
  8390. */
  8391. get applyByPostProcess(): boolean;
  8392. /**
  8393. * Sets wether the image processing is applied through a post process or not.
  8394. */
  8395. set applyByPostProcess(value: boolean);
  8396. private _isEnabled;
  8397. /**
  8398. * Gets wether the image processing is enabled or not.
  8399. */
  8400. get isEnabled(): boolean;
  8401. /**
  8402. * Sets wether the image processing is enabled or not.
  8403. */
  8404. set isEnabled(value: boolean);
  8405. /**
  8406. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8407. */
  8408. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8409. /**
  8410. * Method called each time the image processing information changes requires to recompile the effect.
  8411. */
  8412. protected _updateParameters(): void;
  8413. /**
  8414. * Gets the current class name.
  8415. * @return "ImageProcessingConfiguration"
  8416. */
  8417. getClassName(): string;
  8418. /**
  8419. * Prepare the list of uniforms associated with the Image Processing effects.
  8420. * @param uniforms The list of uniforms used in the effect
  8421. * @param defines the list of defines currently in use
  8422. */
  8423. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8424. /**
  8425. * Prepare the list of samplers associated with the Image Processing effects.
  8426. * @param samplersList The list of uniforms used in the effect
  8427. * @param defines the list of defines currently in use
  8428. */
  8429. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8430. /**
  8431. * Prepare the list of defines associated to the shader.
  8432. * @param defines the list of defines to complete
  8433. * @param forPostProcess Define if we are currently in post process mode or not
  8434. */
  8435. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8436. /**
  8437. * Returns true if all the image processing information are ready.
  8438. * @returns True if ready, otherwise, false
  8439. */
  8440. isReady(): boolean;
  8441. /**
  8442. * Binds the image processing to the shader.
  8443. * @param effect The effect to bind to
  8444. * @param overrideAspectRatio Override the aspect ratio of the effect
  8445. */
  8446. bind(effect: Effect, overrideAspectRatio?: number): void;
  8447. /**
  8448. * Clones the current image processing instance.
  8449. * @return The cloned image processing
  8450. */
  8451. clone(): ImageProcessingConfiguration;
  8452. /**
  8453. * Serializes the current image processing instance to a json representation.
  8454. * @return a JSON representation
  8455. */
  8456. serialize(): any;
  8457. /**
  8458. * Parses the image processing from a json representation.
  8459. * @param source the JSON source to parse
  8460. * @return The parsed image processing
  8461. */
  8462. static Parse(source: any): ImageProcessingConfiguration;
  8463. private static _VIGNETTEMODE_MULTIPLY;
  8464. private static _VIGNETTEMODE_OPAQUE;
  8465. /**
  8466. * Used to apply the vignette as a mix with the pixel color.
  8467. */
  8468. static get VIGNETTEMODE_MULTIPLY(): number;
  8469. /**
  8470. * Used to apply the vignette as a replacement of the pixel color.
  8471. */
  8472. static get VIGNETTEMODE_OPAQUE(): number;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** @hidden */
  8477. export var postprocessVertexShader: {
  8478. name: string;
  8479. shader: string;
  8480. };
  8481. }
  8482. declare module BABYLON {
  8483. interface ThinEngine {
  8484. /**
  8485. * Creates a new render target texture
  8486. * @param size defines the size of the texture
  8487. * @param options defines the options used to create the texture
  8488. * @returns a new render target texture stored in an InternalTexture
  8489. */
  8490. createRenderTargetTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. layers?: number;
  8494. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8495. /**
  8496. * Creates a depth stencil texture.
  8497. * This is only available in WebGL 2 or with the depth texture extension available.
  8498. * @param size The size of face edge in the texture.
  8499. * @param options The options defining the texture.
  8500. * @returns The texture
  8501. */
  8502. createDepthStencilTexture(size: number | {
  8503. width: number;
  8504. height: number;
  8505. layers?: number;
  8506. }, options: DepthTextureCreationOptions): InternalTexture;
  8507. /** @hidden */
  8508. _createDepthStencilTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: DepthTextureCreationOptions): InternalTexture;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /** Defines supported spaces */
  8517. export enum Space {
  8518. /** Local (object) space */
  8519. LOCAL = 0,
  8520. /** World space */
  8521. WORLD = 1,
  8522. /** Bone space */
  8523. BONE = 2
  8524. }
  8525. /** Defines the 3 main axes */
  8526. export class Axis {
  8527. /** X axis */
  8528. static X: Vector3;
  8529. /** Y axis */
  8530. static Y: Vector3;
  8531. /** Z axis */
  8532. static Z: Vector3;
  8533. }
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add constraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8577. * panning
  8578. */
  8579. invertRotation: boolean;
  8580. /**
  8581. * Speed multiplier for inverse camera panning
  8582. */
  8583. inverseRotationSpeed: number;
  8584. /**
  8585. * Define the current target of the camera as an object or a position.
  8586. */
  8587. lockedTarget: any;
  8588. /** @hidden */
  8589. _currentTarget: Vector3;
  8590. /** @hidden */
  8591. _initialFocalDistance: number;
  8592. /** @hidden */
  8593. _viewMatrix: Matrix;
  8594. /** @hidden */
  8595. _camMatrix: Matrix;
  8596. /** @hidden */
  8597. _cameraTransformMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraRotationMatrix: Matrix;
  8600. /** @hidden */
  8601. _referencePoint: Vector3;
  8602. /** @hidden */
  8603. _transformedReferencePoint: Vector3;
  8604. protected _globalCurrentTarget: Vector3;
  8605. protected _globalCurrentUpVector: Vector3;
  8606. /** @hidden */
  8607. _reset: () => void;
  8608. private _defaultUp;
  8609. /**
  8610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8611. * This is the base of the follow, arc rotate cameras and Free camera
  8612. * @see http://doc.babylonjs.com/features/cameras
  8613. * @param name Defines the name of the camera in the scene
  8614. * @param position Defines the start position of the camera in the scene
  8615. * @param scene Defines the scene the camera belongs to
  8616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8617. */
  8618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8619. /**
  8620. * Gets the position in front of the camera at a given distance.
  8621. * @param distance The distance from the camera we want the position to be
  8622. * @returns the position
  8623. */
  8624. getFrontPosition(distance: number): Vector3;
  8625. /** @hidden */
  8626. _getLockedTargetPosition(): Nullable<Vector3>;
  8627. private _storedPosition;
  8628. private _storedRotation;
  8629. private _storedRotationQuaternion;
  8630. /**
  8631. * Store current camera state of the camera (fov, position, rotation, etc..)
  8632. * @returns the camera
  8633. */
  8634. storeState(): Camera;
  8635. /**
  8636. * Restored camera state. You must call storeState() first
  8637. * @returns whether it was successful or not
  8638. * @hidden
  8639. */
  8640. _restoreStateValues(): boolean;
  8641. /** @hidden */
  8642. _initCache(): void;
  8643. /** @hidden */
  8644. _updateCache(ignoreParentClass?: boolean): void;
  8645. /** @hidden */
  8646. _isSynchronizedViewMatrix(): boolean;
  8647. /** @hidden */
  8648. _computeLocalCameraSpeed(): number;
  8649. /**
  8650. * Defines the target the camera should look at.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Gather the list of keyboard event types as constants.
  8695. */
  8696. export class KeyboardEventTypes {
  8697. /**
  8698. * The keydown event is fired when a key becomes active (pressed).
  8699. */
  8700. static readonly KEYDOWN: number;
  8701. /**
  8702. * The keyup event is fired when a key has been released.
  8703. */
  8704. static readonly KEYUP: number;
  8705. }
  8706. /**
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. */
  8709. export class KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Instantiates a new keyboard info.
  8720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8721. * @param type Defines the type of event (KeyboardEventTypes)
  8722. * @param event Defines the related dom event
  8723. */
  8724. constructor(
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number,
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent);
  8733. }
  8734. /**
  8735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8737. */
  8738. export class KeyboardInfoPre extends KeyboardInfo {
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number;
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent;
  8747. /**
  8748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8749. */
  8750. skipOnPointerObservable: boolean;
  8751. /**
  8752. * Instantiates a new keyboard pre info.
  8753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8754. * @param type Defines the type of event (KeyboardEventTypes)
  8755. * @param event Defines the related dom event
  8756. */
  8757. constructor(
  8758. /**
  8759. * Defines the type of event (KeyboardEventTypes)
  8760. */
  8761. type: number,
  8762. /**
  8763. * Defines the related dom event
  8764. */
  8765. event: KeyboardEvent);
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /**
  8770. * Manage the keyboard inputs to control the movement of a free camera.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8774. /**
  8775. * Defines the camera the input is attached to.
  8776. */
  8777. camera: FreeCamera;
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8780. */
  8781. keysUp: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8784. */
  8785. keysUpward: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8788. */
  8789. keysDown: number[];
  8790. /**
  8791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8792. */
  8793. keysDownward: number[];
  8794. /**
  8795. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8796. */
  8797. keysLeft: number[];
  8798. /**
  8799. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8800. */
  8801. keysRight: number[];
  8802. private _keys;
  8803. private _onCanvasBlurObserver;
  8804. private _onKeyboardObserver;
  8805. private _engine;
  8806. private _scene;
  8807. /**
  8808. * Attach the input controls to a specific dom element to get the input from.
  8809. * @param element Defines the element the controls should be listened from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current controls from the specified dom element.
  8815. * @param element Defines the element to stop listening the inputs from
  8816. */
  8817. detachControl(element: Nullable<HTMLElement>): void;
  8818. /**
  8819. * Update the current camera state depending on the inputs that have been used this frame.
  8820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8821. */
  8822. checkInputs(): void;
  8823. /**
  8824. * Gets the class name of the current intput.
  8825. * @returns the class name
  8826. */
  8827. getClassName(): string;
  8828. /** @hidden */
  8829. _onLostFocus(): void;
  8830. /**
  8831. * Get the friendly name associated with the input class.
  8832. * @returns the input friendly name
  8833. */
  8834. getSimpleName(): string;
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Interface describing all the common properties and methods a shadow light needs to implement.
  8840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8841. * as well as binding the different shadow properties to the effects.
  8842. */
  8843. export interface IShadowLight extends Light {
  8844. /**
  8845. * The light id in the scene (used in scene.findLighById for instance)
  8846. */
  8847. id: string;
  8848. /**
  8849. * The position the shdow will be casted from.
  8850. */
  8851. position: Vector3;
  8852. /**
  8853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8854. */
  8855. direction: Vector3;
  8856. /**
  8857. * The transformed position. Position of the light in world space taking parenting in account.
  8858. */
  8859. transformedPosition: Vector3;
  8860. /**
  8861. * The transformed direction. Direction of the light in world space taking parenting in account.
  8862. */
  8863. transformedDirection: Vector3;
  8864. /**
  8865. * The friendly name of the light in the scene.
  8866. */
  8867. name: string;
  8868. /**
  8869. * Defines the shadow projection clipping minimum z value.
  8870. */
  8871. shadowMinZ: number;
  8872. /**
  8873. * Defines the shadow projection clipping maximum z value.
  8874. */
  8875. shadowMaxZ: number;
  8876. /**
  8877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8879. */
  8880. computeTransformedInformation(): boolean;
  8881. /**
  8882. * Gets the scene the light belongs to.
  8883. * @returns The scene
  8884. */
  8885. getScene(): Scene;
  8886. /**
  8887. * Callback defining a custom Projection Matrix Builder.
  8888. * This can be used to override the default projection matrix computation.
  8889. */
  8890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8891. /**
  8892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8893. * @param matrix The materix to updated with the projection information
  8894. * @param viewMatrix The transform matrix of the light
  8895. * @param renderList The list of mesh to render in the map
  8896. * @returns The current light
  8897. */
  8898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8899. /**
  8900. * Gets the current depth scale used in ESM.
  8901. * @returns The scale
  8902. */
  8903. getDepthScale(): number;
  8904. /**
  8905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8906. * @returns true if a cube texture needs to be use
  8907. */
  8908. needCube(): boolean;
  8909. /**
  8910. * Detects if the projection matrix requires to be recomputed this frame.
  8911. * @returns true if it requires to be recomputed otherwise, false.
  8912. */
  8913. needProjectionMatrixCompute(): boolean;
  8914. /**
  8915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8916. */
  8917. forceProjectionMatrixCompute(): void;
  8918. /**
  8919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8922. */
  8923. getShadowDirection(faceIndex?: number): Vector3;
  8924. /**
  8925. * Gets the minZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the min for
  8927. * @returns the depth min z
  8928. */
  8929. getDepthMinZ(activeCamera: Camera): number;
  8930. /**
  8931. * Gets the maxZ used for shadow according to both the scene and the light.
  8932. * @param activeCamera The camera we are returning the max for
  8933. * @returns the depth max z
  8934. */
  8935. getDepthMaxZ(activeCamera: Camera): number;
  8936. }
  8937. /**
  8938. * Base implementation IShadowLight
  8939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8940. */
  8941. export abstract class ShadowLight extends Light implements IShadowLight {
  8942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8943. protected _position: Vector3;
  8944. protected _setPosition(value: Vector3): void;
  8945. /**
  8946. * Sets the position the shadow will be casted from. Also use as the light position for both
  8947. * point and spot lights.
  8948. */
  8949. get position(): Vector3;
  8950. /**
  8951. * Sets the position the shadow will be casted from. Also use as the light position for both
  8952. * point and spot lights.
  8953. */
  8954. set position(value: Vector3);
  8955. protected _direction: Vector3;
  8956. protected _setDirection(value: Vector3): void;
  8957. /**
  8958. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8959. * Also use as the light direction on spot and directional lights.
  8960. */
  8961. get direction(): Vector3;
  8962. /**
  8963. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8964. * Also use as the light direction on spot and directional lights.
  8965. */
  8966. set direction(value: Vector3);
  8967. protected _shadowMinZ: number;
  8968. /**
  8969. * Gets the shadow projection clipping minimum z value.
  8970. */
  8971. get shadowMinZ(): number;
  8972. /**
  8973. * Sets the shadow projection clipping minimum z value.
  8974. */
  8975. set shadowMinZ(value: number);
  8976. protected _shadowMaxZ: number;
  8977. /**
  8978. * Sets the shadow projection clipping maximum z value.
  8979. */
  8980. get shadowMaxZ(): number;
  8981. /**
  8982. * Gets the shadow projection clipping maximum z value.
  8983. */
  8984. set shadowMaxZ(value: number);
  8985. /**
  8986. * Callback defining a custom Projection Matrix Builder.
  8987. * This can be used to override the default projection matrix computation.
  8988. */
  8989. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. private _needProjectionMatrixCompute;
  8999. /**
  9000. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9001. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9002. */
  9003. computeTransformedInformation(): boolean;
  9004. /**
  9005. * Return the depth scale used for the shadow map.
  9006. * @returns the depth scale.
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9011. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9012. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9013. */
  9014. getShadowDirection(faceIndex?: number): Vector3;
  9015. /**
  9016. * Returns the ShadowLight absolute position in the World.
  9017. * @returns the position vector in world space
  9018. */
  9019. getAbsolutePosition(): Vector3;
  9020. /**
  9021. * Sets the ShadowLight direction toward the passed target.
  9022. * @param target The point to target in local space
  9023. * @returns the updated ShadowLight direction
  9024. */
  9025. setDirectionToTarget(target: Vector3): Vector3;
  9026. /**
  9027. * Returns the light rotation in euler definition.
  9028. * @returns the x y z rotation in local space.
  9029. */
  9030. getRotation(): Vector3;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /** @hidden */
  9046. _initCache(): void;
  9047. /** @hidden */
  9048. _isSynchronized(): boolean;
  9049. /**
  9050. * Computes the world matrix of the node
  9051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9052. * @returns the world matrix
  9053. */
  9054. computeWorldMatrix(force?: boolean): Matrix;
  9055. /**
  9056. * Gets the minZ used for shadow according to both the scene and the light.
  9057. * @param activeCamera The camera we are returning the min for
  9058. * @returns the depth min z
  9059. */
  9060. getDepthMinZ(activeCamera: Camera): number;
  9061. /**
  9062. * Gets the maxZ used for shadow according to both the scene and the light.
  9063. * @param activeCamera The camera we are returning the max for
  9064. * @returns the depth max z
  9065. */
  9066. getDepthMaxZ(activeCamera: Camera): number;
  9067. /**
  9068. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9069. * @param matrix The materix to updated with the projection information
  9070. * @param viewMatrix The transform matrix of the light
  9071. * @param renderList The list of mesh to render in the map
  9072. * @returns The current light
  9073. */
  9074. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9075. }
  9076. }
  9077. declare module BABYLON {
  9078. /**
  9079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9081. */
  9082. export class EffectFallbacks implements IEffectFallbacks {
  9083. private _defines;
  9084. private _currentRank;
  9085. private _maxRank;
  9086. private _mesh;
  9087. /**
  9088. * Removes the fallback from the bound mesh.
  9089. */
  9090. unBindMesh(): void;
  9091. /**
  9092. * Adds a fallback on the specified property.
  9093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9094. * @param define The name of the define in the shader
  9095. */
  9096. addFallback(rank: number, define: string): void;
  9097. /**
  9098. * Sets the mesh to use CPU skinning when needing to fallback.
  9099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9100. * @param mesh The mesh to use the fallbacks.
  9101. */
  9102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9103. /**
  9104. * Checks to see if more fallbacks are still availible.
  9105. */
  9106. get hasMoreFallbacks(): boolean;
  9107. /**
  9108. * Removes the defines that should be removed when falling back.
  9109. * @param currentDefines defines the current define statements for the shader.
  9110. * @param effect defines the current effect we try to compile
  9111. * @returns The resulting defines with defines of the current rank removed.
  9112. */
  9113. reduce(currentDefines: string, effect: Effect): string;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * "Static Class" containing the most commonly used helper while dealing with material for
  9119. * rendering purpose.
  9120. *
  9121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9122. *
  9123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9124. */
  9125. export class MaterialHelper {
  9126. /**
  9127. * Bind the current view position to an effect.
  9128. * @param effect The effect to be bound
  9129. * @param scene The scene the eyes position is used from
  9130. * @param variableName name of the shader variable that will hold the eye position
  9131. */
  9132. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9133. /**
  9134. * Helps preparing the defines values about the UVs in used in the effect.
  9135. * UVs are shared as much as we can accross channels in the shaders.
  9136. * @param texture The texture we are preparing the UVs for
  9137. * @param defines The defines to update
  9138. * @param key The channel key "diffuse", "specular"... used in the shader
  9139. */
  9140. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9141. /**
  9142. * Binds a texture matrix value to its corrsponding uniform
  9143. * @param texture The texture to bind the matrix for
  9144. * @param uniformBuffer The uniform buffer receivin the data
  9145. * @param key The channel key "diffuse", "specular"... used in the shader
  9146. */
  9147. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9148. /**
  9149. * Gets the current status of the fog (should it be enabled?)
  9150. * @param mesh defines the mesh to evaluate for fog support
  9151. * @param scene defines the hosting scene
  9152. * @returns true if fog must be enabled
  9153. */
  9154. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9155. /**
  9156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9157. * @param mesh defines the current mesh
  9158. * @param scene defines the current scene
  9159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9160. * @param pointsCloud defines if point cloud rendering has to be turned on
  9161. * @param fogEnabled defines if fog has to be turned on
  9162. * @param alphaTest defines if alpha testing has to be turned on
  9163. * @param defines defines the current list of defines
  9164. */
  9165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9166. /**
  9167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9168. * @param scene defines the current scene
  9169. * @param engine defines the current engine
  9170. * @param defines specifies the list of active defines
  9171. * @param useInstances defines if instances have to be turned on
  9172. * @param useClipPlane defines if clip plane have to be turned on
  9173. */
  9174. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9175. /**
  9176. * Prepares the defines for bones
  9177. * @param mesh The mesh containing the geometry data we will draw
  9178. * @param defines The defines to update
  9179. */
  9180. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9181. /**
  9182. * Prepares the defines for morph targets
  9183. * @param mesh The mesh containing the geometry data we will draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9187. /**
  9188. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9189. * @param mesh The mesh containing the geometry data we will draw
  9190. * @param defines The defines to update
  9191. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9192. * @param useBones Precise whether bones should be used or not (override mesh info)
  9193. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9194. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9195. * @returns false if defines are considered not dirty and have not been checked
  9196. */
  9197. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9198. /**
  9199. * Prepares the defines related to multiview
  9200. * @param scene The scene we are intending to draw
  9201. * @param defines The defines to update
  9202. */
  9203. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param light The light the effect is compiling for
  9209. * @param lightIndex The index of the light
  9210. * @param defines The defines to update
  9211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9212. * @param state Defines the current state regarding what is needed (normals, etc...)
  9213. */
  9214. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9215. needNormals: boolean;
  9216. needRebuild: boolean;
  9217. shadowEnabled: boolean;
  9218. specularEnabled: boolean;
  9219. lightmapMode: boolean;
  9220. }): void;
  9221. /**
  9222. * Prepares the defines related to the light information passed in parameter
  9223. * @param scene The scene we are intending to draw
  9224. * @param mesh The mesh the effect is compiling for
  9225. * @param defines The defines to update
  9226. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9227. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9228. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9229. * @returns true if normals will be required for the rest of the effect
  9230. */
  9231. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9232. /**
  9233. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9234. * @param lightIndex defines the light index
  9235. * @param uniformsList The uniform list
  9236. * @param samplersList The sampler list
  9237. * @param projectedLightTexture defines if projected texture must be used
  9238. * @param uniformBuffersList defines an optional list of uniform buffers
  9239. */
  9240. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9241. /**
  9242. * Prepares the uniforms and samplers list to be used in the effect
  9243. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9244. * @param samplersList The sampler list
  9245. * @param defines The defines helping in the list generation
  9246. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9247. */
  9248. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9249. /**
  9250. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9251. * @param defines The defines to update while falling back
  9252. * @param fallbacks The authorized effect fallbacks
  9253. * @param maxSimultaneousLights The maximum number of lights allowed
  9254. * @param rank the current rank of the Effect
  9255. * @returns The newly affected rank
  9256. */
  9257. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9258. private static _TmpMorphInfluencers;
  9259. /**
  9260. * Prepares the list of attributes required for morph targets according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the morph targets attributes for
  9263. * @param influencers The number of influencers
  9264. */
  9265. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9266. /**
  9267. * Prepares the list of attributes required for morph targets according to the effect defines.
  9268. * @param attribs The current list of supported attribs
  9269. * @param mesh The mesh to prepare the morph targets attributes for
  9270. * @param defines The current Defines of the effect
  9271. */
  9272. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9273. /**
  9274. * Prepares the list of attributes required for bones according to the effect defines.
  9275. * @param attribs The current list of supported attribs
  9276. * @param mesh The mesh to prepare the bones attributes for
  9277. * @param defines The current Defines of the effect
  9278. * @param fallbacks The current efffect fallback strategy
  9279. */
  9280. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9281. /**
  9282. * Check and prepare the list of attributes required for instances according to the effect defines.
  9283. * @param attribs The current list of supported attribs
  9284. * @param defines The current MaterialDefines of the effect
  9285. */
  9286. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9287. /**
  9288. * Add the list of attributes required for instances to the attribs array.
  9289. * @param attribs The current list of supported attribs
  9290. */
  9291. static PushAttributesForInstances(attribs: string[]): void;
  9292. /**
  9293. * Binds the light information to the effect.
  9294. * @param light The light containing the generator
  9295. * @param effect The effect we are binding the data to
  9296. * @param lightIndex The light index in the effect used to render
  9297. */
  9298. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9299. /**
  9300. * Binds the lights information from the scene to the effect for the given mesh.
  9301. * @param light Light to bind
  9302. * @param lightIndex Light index
  9303. * @param scene The scene where the light belongs to
  9304. * @param effect The effect we are binding the data to
  9305. * @param useSpecular Defines if specular is supported
  9306. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9307. */
  9308. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9309. /**
  9310. * Binds the lights information from the scene to the effect for the given mesh.
  9311. * @param scene The scene the lights belongs to
  9312. * @param mesh The mesh we are binding the information to render
  9313. * @param effect The effect we are binding the data to
  9314. * @param defines The generated defines for the effect
  9315. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9317. */
  9318. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9319. private static _tempFogColor;
  9320. /**
  9321. * Binds the fog information from the scene to the effect for the given mesh.
  9322. * @param scene The scene the lights belongs to
  9323. * @param mesh The mesh we are binding the information to render
  9324. * @param effect The effect we are binding the data to
  9325. * @param linearSpace Defines if the fog effect is applied in linear space
  9326. */
  9327. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9328. /**
  9329. * Binds the bones information from the mesh to the effect.
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param effect The effect we are binding the data to
  9332. */
  9333. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9334. /**
  9335. * Binds the morph targets information from the mesh to the effect.
  9336. * @param abstractMesh The mesh we are binding the information to render
  9337. * @param effect The effect we are binding the data to
  9338. */
  9339. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9340. /**
  9341. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9342. * @param defines The generated defines used in the effect
  9343. * @param effect The effect we are binding the data to
  9344. * @param scene The scene we are willing to render with logarithmic scale for
  9345. */
  9346. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9347. /**
  9348. * Binds the clip plane information from the scene to the effect.
  9349. * @param scene The scene the clip plane information are extracted from
  9350. * @param effect The effect we are binding the data to
  9351. */
  9352. static BindClipPlane(effect: Effect, scene: Scene): void;
  9353. }
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var packingFunctions: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var bayerDitherFunctions: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var shadowMapFragmentDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var clipPlaneFragmentDeclaration: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var clipPlaneFragment: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var shadowMapFragment: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var shadowMapPixelShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /** @hidden */
  9406. export var bonesDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module BABYLON {
  9412. /** @hidden */
  9413. export var morphTargetsVertexGlobalDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module BABYLON {
  9419. /** @hidden */
  9420. export var morphTargetsVertexDeclaration: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module BABYLON {
  9426. /** @hidden */
  9427. export var instancesDeclaration: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module BABYLON {
  9433. /** @hidden */
  9434. export var helperFunctions: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module BABYLON {
  9440. /** @hidden */
  9441. export var shadowMapVertexDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module BABYLON {
  9447. /** @hidden */
  9448. export var clipPlaneVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module BABYLON {
  9454. /** @hidden */
  9455. export var morphTargetsVertex: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module BABYLON {
  9461. /** @hidden */
  9462. export var instancesVertex: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module BABYLON {
  9468. /** @hidden */
  9469. export var bonesVertex: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module BABYLON {
  9475. /** @hidden */
  9476. export var shadowMapVertexNormalBias: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module BABYLON {
  9482. /** @hidden */
  9483. export var shadowMapVertexMetric: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var clipPlaneVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var shadowMapVertexShader: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /** @hidden */
  9504. export var depthBoxBlurPixelShader: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module BABYLON {
  9510. /** @hidden */
  9511. export var shadowMapFragmentSoftTransparentShadow: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module BABYLON {
  9517. /**
  9518. * Class representing a ray with position and direction
  9519. */
  9520. export class Ray {
  9521. /** origin point */
  9522. origin: Vector3;
  9523. /** direction */
  9524. direction: Vector3;
  9525. /** length of the ray */
  9526. length: number;
  9527. private static readonly TmpVector3;
  9528. private _tmpRay;
  9529. /**
  9530. * Creates a new ray
  9531. * @param origin origin point
  9532. * @param direction direction
  9533. * @param length length of the ray
  9534. */
  9535. constructor(
  9536. /** origin point */
  9537. origin: Vector3,
  9538. /** direction */
  9539. direction: Vector3,
  9540. /** length of the ray */
  9541. length?: number);
  9542. /**
  9543. * Checks if the ray intersects a box
  9544. * This does not account for the ray lenght by design to improve perfs.
  9545. * @param minimum bound of the box
  9546. * @param maximum bound of the box
  9547. * @param intersectionTreshold extra extend to be added to the box in all direction
  9548. * @returns if the box was hit
  9549. */
  9550. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9551. /**
  9552. * Checks if the ray intersects a box
  9553. * This does not account for the ray lenght by design to improve perfs.
  9554. * @param box the bounding box to check
  9555. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9556. * @returns if the box was hit
  9557. */
  9558. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9559. /**
  9560. * If the ray hits a sphere
  9561. * @param sphere the bounding sphere to check
  9562. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9563. * @returns true if it hits the sphere
  9564. */
  9565. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9566. /**
  9567. * If the ray hits a triange
  9568. * @param vertex0 triangle vertex
  9569. * @param vertex1 triangle vertex
  9570. * @param vertex2 triangle vertex
  9571. * @returns intersection information if hit
  9572. */
  9573. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9574. /**
  9575. * Checks if ray intersects a plane
  9576. * @param plane the plane to check
  9577. * @returns the distance away it was hit
  9578. */
  9579. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9580. /**
  9581. * Calculate the intercept of a ray on a given axis
  9582. * @param axis to check 'x' | 'y' | 'z'
  9583. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9584. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9585. */
  9586. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9587. /**
  9588. * Checks if ray intersects a mesh
  9589. * @param mesh the mesh to check
  9590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9591. * @returns picking info of the intersecton
  9592. */
  9593. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9594. /**
  9595. * Checks if ray intersects a mesh
  9596. * @param meshes the meshes to check
  9597. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9598. * @param results array to store result in
  9599. * @returns Array of picking infos
  9600. */
  9601. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9602. private _comparePickingInfo;
  9603. private static smallnum;
  9604. private static rayl;
  9605. /**
  9606. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9607. * @param sega the first point of the segment to test the intersection against
  9608. * @param segb the second point of the segment to test the intersection against
  9609. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9610. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9611. */
  9612. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9613. /**
  9614. * Update the ray from viewport position
  9615. * @param x position
  9616. * @param y y position
  9617. * @param viewportWidth viewport width
  9618. * @param viewportHeight viewport height
  9619. * @param world world matrix
  9620. * @param view view matrix
  9621. * @param projection projection matrix
  9622. * @returns this ray updated
  9623. */
  9624. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9625. /**
  9626. * Creates a ray with origin and direction of 0,0,0
  9627. * @returns the new ray
  9628. */
  9629. static Zero(): Ray;
  9630. /**
  9631. * Creates a new ray from screen space and viewport
  9632. * @param x position
  9633. * @param y y position
  9634. * @param viewportWidth viewport width
  9635. * @param viewportHeight viewport height
  9636. * @param world world matrix
  9637. * @param view view matrix
  9638. * @param projection projection matrix
  9639. * @returns new ray
  9640. */
  9641. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9642. /**
  9643. * 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
  9644. * transformed to the given world matrix.
  9645. * @param origin The origin point
  9646. * @param end The end point
  9647. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9648. * @returns the new ray
  9649. */
  9650. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9651. /**
  9652. * Transforms a ray by a matrix
  9653. * @param ray ray to transform
  9654. * @param matrix matrix to apply
  9655. * @returns the resulting new ray
  9656. */
  9657. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9658. /**
  9659. * Transforms a ray by a matrix
  9660. * @param ray ray to transform
  9661. * @param matrix matrix to apply
  9662. * @param result ray to store result in
  9663. */
  9664. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9665. /**
  9666. * Unproject a ray from screen space to object space
  9667. * @param sourceX defines the screen space x coordinate to use
  9668. * @param sourceY defines the screen space y coordinate to use
  9669. * @param viewportWidth defines the current width of the viewport
  9670. * @param viewportHeight defines the current height of the viewport
  9671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9672. * @param view defines the view matrix to use
  9673. * @param projection defines the projection matrix to use
  9674. */
  9675. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9676. }
  9677. /**
  9678. * Type used to define predicate used to select faces when a mesh intersection is detected
  9679. */
  9680. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9681. interface Scene {
  9682. /** @hidden */
  9683. _tempPickingRay: Nullable<Ray>;
  9684. /** @hidden */
  9685. _cachedRayForTransform: Ray;
  9686. /** @hidden */
  9687. _pickWithRayInverseMatrix: Matrix;
  9688. /** @hidden */
  9689. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9690. /** @hidden */
  9691. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9692. }
  9693. }
  9694. declare module BABYLON {
  9695. /**
  9696. * Groups all the scene component constants in one place to ease maintenance.
  9697. * @hidden
  9698. */
  9699. export class SceneComponentConstants {
  9700. static readonly NAME_EFFECTLAYER: string;
  9701. static readonly NAME_LAYER: string;
  9702. static readonly NAME_LENSFLARESYSTEM: string;
  9703. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9704. static readonly NAME_PARTICLESYSTEM: string;
  9705. static readonly NAME_GAMEPAD: string;
  9706. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9707. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9708. static readonly NAME_DEPTHRENDERER: string;
  9709. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9710. static readonly NAME_SPRITE: string;
  9711. static readonly NAME_OUTLINERENDERER: string;
  9712. static readonly NAME_PROCEDURALTEXTURE: string;
  9713. static readonly NAME_SHADOWGENERATOR: string;
  9714. static readonly NAME_OCTREE: string;
  9715. static readonly NAME_PHYSICSENGINE: string;
  9716. static readonly NAME_AUDIO: string;
  9717. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9718. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9719. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9720. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9721. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9722. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9723. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9724. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9725. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9726. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9727. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9728. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9729. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9730. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9731. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9732. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9733. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9734. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9735. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9736. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9737. static readonly STEP_AFTERRENDER_AUDIO: number;
  9738. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9739. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9740. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9741. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9742. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9743. static readonly STEP_POINTERMOVE_SPRITE: number;
  9744. static readonly STEP_POINTERDOWN_SPRITE: number;
  9745. static readonly STEP_POINTERUP_SPRITE: number;
  9746. }
  9747. /**
  9748. * This represents a scene component.
  9749. *
  9750. * This is used to decouple the dependency the scene is having on the different workloads like
  9751. * layers, post processes...
  9752. */
  9753. export interface ISceneComponent {
  9754. /**
  9755. * The name of the component. Each component must have a unique name.
  9756. */
  9757. name: string;
  9758. /**
  9759. * The scene the component belongs to.
  9760. */
  9761. scene: Scene;
  9762. /**
  9763. * Register the component to one instance of a scene.
  9764. */
  9765. register(): void;
  9766. /**
  9767. * Rebuilds the elements related to this component in case of
  9768. * context lost for instance.
  9769. */
  9770. rebuild(): void;
  9771. /**
  9772. * Disposes the component and the associated ressources.
  9773. */
  9774. dispose(): void;
  9775. }
  9776. /**
  9777. * This represents a SERIALIZABLE scene component.
  9778. *
  9779. * This extends Scene Component to add Serialization methods on top.
  9780. */
  9781. export interface ISceneSerializableComponent extends ISceneComponent {
  9782. /**
  9783. * Adds all the elements from the container to the scene
  9784. * @param container the container holding the elements
  9785. */
  9786. addFromContainer(container: AbstractScene): void;
  9787. /**
  9788. * Removes all the elements in the container from the scene
  9789. * @param container contains the elements to remove
  9790. * @param dispose if the removed element should be disposed (default: false)
  9791. */
  9792. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9793. /**
  9794. * Serializes the component data to the specified json object
  9795. * @param serializationObject The object to serialize to
  9796. */
  9797. serialize(serializationObject: any): void;
  9798. }
  9799. /**
  9800. * Strong typing of a Mesh related stage step action
  9801. */
  9802. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9803. /**
  9804. * Strong typing of a Evaluate Sub Mesh related stage step action
  9805. */
  9806. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9807. /**
  9808. * Strong typing of a Active Mesh related stage step action
  9809. */
  9810. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9811. /**
  9812. * Strong typing of a Camera related stage step action
  9813. */
  9814. export type CameraStageAction = (camera: Camera) => void;
  9815. /**
  9816. * Strong typing of a Camera Frame buffer related stage step action
  9817. */
  9818. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9819. /**
  9820. * Strong typing of a Render Target related stage step action
  9821. */
  9822. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9823. /**
  9824. * Strong typing of a RenderingGroup related stage step action
  9825. */
  9826. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9827. /**
  9828. * Strong typing of a Mesh Render related stage step action
  9829. */
  9830. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9831. /**
  9832. * Strong typing of a simple stage step action
  9833. */
  9834. export type SimpleStageAction = () => void;
  9835. /**
  9836. * Strong typing of a render target action.
  9837. */
  9838. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9839. /**
  9840. * Strong typing of a pointer move action.
  9841. */
  9842. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9843. /**
  9844. * Strong typing of a pointer up/down action.
  9845. */
  9846. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9847. /**
  9848. * Representation of a stage in the scene (Basically a list of ordered steps)
  9849. * @hidden
  9850. */
  9851. export class Stage<T extends Function> extends Array<{
  9852. index: number;
  9853. component: ISceneComponent;
  9854. action: T;
  9855. }> {
  9856. /**
  9857. * Hide ctor from the rest of the world.
  9858. * @param items The items to add.
  9859. */
  9860. private constructor();
  9861. /**
  9862. * Creates a new Stage.
  9863. * @returns A new instance of a Stage
  9864. */
  9865. static Create<T extends Function>(): Stage<T>;
  9866. /**
  9867. * Registers a step in an ordered way in the targeted stage.
  9868. * @param index Defines the position to register the step in
  9869. * @param component Defines the component attached to the step
  9870. * @param action Defines the action to launch during the step
  9871. */
  9872. registerStep(index: number, component: ISceneComponent, action: T): void;
  9873. /**
  9874. * Clears all the steps from the stage.
  9875. */
  9876. clear(): void;
  9877. }
  9878. }
  9879. declare module BABYLON {
  9880. interface Scene {
  9881. /** @hidden */
  9882. _pointerOverSprite: Nullable<Sprite>;
  9883. /** @hidden */
  9884. _pickedDownSprite: Nullable<Sprite>;
  9885. /** @hidden */
  9886. _tempSpritePickingRay: Nullable<Ray>;
  9887. /**
  9888. * All of the sprite managers added to this scene
  9889. * @see http://doc.babylonjs.com/babylon101/sprites
  9890. */
  9891. spriteManagers: Array<ISpriteManager>;
  9892. /**
  9893. * An event triggered when sprites rendering is about to start
  9894. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9895. */
  9896. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9897. /**
  9898. * An event triggered when sprites rendering is done
  9899. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9900. */
  9901. onAfterSpritesRenderingObservable: Observable<Scene>;
  9902. /** @hidden */
  9903. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9904. /** Launch a ray to try to pick a sprite in the scene
  9905. * @param x position on screen
  9906. * @param y position on screen
  9907. * @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
  9908. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9909. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9910. * @returns a PickingInfo
  9911. */
  9912. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9913. /** Use the given ray to pick a sprite in the scene
  9914. * @param ray The ray (in world space) to use to pick meshes
  9915. * @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
  9916. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9917. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9918. * @returns a PickingInfo
  9919. */
  9920. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9921. /** @hidden */
  9922. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9923. /** Launch a ray to try to pick sprites in the scene
  9924. * @param x position on screen
  9925. * @param y position on screen
  9926. * @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
  9927. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9928. * @returns a PickingInfo array
  9929. */
  9930. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9931. /** Use the given ray to pick sprites in the scene
  9932. * @param ray The ray (in world space) to use to pick meshes
  9933. * @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
  9934. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9935. * @returns a PickingInfo array
  9936. */
  9937. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9938. /**
  9939. * Force the sprite under the pointer
  9940. * @param sprite defines the sprite to use
  9941. */
  9942. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9943. /**
  9944. * Gets the sprite under the pointer
  9945. * @returns a Sprite or null if no sprite is under the pointer
  9946. */
  9947. getPointerOverSprite(): Nullable<Sprite>;
  9948. }
  9949. /**
  9950. * Defines the sprite scene component responsible to manage sprites
  9951. * in a given scene.
  9952. */
  9953. export class SpriteSceneComponent implements ISceneComponent {
  9954. /**
  9955. * The component name helpfull to identify the component in the list of scene components.
  9956. */
  9957. readonly name: string;
  9958. /**
  9959. * The scene the component belongs to.
  9960. */
  9961. scene: Scene;
  9962. /** @hidden */
  9963. private _spritePredicate;
  9964. /**
  9965. * Creates a new instance of the component for the given scene
  9966. * @param scene Defines the scene to register the component in
  9967. */
  9968. constructor(scene: Scene);
  9969. /**
  9970. * Registers the component in a given scene
  9971. */
  9972. register(): void;
  9973. /**
  9974. * Rebuilds the elements related to this component in case of
  9975. * context lost for instance.
  9976. */
  9977. rebuild(): void;
  9978. /**
  9979. * Disposes the component and the associated ressources.
  9980. */
  9981. dispose(): void;
  9982. private _pickSpriteButKeepRay;
  9983. private _pointerMove;
  9984. private _pointerDown;
  9985. private _pointerUp;
  9986. }
  9987. }
  9988. declare module BABYLON {
  9989. /** @hidden */
  9990. export var fogFragmentDeclaration: {
  9991. name: string;
  9992. shader: string;
  9993. };
  9994. }
  9995. declare module BABYLON {
  9996. /** @hidden */
  9997. export var fogFragment: {
  9998. name: string;
  9999. shader: string;
  10000. };
  10001. }
  10002. declare module BABYLON {
  10003. /** @hidden */
  10004. export var spritesPixelShader: {
  10005. name: string;
  10006. shader: string;
  10007. };
  10008. }
  10009. declare module BABYLON {
  10010. /** @hidden */
  10011. export var fogVertexDeclaration: {
  10012. name: string;
  10013. shader: string;
  10014. };
  10015. }
  10016. declare module BABYLON {
  10017. /** @hidden */
  10018. export var spritesVertexShader: {
  10019. name: string;
  10020. shader: string;
  10021. };
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10026. */
  10027. export interface ISpriteManager extends IDisposable {
  10028. /**
  10029. * Restricts the camera to viewing objects with the same layerMask.
  10030. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10031. */
  10032. layerMask: number;
  10033. /**
  10034. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10035. */
  10036. isPickable: boolean;
  10037. /**
  10038. * Gets the hosting scene
  10039. */
  10040. scene: Scene;
  10041. /**
  10042. * Specifies the rendering group id for this mesh (0 by default)
  10043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10044. */
  10045. renderingGroupId: number;
  10046. /**
  10047. * Defines the list of sprites managed by the manager.
  10048. */
  10049. sprites: Array<Sprite>;
  10050. /**
  10051. * Tests the intersection of a sprite with a specific ray.
  10052. * @param ray The ray we are sending to test the collision
  10053. * @param camera The camera space we are sending rays in
  10054. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10055. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10056. * @returns picking info or null.
  10057. */
  10058. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10059. /**
  10060. * Intersects the sprites with a ray
  10061. * @param ray defines the ray to intersect with
  10062. * @param camera defines the current active camera
  10063. * @param predicate defines a predicate used to select candidate sprites
  10064. * @returns null if no hit or a PickingInfo array
  10065. */
  10066. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10067. /**
  10068. * Renders the list of sprites on screen.
  10069. */
  10070. render(): void;
  10071. }
  10072. /**
  10073. * Class used to manage multiple sprites on the same spritesheet
  10074. * @see http://doc.babylonjs.com/babylon101/sprites
  10075. */
  10076. export class SpriteManager implements ISpriteManager {
  10077. /** defines the manager's name */
  10078. name: string;
  10079. /** Gets the list of sprites */
  10080. sprites: Sprite[];
  10081. /** Gets or sets the rendering group id (0 by default) */
  10082. renderingGroupId: number;
  10083. /** Gets or sets camera layer mask */
  10084. layerMask: number;
  10085. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10086. fogEnabled: boolean;
  10087. /** Gets or sets a boolean indicating if the sprites are pickable */
  10088. isPickable: boolean;
  10089. /** Defines the default width of a cell in the spritesheet */
  10090. cellWidth: number;
  10091. /** Defines the default height of a cell in the spritesheet */
  10092. cellHeight: number;
  10093. /** Associative array from JSON sprite data file */
  10094. private _cellData;
  10095. /** Array of sprite names from JSON sprite data file */
  10096. private _spriteMap;
  10097. /** True when packed cell data from JSON file is ready*/
  10098. private _packedAndReady;
  10099. private _textureContent;
  10100. /**
  10101. * An event triggered when the manager is disposed.
  10102. */
  10103. onDisposeObservable: Observable<SpriteManager>;
  10104. private _onDisposeObserver;
  10105. /**
  10106. * Callback called when the manager is disposed
  10107. */
  10108. set onDispose(callback: () => void);
  10109. private _capacity;
  10110. private _fromPacked;
  10111. private _spriteTexture;
  10112. private _epsilon;
  10113. private _scene;
  10114. private _vertexData;
  10115. private _buffer;
  10116. private _vertexBuffers;
  10117. private _indexBuffer;
  10118. private _effectBase;
  10119. private _effectFog;
  10120. /**
  10121. * Gets or sets the unique id of the sprite
  10122. */
  10123. uniqueId: number;
  10124. /**
  10125. * Gets the array of sprites
  10126. */
  10127. get children(): Sprite[];
  10128. /**
  10129. * Gets the hosting scene
  10130. */
  10131. get scene(): Scene;
  10132. /**
  10133. * Gets or sets the spritesheet texture
  10134. */
  10135. get texture(): Texture;
  10136. set texture(value: Texture);
  10137. private _blendMode;
  10138. /**
  10139. * Blend mode use to render the particle, it can be any of
  10140. * the static Constants.ALPHA_x properties provided in this class.
  10141. * Default value is Constants.ALPHA_COMBINE
  10142. */
  10143. get blendMode(): number;
  10144. set blendMode(blendMode: number);
  10145. /** Disables writing to the depth buffer when rendering the sprites.
  10146. * It can be handy to disable depth writing when using textures without alpha channel
  10147. * and setting some specific blend modes.
  10148. */
  10149. disableDepthWrite: boolean;
  10150. /**
  10151. * Creates a new sprite manager
  10152. * @param name defines the manager's name
  10153. * @param imgUrl defines the sprite sheet url
  10154. * @param capacity defines the maximum allowed number of sprites
  10155. * @param cellSize defines the size of a sprite cell
  10156. * @param scene defines the hosting scene
  10157. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10158. * @param samplingMode defines the smapling mode to use with spritesheet
  10159. * @param fromPacked set to false; do not alter
  10160. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10161. */
  10162. constructor(
  10163. /** defines the manager's name */
  10164. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10165. /**
  10166. * Returns the string "SpriteManager"
  10167. * @returns "SpriteManager"
  10168. */
  10169. getClassName(): string;
  10170. private _makePacked;
  10171. private _appendSpriteVertex;
  10172. private _checkTextureAlpha;
  10173. /**
  10174. * Intersects the sprites with a ray
  10175. * @param ray defines the ray to intersect with
  10176. * @param camera defines the current active camera
  10177. * @param predicate defines a predicate used to select candidate sprites
  10178. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10179. * @returns null if no hit or a PickingInfo
  10180. */
  10181. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10182. /**
  10183. * Intersects the sprites with a ray
  10184. * @param ray defines the ray to intersect with
  10185. * @param camera defines the current active camera
  10186. * @param predicate defines a predicate used to select candidate sprites
  10187. * @returns null if no hit or a PickingInfo array
  10188. */
  10189. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10190. /**
  10191. * Render all child sprites
  10192. */
  10193. render(): void;
  10194. /**
  10195. * Release associated resources
  10196. */
  10197. dispose(): void;
  10198. }
  10199. }
  10200. declare module BABYLON {
  10201. /** Interface used by value gradients (color, factor, ...) */
  10202. export interface IValueGradient {
  10203. /**
  10204. * Gets or sets the gradient value (between 0 and 1)
  10205. */
  10206. gradient: number;
  10207. }
  10208. /** Class used to store color4 gradient */
  10209. export class ColorGradient implements IValueGradient {
  10210. /**
  10211. * Gets or sets the gradient value (between 0 and 1)
  10212. */
  10213. gradient: number;
  10214. /**
  10215. * Gets or sets first associated color
  10216. */
  10217. color1: Color4;
  10218. /**
  10219. * Gets or sets second associated color
  10220. */
  10221. color2?: Color4 | undefined;
  10222. /**
  10223. * Creates a new color4 gradient
  10224. * @param gradient gets or sets the gradient value (between 0 and 1)
  10225. * @param color1 gets or sets first associated color
  10226. * @param color2 gets or sets first second color
  10227. */
  10228. constructor(
  10229. /**
  10230. * Gets or sets the gradient value (between 0 and 1)
  10231. */
  10232. gradient: number,
  10233. /**
  10234. * Gets or sets first associated color
  10235. */
  10236. color1: Color4,
  10237. /**
  10238. * Gets or sets second associated color
  10239. */
  10240. color2?: Color4 | undefined);
  10241. /**
  10242. * Will get a color picked randomly between color1 and color2.
  10243. * If color2 is undefined then color1 will be used
  10244. * @param result defines the target Color4 to store the result in
  10245. */
  10246. getColorToRef(result: Color4): void;
  10247. }
  10248. /** Class used to store color 3 gradient */
  10249. export class Color3Gradient implements IValueGradient {
  10250. /**
  10251. * Gets or sets the gradient value (between 0 and 1)
  10252. */
  10253. gradient: number;
  10254. /**
  10255. * Gets or sets the associated color
  10256. */
  10257. color: Color3;
  10258. /**
  10259. * Creates a new color3 gradient
  10260. * @param gradient gets or sets the gradient value (between 0 and 1)
  10261. * @param color gets or sets associated color
  10262. */
  10263. constructor(
  10264. /**
  10265. * Gets or sets the gradient value (between 0 and 1)
  10266. */
  10267. gradient: number,
  10268. /**
  10269. * Gets or sets the associated color
  10270. */
  10271. color: Color3);
  10272. }
  10273. /** Class used to store factor gradient */
  10274. export class FactorGradient implements IValueGradient {
  10275. /**
  10276. * Gets or sets the gradient value (between 0 and 1)
  10277. */
  10278. gradient: number;
  10279. /**
  10280. * Gets or sets first associated factor
  10281. */
  10282. factor1: number;
  10283. /**
  10284. * Gets or sets second associated factor
  10285. */
  10286. factor2?: number | undefined;
  10287. /**
  10288. * Creates a new factor gradient
  10289. * @param gradient gets or sets the gradient value (between 0 and 1)
  10290. * @param factor1 gets or sets first associated factor
  10291. * @param factor2 gets or sets second associated factor
  10292. */
  10293. constructor(
  10294. /**
  10295. * Gets or sets the gradient value (between 0 and 1)
  10296. */
  10297. gradient: number,
  10298. /**
  10299. * Gets or sets first associated factor
  10300. */
  10301. factor1: number,
  10302. /**
  10303. * Gets or sets second associated factor
  10304. */
  10305. factor2?: number | undefined);
  10306. /**
  10307. * Will get a number picked randomly between factor1 and factor2.
  10308. * If factor2 is undefined then factor1 will be used
  10309. * @returns the picked number
  10310. */
  10311. getFactor(): number;
  10312. }
  10313. /**
  10314. * Helper used to simplify some generic gradient tasks
  10315. */
  10316. export class GradientHelper {
  10317. /**
  10318. * Gets the current gradient from an array of IValueGradient
  10319. * @param ratio defines the current ratio to get
  10320. * @param gradients defines the array of IValueGradient
  10321. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10322. */
  10323. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10324. }
  10325. }
  10326. declare module BABYLON {
  10327. /**
  10328. * Interface for the size containing width and height
  10329. */
  10330. export interface ISize {
  10331. /**
  10332. * Width
  10333. */
  10334. width: number;
  10335. /**
  10336. * Heighht
  10337. */
  10338. height: number;
  10339. }
  10340. /**
  10341. * Size containing widht and height
  10342. */
  10343. export class Size implements ISize {
  10344. /**
  10345. * Width
  10346. */
  10347. width: number;
  10348. /**
  10349. * Height
  10350. */
  10351. height: number;
  10352. /**
  10353. * Creates a Size object from the given width and height (floats).
  10354. * @param width width of the new size
  10355. * @param height height of the new size
  10356. */
  10357. constructor(width: number, height: number);
  10358. /**
  10359. * Returns a string with the Size width and height
  10360. * @returns a string with the Size width and height
  10361. */
  10362. toString(): string;
  10363. /**
  10364. * "Size"
  10365. * @returns the string "Size"
  10366. */
  10367. getClassName(): string;
  10368. /**
  10369. * Returns the Size hash code.
  10370. * @returns a hash code for a unique width and height
  10371. */
  10372. getHashCode(): number;
  10373. /**
  10374. * Updates the current size from the given one.
  10375. * @param src the given size
  10376. */
  10377. copyFrom(src: Size): void;
  10378. /**
  10379. * Updates in place the current Size from the given floats.
  10380. * @param width width of the new size
  10381. * @param height height of the new size
  10382. * @returns the updated Size.
  10383. */
  10384. copyFromFloats(width: number, height: number): Size;
  10385. /**
  10386. * Updates in place the current Size from the given floats.
  10387. * @param width width to set
  10388. * @param height height to set
  10389. * @returns the updated Size.
  10390. */
  10391. set(width: number, height: number): Size;
  10392. /**
  10393. * Multiplies the width and height by numbers
  10394. * @param w factor to multiple the width by
  10395. * @param h factor to multiple the height by
  10396. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10397. */
  10398. multiplyByFloats(w: number, h: number): Size;
  10399. /**
  10400. * Clones the size
  10401. * @returns a new Size copied from the given one.
  10402. */
  10403. clone(): Size;
  10404. /**
  10405. * True if the current Size and the given one width and height are strictly equal.
  10406. * @param other the other size to compare against
  10407. * @returns True if the current Size and the given one width and height are strictly equal.
  10408. */
  10409. equals(other: Size): boolean;
  10410. /**
  10411. * The surface of the Size : width * height (float).
  10412. */
  10413. get surface(): number;
  10414. /**
  10415. * Create a new size of zero
  10416. * @returns a new Size set to (0.0, 0.0)
  10417. */
  10418. static Zero(): Size;
  10419. /**
  10420. * Sums the width and height of two sizes
  10421. * @param otherSize size to add to this size
  10422. * @returns a new Size set as the addition result of the current Size and the given one.
  10423. */
  10424. add(otherSize: Size): Size;
  10425. /**
  10426. * Subtracts the width and height of two
  10427. * @param otherSize size to subtract to this size
  10428. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10429. */
  10430. subtract(otherSize: Size): Size;
  10431. /**
  10432. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10433. * @param start starting size to lerp between
  10434. * @param end end size to lerp between
  10435. * @param amount amount to lerp between the start and end values
  10436. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10437. */
  10438. static Lerp(start: Size, end: Size, amount: number): Size;
  10439. }
  10440. }
  10441. declare module BABYLON {
  10442. interface ThinEngine {
  10443. /**
  10444. * Creates a dynamic texture
  10445. * @param width defines the width of the texture
  10446. * @param height defines the height of the texture
  10447. * @param generateMipMaps defines if the engine should generate the mip levels
  10448. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10449. * @returns the dynamic texture inside an InternalTexture
  10450. */
  10451. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10452. /**
  10453. * Update the content of a dynamic texture
  10454. * @param texture defines the texture to update
  10455. * @param canvas defines the canvas containing the source
  10456. * @param invertY defines if data must be stored with Y axis inverted
  10457. * @param premulAlpha defines if alpha is stored as premultiplied
  10458. * @param format defines the format of the data
  10459. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10460. */
  10461. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10462. }
  10463. }
  10464. declare module BABYLON {
  10465. /**
  10466. * Helper class used to generate a canvas to manipulate images
  10467. */
  10468. export class CanvasGenerator {
  10469. /**
  10470. * Create a new canvas (or offscreen canvas depending on the context)
  10471. * @param width defines the expected width
  10472. * @param height defines the expected height
  10473. * @return a new canvas or offscreen canvas
  10474. */
  10475. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10476. }
  10477. }
  10478. declare module BABYLON {
  10479. /**
  10480. * A class extending Texture allowing drawing on a texture
  10481. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10482. */
  10483. export class DynamicTexture extends Texture {
  10484. private _generateMipMaps;
  10485. private _canvas;
  10486. private _context;
  10487. /**
  10488. * Creates a DynamicTexture
  10489. * @param name defines the name of the texture
  10490. * @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
  10491. * @param scene defines the scene where you want the texture
  10492. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10493. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10494. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10495. */
  10496. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10497. /**
  10498. * Get the current class name of the texture useful for serialization or dynamic coding.
  10499. * @returns "DynamicTexture"
  10500. */
  10501. getClassName(): string;
  10502. /**
  10503. * Gets the current state of canRescale
  10504. */
  10505. get canRescale(): boolean;
  10506. private _recreate;
  10507. /**
  10508. * Scales the texture
  10509. * @param ratio the scale factor to apply to both width and height
  10510. */
  10511. scale(ratio: number): void;
  10512. /**
  10513. * Resizes the texture
  10514. * @param width the new width
  10515. * @param height the new height
  10516. */
  10517. scaleTo(width: number, height: number): void;
  10518. /**
  10519. * Gets the context of the canvas used by the texture
  10520. * @returns the canvas context of the dynamic texture
  10521. */
  10522. getContext(): CanvasRenderingContext2D;
  10523. /**
  10524. * Clears the texture
  10525. */
  10526. clear(): void;
  10527. /**
  10528. * Updates the texture
  10529. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10530. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10531. */
  10532. update(invertY?: boolean, premulAlpha?: boolean): void;
  10533. /**
  10534. * Draws text onto the texture
  10535. * @param text defines the text to be drawn
  10536. * @param x defines the placement of the text from the left
  10537. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10538. * @param font defines the font to be used with font-style, font-size, font-name
  10539. * @param color defines the color used for the text
  10540. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10541. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10542. * @param update defines whether texture is immediately update (default is true)
  10543. */
  10544. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10545. /**
  10546. * Clones the texture
  10547. * @returns the clone of the texture.
  10548. */
  10549. clone(): DynamicTexture;
  10550. /**
  10551. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10552. * @returns a serialized dynamic texture object
  10553. */
  10554. serialize(): any;
  10555. /** @hidden */
  10556. _rebuild(): void;
  10557. }
  10558. }
  10559. declare module BABYLON {
  10560. interface ThinEngine {
  10561. /**
  10562. * Creates a raw texture
  10563. * @param data defines the data to store in the texture
  10564. * @param width defines the width of the texture
  10565. * @param height defines the height of the texture
  10566. * @param format defines the format of the data
  10567. * @param generateMipMaps defines if the engine should generate the mip levels
  10568. * @param invertY defines if data must be stored with Y axis inverted
  10569. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10570. * @param compression defines the compression used (null by default)
  10571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10572. * @returns the raw texture inside an InternalTexture
  10573. */
  10574. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10575. /**
  10576. * Update a raw texture
  10577. * @param texture defines the texture to update
  10578. * @param data defines the data to store in the texture
  10579. * @param format defines the format of the data
  10580. * @param invertY defines if data must be stored with Y axis inverted
  10581. */
  10582. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10583. /**
  10584. * Update a raw texture
  10585. * @param texture defines the texture to update
  10586. * @param data defines the data to store in the texture
  10587. * @param format defines the format of the data
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param compression defines the compression used (null by default)
  10590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10591. */
  10592. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10593. /**
  10594. * Creates a new raw cube texture
  10595. * @param data defines the array of data to use to create each face
  10596. * @param size defines the size of the textures
  10597. * @param format defines the format of the data
  10598. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10599. * @param generateMipMaps defines if the engine should generate the mip levels
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10602. * @param compression defines the compression used (null by default)
  10603. * @returns the cube texture as an InternalTexture
  10604. */
  10605. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10606. /**
  10607. * Update a raw cube texture
  10608. * @param texture defines the texture to udpdate
  10609. * @param data defines the data to store
  10610. * @param format defines the data format
  10611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10612. * @param invertY defines if data must be stored with Y axis inverted
  10613. */
  10614. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10615. /**
  10616. * Update a raw cube texture
  10617. * @param texture defines the texture to udpdate
  10618. * @param data defines the data to store
  10619. * @param format defines the data format
  10620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10621. * @param invertY defines if data must be stored with Y axis inverted
  10622. * @param compression defines the compression used (null by default)
  10623. */
  10624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10625. /**
  10626. * Update a raw cube texture
  10627. * @param texture defines the texture to udpdate
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10631. * @param invertY defines if data must be stored with Y axis inverted
  10632. * @param compression defines the compression used (null by default)
  10633. * @param level defines which level of the texture to update
  10634. */
  10635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10636. /**
  10637. * Creates a new raw cube texture from a specified url
  10638. * @param url defines the url where the data is located
  10639. * @param scene defines the current scene
  10640. * @param size defines the size of the textures
  10641. * @param format defines the format of the data
  10642. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10643. * @param noMipmap defines if the engine should avoid generating the mip levels
  10644. * @param callback defines a callback used to extract texture data from loaded data
  10645. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10646. * @param onLoad defines a callback called when texture is loaded
  10647. * @param onError defines a callback called if there is an error
  10648. * @returns the cube texture as an InternalTexture
  10649. */
  10650. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10651. /**
  10652. * Creates a new raw cube texture from a specified url
  10653. * @param url defines the url where the data is located
  10654. * @param scene defines the current scene
  10655. * @param size defines the size of the textures
  10656. * @param format defines the format of the data
  10657. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10658. * @param noMipmap defines if the engine should avoid generating the mip levels
  10659. * @param callback defines a callback used to extract texture data from loaded data
  10660. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10661. * @param onLoad defines a callback called when texture is loaded
  10662. * @param onError defines a callback called if there is an error
  10663. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10664. * @param invertY defines if data must be stored with Y axis inverted
  10665. * @returns the cube texture as an InternalTexture
  10666. */
  10667. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10668. /**
  10669. * Creates a new raw 3D texture
  10670. * @param data defines the data used to create the texture
  10671. * @param width defines the width of the texture
  10672. * @param height defines the height of the texture
  10673. * @param depth defines the depth of the texture
  10674. * @param format defines the format of the texture
  10675. * @param generateMipMaps defines if the engine must generate mip levels
  10676. * @param invertY defines if data must be stored with Y axis inverted
  10677. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10678. * @param compression defines the compressed used (can be null)
  10679. * @param textureType defines the compressed used (can be null)
  10680. * @returns a new raw 3D texture (stored in an InternalTexture)
  10681. */
  10682. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10683. /**
  10684. * Update a raw 3D texture
  10685. * @param texture defines the texture to update
  10686. * @param data defines the data to store
  10687. * @param format defines the data format
  10688. * @param invertY defines if data must be stored with Y axis inverted
  10689. */
  10690. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10691. /**
  10692. * Update a raw 3D texture
  10693. * @param texture defines the texture to update
  10694. * @param data defines the data to store
  10695. * @param format defines the data format
  10696. * @param invertY defines if data must be stored with Y axis inverted
  10697. * @param compression defines the used compression (can be null)
  10698. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10699. */
  10700. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10701. /**
  10702. * Creates a new raw 2D array texture
  10703. * @param data defines the data used to create the texture
  10704. * @param width defines the width of the texture
  10705. * @param height defines the height of the texture
  10706. * @param depth defines the number of layers of the texture
  10707. * @param format defines the format of the texture
  10708. * @param generateMipMaps defines if the engine must generate mip levels
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10711. * @param compression defines the compressed used (can be null)
  10712. * @param textureType defines the compressed used (can be null)
  10713. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10714. */
  10715. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10716. /**
  10717. * Update a raw 2D array texture
  10718. * @param texture defines the texture to update
  10719. * @param data defines the data to store
  10720. * @param format defines the data format
  10721. * @param invertY defines if data must be stored with Y axis inverted
  10722. */
  10723. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10724. /**
  10725. * Update a raw 2D array texture
  10726. * @param texture defines the texture to update
  10727. * @param data defines the data to store
  10728. * @param format defines the data format
  10729. * @param invertY defines if data must be stored with Y axis inverted
  10730. * @param compression defines the used compression (can be null)
  10731. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10732. */
  10733. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. /**
  10738. * Raw texture can help creating a texture directly from an array of data.
  10739. * This can be super useful if you either get the data from an uncompressed source or
  10740. * if you wish to create your texture pixel by pixel.
  10741. */
  10742. export class RawTexture extends Texture {
  10743. /**
  10744. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10745. */
  10746. format: number;
  10747. /**
  10748. * Instantiates a new RawTexture.
  10749. * Raw texture can help creating a texture directly from an array of data.
  10750. * This can be super useful if you either get the data from an uncompressed source or
  10751. * if you wish to create your texture pixel by pixel.
  10752. * @param data define the array of data to use to create the texture
  10753. * @param width define the width of the texture
  10754. * @param height define the height of the texture
  10755. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10756. * @param scene define the scene the texture belongs to
  10757. * @param generateMipMaps define whether mip maps should be generated or not
  10758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10760. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10761. */
  10762. constructor(data: ArrayBufferView, width: number, height: number,
  10763. /**
  10764. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10765. */
  10766. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10767. /**
  10768. * Updates the texture underlying data.
  10769. * @param data Define the new data of the texture
  10770. */
  10771. update(data: ArrayBufferView): void;
  10772. /**
  10773. * Creates a luminance texture from some data.
  10774. * @param data Define the texture data
  10775. * @param width Define the width of the texture
  10776. * @param height Define the height of the texture
  10777. * @param scene Define the scene the texture belongs to
  10778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10781. * @returns the luminance texture
  10782. */
  10783. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10784. /**
  10785. * Creates a luminance alpha texture from some data.
  10786. * @param data Define the texture data
  10787. * @param width Define the width of the texture
  10788. * @param height Define the height of the texture
  10789. * @param scene Define the scene the texture belongs to
  10790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10793. * @returns the luminance alpha texture
  10794. */
  10795. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10796. /**
  10797. * Creates an alpha texture from some data.
  10798. * @param data Define the texture data
  10799. * @param width Define the width of the texture
  10800. * @param height Define the height of the texture
  10801. * @param scene Define the scene the texture belongs to
  10802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10805. * @returns the alpha texture
  10806. */
  10807. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10808. /**
  10809. * Creates a RGB texture from some data.
  10810. * @param data Define the texture data
  10811. * @param width Define the width of the texture
  10812. * @param height Define the height of the texture
  10813. * @param scene Define the scene the texture belongs to
  10814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10818. * @returns the RGB alpha texture
  10819. */
  10820. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10821. /**
  10822. * Creates a RGBA texture from some data.
  10823. * @param data Define the texture data
  10824. * @param width Define the width of the texture
  10825. * @param height Define the height of the texture
  10826. * @param scene Define the scene the texture belongs to
  10827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10830. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10831. * @returns the RGBA texture
  10832. */
  10833. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10834. /**
  10835. * Creates a R texture from some data.
  10836. * @param data Define the texture data
  10837. * @param width Define the width of the texture
  10838. * @param height Define the height of the texture
  10839. * @param scene Define the scene the texture belongs to
  10840. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10841. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10842. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10843. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10844. * @returns the R texture
  10845. */
  10846. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10847. }
  10848. }
  10849. declare module BABYLON {
  10850. interface AbstractScene {
  10851. /**
  10852. * The list of procedural textures added to the scene
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10854. */
  10855. proceduralTextures: Array<ProceduralTexture>;
  10856. }
  10857. /**
  10858. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10859. * in a given scene.
  10860. */
  10861. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10862. /**
  10863. * The component name helpfull to identify the component in the list of scene components.
  10864. */
  10865. readonly name: string;
  10866. /**
  10867. * The scene the component belongs to.
  10868. */
  10869. scene: Scene;
  10870. /**
  10871. * Creates a new instance of the component for the given scene
  10872. * @param scene Defines the scene to register the component in
  10873. */
  10874. constructor(scene: Scene);
  10875. /**
  10876. * Registers the component in a given scene
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. private _beforeClear;
  10889. }
  10890. }
  10891. declare module BABYLON {
  10892. interface ThinEngine {
  10893. /**
  10894. * Creates a new render target cube texture
  10895. * @param size defines the size of the texture
  10896. * @param options defines the options used to create the texture
  10897. * @returns a new render target cube texture stored in an InternalTexture
  10898. */
  10899. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10900. }
  10901. }
  10902. declare module BABYLON {
  10903. /** @hidden */
  10904. export var proceduralVertexShader: {
  10905. name: string;
  10906. shader: string;
  10907. };
  10908. }
  10909. declare module BABYLON {
  10910. /**
  10911. * 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.
  10912. * This is the base class of any Procedural texture and contains most of the shareable code.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10914. */
  10915. export class ProceduralTexture extends Texture {
  10916. isCube: boolean;
  10917. /**
  10918. * Define if the texture is enabled or not (disabled texture will not render)
  10919. */
  10920. isEnabled: boolean;
  10921. /**
  10922. * Define if the texture must be cleared before rendering (default is true)
  10923. */
  10924. autoClear: boolean;
  10925. /**
  10926. * Callback called when the texture is generated
  10927. */
  10928. onGenerated: () => void;
  10929. /**
  10930. * Event raised when the texture is generated
  10931. */
  10932. onGeneratedObservable: Observable<ProceduralTexture>;
  10933. /** @hidden */
  10934. _generateMipMaps: boolean;
  10935. /** @hidden **/
  10936. _effect: Effect;
  10937. /** @hidden */
  10938. _textures: {
  10939. [key: string]: Texture;
  10940. };
  10941. /** @hidden */
  10942. protected _fallbackTexture: Nullable<Texture>;
  10943. private _size;
  10944. private _currentRefreshId;
  10945. private _frameId;
  10946. private _refreshRate;
  10947. private _vertexBuffers;
  10948. private _indexBuffer;
  10949. private _uniforms;
  10950. private _samplers;
  10951. private _fragment;
  10952. private _floats;
  10953. private _ints;
  10954. private _floatsArrays;
  10955. private _colors3;
  10956. private _colors4;
  10957. private _vectors2;
  10958. private _vectors3;
  10959. private _matrices;
  10960. private _fallbackTextureUsed;
  10961. private _fullEngine;
  10962. private _cachedDefines;
  10963. private _contentUpdateId;
  10964. private _contentData;
  10965. /**
  10966. * Instantiates a new procedural texture.
  10967. * 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.
  10968. * This is the base class of any Procedural texture and contains most of the shareable code.
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10970. * @param name Define the name of the texture
  10971. * @param size Define the size of the texture to create
  10972. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10973. * @param scene Define the scene the texture belongs to
  10974. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10975. * @param generateMipMaps Define if the texture should creates mip maps or not
  10976. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10977. */
  10978. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10979. /**
  10980. * The effect that is created when initializing the post process.
  10981. * @returns The created effect corresponding the the postprocess.
  10982. */
  10983. getEffect(): Effect;
  10984. /**
  10985. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10986. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10987. */
  10988. getContent(): Nullable<ArrayBufferView>;
  10989. private _createIndexBuffer;
  10990. /** @hidden */
  10991. _rebuild(): void;
  10992. /**
  10993. * Resets the texture in order to recreate its associated resources.
  10994. * This can be called in case of context loss
  10995. */
  10996. reset(): void;
  10997. protected _getDefines(): string;
  10998. /**
  10999. * Is the texture ready to be used ? (rendered at least once)
  11000. * @returns true if ready, otherwise, false.
  11001. */
  11002. isReady(): boolean;
  11003. /**
  11004. * Resets the refresh counter of the texture and start bak from scratch.
  11005. * Could be useful to regenerate the texture if it is setup to render only once.
  11006. */
  11007. resetRefreshCounter(): void;
  11008. /**
  11009. * Set the fragment shader to use in order to render the texture.
  11010. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11011. */
  11012. setFragment(fragment: any): void;
  11013. /**
  11014. * Define the refresh rate of the texture or the rendering frequency.
  11015. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11016. */
  11017. get refreshRate(): number;
  11018. set refreshRate(value: number);
  11019. /** @hidden */
  11020. _shouldRender(): boolean;
  11021. /**
  11022. * Get the size the texture is rendering at.
  11023. * @returns the size (texture is always squared)
  11024. */
  11025. getRenderSize(): number;
  11026. /**
  11027. * Resize the texture to new value.
  11028. * @param size Define the new size the texture should have
  11029. * @param generateMipMaps Define whether the new texture should create mip maps
  11030. */
  11031. resize(size: number, generateMipMaps: boolean): void;
  11032. private _checkUniform;
  11033. /**
  11034. * Set a texture in the shader program used to render.
  11035. * @param name Define the name of the uniform samplers as defined in the shader
  11036. * @param texture Define the texture to bind to this sampler
  11037. * @return the texture itself allowing "fluent" like uniform updates
  11038. */
  11039. setTexture(name: string, texture: Texture): ProceduralTexture;
  11040. /**
  11041. * Set a float in the shader.
  11042. * @param name Define the name of the uniform as defined in the shader
  11043. * @param value Define the value to give to the uniform
  11044. * @return the texture itself allowing "fluent" like uniform updates
  11045. */
  11046. setFloat(name: string, value: number): ProceduralTexture;
  11047. /**
  11048. * Set a int in the shader.
  11049. * @param name Define the name of the uniform as defined in the shader
  11050. * @param value Define the value to give to the uniform
  11051. * @return the texture itself allowing "fluent" like uniform updates
  11052. */
  11053. setInt(name: string, value: number): ProceduralTexture;
  11054. /**
  11055. * Set an array of floats in the shader.
  11056. * @param name Define the name of the uniform as defined in the shader
  11057. * @param value Define the value to give to the uniform
  11058. * @return the texture itself allowing "fluent" like uniform updates
  11059. */
  11060. setFloats(name: string, value: number[]): ProceduralTexture;
  11061. /**
  11062. * Set a vec3 in the shader from a Color3.
  11063. * @param name Define the name of the uniform as defined in the shader
  11064. * @param value Define the value to give to the uniform
  11065. * @return the texture itself allowing "fluent" like uniform updates
  11066. */
  11067. setColor3(name: string, value: Color3): ProceduralTexture;
  11068. /**
  11069. * Set a vec4 in the shader from a Color4.
  11070. * @param name Define the name of the uniform as defined in the shader
  11071. * @param value Define the value to give to the uniform
  11072. * @return the texture itself allowing "fluent" like uniform updates
  11073. */
  11074. setColor4(name: string, value: Color4): ProceduralTexture;
  11075. /**
  11076. * Set a vec2 in the shader from a Vector2.
  11077. * @param name Define the name of the uniform as defined in the shader
  11078. * @param value Define the value to give to the uniform
  11079. * @return the texture itself allowing "fluent" like uniform updates
  11080. */
  11081. setVector2(name: string, value: Vector2): ProceduralTexture;
  11082. /**
  11083. * Set a vec3 in the shader from a Vector3.
  11084. * @param name Define the name of the uniform as defined in the shader
  11085. * @param value Define the value to give to the uniform
  11086. * @return the texture itself allowing "fluent" like uniform updates
  11087. */
  11088. setVector3(name: string, value: Vector3): ProceduralTexture;
  11089. /**
  11090. * Set a mat4 in the shader from a MAtrix.
  11091. * @param name Define the name of the uniform as defined in the shader
  11092. * @param value Define the value to give to the uniform
  11093. * @return the texture itself allowing "fluent" like uniform updates
  11094. */
  11095. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11096. /**
  11097. * Render the texture to its associated render target.
  11098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11099. */
  11100. render(useCameraPostProcess?: boolean): void;
  11101. /**
  11102. * Clone the texture.
  11103. * @returns the cloned texture
  11104. */
  11105. clone(): ProceduralTexture;
  11106. /**
  11107. * Dispose the texture and release its asoociated resources.
  11108. */
  11109. dispose(): void;
  11110. }
  11111. }
  11112. declare module BABYLON {
  11113. /**
  11114. * This represents the base class for particle system in Babylon.
  11115. * 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.
  11116. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11117. * @example https://doc.babylonjs.com/babylon101/particles
  11118. */
  11119. export class BaseParticleSystem {
  11120. /**
  11121. * Source color is added to the destination color without alpha affecting the result
  11122. */
  11123. static BLENDMODE_ONEONE: number;
  11124. /**
  11125. * Blend current color and particle color using particle’s alpha
  11126. */
  11127. static BLENDMODE_STANDARD: number;
  11128. /**
  11129. * Add current color and particle color multiplied by particle’s alpha
  11130. */
  11131. static BLENDMODE_ADD: number;
  11132. /**
  11133. * Multiply current color with particle color
  11134. */
  11135. static BLENDMODE_MULTIPLY: number;
  11136. /**
  11137. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11138. */
  11139. static BLENDMODE_MULTIPLYADD: number;
  11140. /**
  11141. * List of animations used by the particle system.
  11142. */
  11143. animations: Animation[];
  11144. /**
  11145. * Gets or sets the unique id of the particle system
  11146. */
  11147. uniqueId: number;
  11148. /**
  11149. * The id of the Particle system.
  11150. */
  11151. id: string;
  11152. /**
  11153. * The friendly name of the Particle system.
  11154. */
  11155. name: string;
  11156. /**
  11157. * Snippet ID if the particle system was created from the snippet server
  11158. */
  11159. snippetId: string;
  11160. /**
  11161. * The rendering group used by the Particle system to chose when to render.
  11162. */
  11163. renderingGroupId: number;
  11164. /**
  11165. * The emitter represents the Mesh or position we are attaching the particle system to.
  11166. */
  11167. emitter: Nullable<AbstractMesh | Vector3>;
  11168. /**
  11169. * The maximum number of particles to emit per frame
  11170. */
  11171. emitRate: number;
  11172. /**
  11173. * If you want to launch only a few particles at once, that can be done, as well.
  11174. */
  11175. manualEmitCount: number;
  11176. /**
  11177. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11178. */
  11179. updateSpeed: number;
  11180. /**
  11181. * The amount of time the particle system is running (depends of the overall update speed).
  11182. */
  11183. targetStopDuration: number;
  11184. /**
  11185. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11186. */
  11187. disposeOnStop: boolean;
  11188. /**
  11189. * Minimum power of emitting particles.
  11190. */
  11191. minEmitPower: number;
  11192. /**
  11193. * Maximum power of emitting particles.
  11194. */
  11195. maxEmitPower: number;
  11196. /**
  11197. * Minimum life time of emitting particles.
  11198. */
  11199. minLifeTime: number;
  11200. /**
  11201. * Maximum life time of emitting particles.
  11202. */
  11203. maxLifeTime: number;
  11204. /**
  11205. * Minimum Size of emitting particles.
  11206. */
  11207. minSize: number;
  11208. /**
  11209. * Maximum Size of emitting particles.
  11210. */
  11211. maxSize: number;
  11212. /**
  11213. * Minimum scale of emitting particles on X axis.
  11214. */
  11215. minScaleX: number;
  11216. /**
  11217. * Maximum scale of emitting particles on X axis.
  11218. */
  11219. maxScaleX: number;
  11220. /**
  11221. * Minimum scale of emitting particles on Y axis.
  11222. */
  11223. minScaleY: number;
  11224. /**
  11225. * Maximum scale of emitting particles on Y axis.
  11226. */
  11227. maxScaleY: number;
  11228. /**
  11229. * Gets or sets the minimal initial rotation in radians.
  11230. */
  11231. minInitialRotation: number;
  11232. /**
  11233. * Gets or sets the maximal initial rotation in radians.
  11234. */
  11235. maxInitialRotation: number;
  11236. /**
  11237. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11238. */
  11239. minAngularSpeed: number;
  11240. /**
  11241. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11242. */
  11243. maxAngularSpeed: number;
  11244. /**
  11245. * The texture used to render each particle. (this can be a spritesheet)
  11246. */
  11247. particleTexture: Nullable<Texture>;
  11248. /**
  11249. * The layer mask we are rendering the particles through.
  11250. */
  11251. layerMask: number;
  11252. /**
  11253. * This can help using your own shader to render the particle system.
  11254. * The according effect will be created
  11255. */
  11256. customShader: any;
  11257. /**
  11258. * By default particle system starts as soon as they are created. This prevents the
  11259. * automatic start to happen and let you decide when to start emitting particles.
  11260. */
  11261. preventAutoStart: boolean;
  11262. private _noiseTexture;
  11263. /**
  11264. * Gets or sets a texture used to add random noise to particle positions
  11265. */
  11266. get noiseTexture(): Nullable<ProceduralTexture>;
  11267. set noiseTexture(value: Nullable<ProceduralTexture>);
  11268. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11269. noiseStrength: Vector3;
  11270. /**
  11271. * Callback triggered when the particle animation is ending.
  11272. */
  11273. onAnimationEnd: Nullable<() => void>;
  11274. /**
  11275. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11276. */
  11277. blendMode: number;
  11278. /**
  11279. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11280. * to override the particles.
  11281. */
  11282. forceDepthWrite: boolean;
  11283. /** 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 */
  11284. preWarmCycles: number;
  11285. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11286. preWarmStepOffset: number;
  11287. /**
  11288. * 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)
  11289. */
  11290. spriteCellChangeSpeed: number;
  11291. /**
  11292. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11293. */
  11294. startSpriteCellID: number;
  11295. /**
  11296. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11297. */
  11298. endSpriteCellID: number;
  11299. /**
  11300. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11301. */
  11302. spriteCellWidth: number;
  11303. /**
  11304. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11305. */
  11306. spriteCellHeight: number;
  11307. /**
  11308. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11309. */
  11310. spriteRandomStartCell: boolean;
  11311. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11312. translationPivot: Vector2;
  11313. /** @hidden */
  11314. protected _isAnimationSheetEnabled: boolean;
  11315. /**
  11316. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11317. */
  11318. beginAnimationOnStart: boolean;
  11319. /**
  11320. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11321. */
  11322. beginAnimationFrom: number;
  11323. /**
  11324. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11325. */
  11326. beginAnimationTo: number;
  11327. /**
  11328. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11329. */
  11330. beginAnimationLoop: boolean;
  11331. /**
  11332. * Gets or sets a world offset applied to all particles
  11333. */
  11334. worldOffset: Vector3;
  11335. /**
  11336. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11337. */
  11338. get isAnimationSheetEnabled(): boolean;
  11339. set isAnimationSheetEnabled(value: boolean);
  11340. /**
  11341. * Get hosting scene
  11342. * @returns the scene
  11343. */
  11344. getScene(): Scene;
  11345. /**
  11346. * You can use gravity if you want to give an orientation to your particles.
  11347. */
  11348. gravity: Vector3;
  11349. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11350. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11351. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11352. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11353. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11354. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11355. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11356. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11357. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11358. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11359. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11360. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11361. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11362. /**
  11363. * Defines the delay in milliseconds before starting the system (0 by default)
  11364. */
  11365. startDelay: number;
  11366. /**
  11367. * Gets the current list of drag gradients.
  11368. * You must use addDragGradient and removeDragGradient to udpate this list
  11369. * @returns the list of drag gradients
  11370. */
  11371. getDragGradients(): Nullable<Array<FactorGradient>>;
  11372. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11373. limitVelocityDamping: number;
  11374. /**
  11375. * Gets the current list of limit velocity gradients.
  11376. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11377. * @returns the list of limit velocity gradients
  11378. */
  11379. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11380. /**
  11381. * Gets the current list of color gradients.
  11382. * You must use addColorGradient and removeColorGradient to udpate this list
  11383. * @returns the list of color gradients
  11384. */
  11385. getColorGradients(): Nullable<Array<ColorGradient>>;
  11386. /**
  11387. * Gets the current list of size gradients.
  11388. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11389. * @returns the list of size gradients
  11390. */
  11391. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11392. /**
  11393. * Gets the current list of color remap gradients.
  11394. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11395. * @returns the list of color remap gradients
  11396. */
  11397. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11398. /**
  11399. * Gets the current list of alpha remap gradients.
  11400. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11401. * @returns the list of alpha remap gradients
  11402. */
  11403. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11404. /**
  11405. * Gets the current list of life time gradients.
  11406. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11407. * @returns the list of life time gradients
  11408. */
  11409. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11410. /**
  11411. * Gets the current list of angular speed gradients.
  11412. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11413. * @returns the list of angular speed gradients
  11414. */
  11415. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11416. /**
  11417. * Gets the current list of velocity gradients.
  11418. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11419. * @returns the list of velocity gradients
  11420. */
  11421. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11422. /**
  11423. * Gets the current list of start size gradients.
  11424. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11425. * @returns the list of start size gradients
  11426. */
  11427. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11428. /**
  11429. * Gets the current list of emit rate gradients.
  11430. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11431. * @returns the list of emit rate gradients
  11432. */
  11433. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11434. /**
  11435. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11437. */
  11438. get direction1(): Vector3;
  11439. set direction1(value: Vector3);
  11440. /**
  11441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11443. */
  11444. get direction2(): Vector3;
  11445. set direction2(value: Vector3);
  11446. /**
  11447. * 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.
  11448. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11449. */
  11450. get minEmitBox(): Vector3;
  11451. set minEmitBox(value: Vector3);
  11452. /**
  11453. * 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.
  11454. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11455. */
  11456. get maxEmitBox(): Vector3;
  11457. set maxEmitBox(value: Vector3);
  11458. /**
  11459. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11460. */
  11461. color1: Color4;
  11462. /**
  11463. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11464. */
  11465. color2: Color4;
  11466. /**
  11467. * Color the particle will have at the end of its lifetime
  11468. */
  11469. colorDead: Color4;
  11470. /**
  11471. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11472. */
  11473. textureMask: Color4;
  11474. /**
  11475. * The particle emitter type defines the emitter used by the particle system.
  11476. * It can be for example box, sphere, or cone...
  11477. */
  11478. particleEmitterType: IParticleEmitterType;
  11479. /** @hidden */
  11480. _isSubEmitter: boolean;
  11481. /**
  11482. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11483. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11484. */
  11485. billboardMode: number;
  11486. protected _isBillboardBased: boolean;
  11487. /**
  11488. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11489. */
  11490. get isBillboardBased(): boolean;
  11491. set isBillboardBased(value: boolean);
  11492. /**
  11493. * The scene the particle system belongs to.
  11494. */
  11495. protected _scene: Scene;
  11496. /**
  11497. * Local cache of defines for image processing.
  11498. */
  11499. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11500. /**
  11501. * Default configuration related to image processing available in the standard Material.
  11502. */
  11503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11504. /**
  11505. * Gets the image processing configuration used either in this material.
  11506. */
  11507. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11508. /**
  11509. * Sets the Default image processing configuration used either in the this material.
  11510. *
  11511. * If sets to null, the scene one is in use.
  11512. */
  11513. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11514. /**
  11515. * Attaches a new image processing configuration to the Standard Material.
  11516. * @param configuration
  11517. */
  11518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11519. /** @hidden */
  11520. protected _reset(): void;
  11521. /** @hidden */
  11522. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11523. /**
  11524. * Instantiates a particle system.
  11525. * 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.
  11526. * @param name The name of the particle system
  11527. */
  11528. constructor(name: string);
  11529. /**
  11530. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11533. * @returns the emitter
  11534. */
  11535. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11536. /**
  11537. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11538. * @param radius The radius of the hemisphere to emit from
  11539. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11540. * @returns the emitter
  11541. */
  11542. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11543. /**
  11544. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11545. * @param radius The radius of the sphere to emit from
  11546. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11547. * @returns the emitter
  11548. */
  11549. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11550. /**
  11551. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11552. * @param radius The radius of the sphere to emit from
  11553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11555. * @returns the emitter
  11556. */
  11557. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11558. /**
  11559. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11560. * @param radius The radius of the emission cylinder
  11561. * @param height The height of the emission cylinder
  11562. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11563. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11564. * @returns the emitter
  11565. */
  11566. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11567. /**
  11568. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11569. * @param radius The radius of the cylinder to emit from
  11570. * @param height The height of the emission cylinder
  11571. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11574. * @returns the emitter
  11575. */
  11576. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11577. /**
  11578. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11579. * @param radius The radius of the cone to emit from
  11580. * @param angle The base angle of the cone
  11581. * @returns the emitter
  11582. */
  11583. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11584. /**
  11585. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11588. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11589. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11590. * @returns the emitter
  11591. */
  11592. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /**
  11597. * Type of sub emitter
  11598. */
  11599. export enum SubEmitterType {
  11600. /**
  11601. * Attached to the particle over it's lifetime
  11602. */
  11603. ATTACHED = 0,
  11604. /**
  11605. * Created when the particle dies
  11606. */
  11607. END = 1
  11608. }
  11609. /**
  11610. * Sub emitter class used to emit particles from an existing particle
  11611. */
  11612. export class SubEmitter {
  11613. /**
  11614. * the particle system to be used by the sub emitter
  11615. */
  11616. particleSystem: ParticleSystem;
  11617. /**
  11618. * Type of the submitter (Default: END)
  11619. */
  11620. type: SubEmitterType;
  11621. /**
  11622. * 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)
  11623. * Note: This only is supported when using an emitter of type Mesh
  11624. */
  11625. inheritDirection: boolean;
  11626. /**
  11627. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11628. */
  11629. inheritedVelocityAmount: number;
  11630. /**
  11631. * Creates a sub emitter
  11632. * @param particleSystem the particle system to be used by the sub emitter
  11633. */
  11634. constructor(
  11635. /**
  11636. * the particle system to be used by the sub emitter
  11637. */
  11638. particleSystem: ParticleSystem);
  11639. /**
  11640. * Clones the sub emitter
  11641. * @returns the cloned sub emitter
  11642. */
  11643. clone(): SubEmitter;
  11644. /**
  11645. * Serialize current object to a JSON object
  11646. * @returns the serialized object
  11647. */
  11648. serialize(): any;
  11649. /** @hidden */
  11650. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11651. /**
  11652. * Creates a new SubEmitter from a serialized JSON version
  11653. * @param serializationObject defines the JSON object to read from
  11654. * @param scene defines the hosting scene
  11655. * @param rootUrl defines the rootUrl for data loading
  11656. * @returns a new SubEmitter
  11657. */
  11658. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11659. /** Release associated resources */
  11660. dispose(): void;
  11661. }
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var imageProcessingDeclaration: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /** @hidden */
  11672. export var imageProcessingFunctions: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module BABYLON {
  11678. /** @hidden */
  11679. export var particlesPixelShader: {
  11680. name: string;
  11681. shader: string;
  11682. };
  11683. }
  11684. declare module BABYLON {
  11685. /** @hidden */
  11686. export var particlesVertexShader: {
  11687. name: string;
  11688. shader: string;
  11689. };
  11690. }
  11691. declare module BABYLON {
  11692. /**
  11693. * This represents a particle system in Babylon.
  11694. * 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.
  11695. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11696. * @example https://doc.babylonjs.com/babylon101/particles
  11697. */
  11698. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11699. /**
  11700. * Billboard mode will only apply to Y axis
  11701. */
  11702. static readonly BILLBOARDMODE_Y: number;
  11703. /**
  11704. * Billboard mode will apply to all axes
  11705. */
  11706. static readonly BILLBOARDMODE_ALL: number;
  11707. /**
  11708. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11709. */
  11710. static readonly BILLBOARDMODE_STRETCHED: number;
  11711. /**
  11712. * This function can be defined to provide custom update for active particles.
  11713. * This function will be called instead of regular update (age, position, color, etc.).
  11714. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11715. */
  11716. updateFunction: (particles: Particle[]) => void;
  11717. private _emitterWorldMatrix;
  11718. /**
  11719. * This function can be defined to specify initial direction for every new particle.
  11720. * It by default use the emitterType defined function
  11721. */
  11722. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11723. /**
  11724. * This function can be defined to specify initial position for every new particle.
  11725. * It by default use the emitterType defined function
  11726. */
  11727. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11728. /**
  11729. * @hidden
  11730. */
  11731. _inheritedVelocityOffset: Vector3;
  11732. /**
  11733. * An event triggered when the system is disposed
  11734. */
  11735. onDisposeObservable: Observable<ParticleSystem>;
  11736. private _onDisposeObserver;
  11737. /**
  11738. * Sets a callback that will be triggered when the system is disposed
  11739. */
  11740. set onDispose(callback: () => void);
  11741. private _particles;
  11742. private _epsilon;
  11743. private _capacity;
  11744. private _stockParticles;
  11745. private _newPartsExcess;
  11746. private _vertexData;
  11747. private _vertexBuffer;
  11748. private _vertexBuffers;
  11749. private _spriteBuffer;
  11750. private _indexBuffer;
  11751. private _effect;
  11752. private _customEffect;
  11753. private _cachedDefines;
  11754. private _scaledColorStep;
  11755. private _colorDiff;
  11756. private _scaledDirection;
  11757. private _scaledGravity;
  11758. private _currentRenderId;
  11759. private _alive;
  11760. private _useInstancing;
  11761. private _started;
  11762. private _stopped;
  11763. private _actualFrame;
  11764. private _scaledUpdateSpeed;
  11765. private _vertexBufferSize;
  11766. /** @hidden */
  11767. _currentEmitRateGradient: Nullable<FactorGradient>;
  11768. /** @hidden */
  11769. _currentEmitRate1: number;
  11770. /** @hidden */
  11771. _currentEmitRate2: number;
  11772. /** @hidden */
  11773. _currentStartSizeGradient: Nullable<FactorGradient>;
  11774. /** @hidden */
  11775. _currentStartSize1: number;
  11776. /** @hidden */
  11777. _currentStartSize2: number;
  11778. private readonly _rawTextureWidth;
  11779. private _rampGradientsTexture;
  11780. private _useRampGradients;
  11781. /** Gets or sets a boolean indicating that ramp gradients must be used
  11782. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11783. */
  11784. get useRampGradients(): boolean;
  11785. set useRampGradients(value: boolean);
  11786. /**
  11787. * 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.
  11788. * 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: [])
  11789. */
  11790. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11791. private _subEmitters;
  11792. /**
  11793. * @hidden
  11794. * If the particle systems emitter should be disposed when the particle system is disposed
  11795. */
  11796. _disposeEmitterOnDispose: boolean;
  11797. /**
  11798. * The current active Sub-systems, this property is used by the root particle system only.
  11799. */
  11800. activeSubSystems: Array<ParticleSystem>;
  11801. /**
  11802. * Specifies if the particles are updated in emitter local space or world space
  11803. */
  11804. isLocal: boolean;
  11805. private _rootParticleSystem;
  11806. /**
  11807. * Gets the current list of active particles
  11808. */
  11809. get particles(): Particle[];
  11810. /**
  11811. * Gets the number of particles active at the same time.
  11812. * @returns The number of active particles.
  11813. */
  11814. getActiveCount(): number;
  11815. /**
  11816. * Returns the string "ParticleSystem"
  11817. * @returns a string containing the class name
  11818. */
  11819. getClassName(): string;
  11820. /**
  11821. * Gets a boolean indicating that the system is stopping
  11822. * @returns true if the system is currently stopping
  11823. */
  11824. isStopping(): boolean;
  11825. /**
  11826. * Instantiates a particle system.
  11827. * 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.
  11828. * @param name The name of the particle system
  11829. * @param capacity The max number of particles alive at the same time
  11830. * @param scene The scene the particle system belongs to
  11831. * @param customEffect a custom effect used to change the way particles are rendered by default
  11832. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11833. * @param epsilon Offset used to render the particles
  11834. */
  11835. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11836. private _addFactorGradient;
  11837. private _removeFactorGradient;
  11838. /**
  11839. * Adds a new life time gradient
  11840. * @param gradient defines the gradient to use (between 0 and 1)
  11841. * @param factor defines the life time factor to affect to the specified gradient
  11842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11843. * @returns the current particle system
  11844. */
  11845. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11846. /**
  11847. * Remove a specific life time gradient
  11848. * @param gradient defines the gradient to remove
  11849. * @returns the current particle system
  11850. */
  11851. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11852. /**
  11853. * Adds a new size gradient
  11854. * @param gradient defines the gradient to use (between 0 and 1)
  11855. * @param factor defines the size factor to affect to the specified gradient
  11856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11857. * @returns the current particle system
  11858. */
  11859. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11860. /**
  11861. * Remove a specific size gradient
  11862. * @param gradient defines the gradient to remove
  11863. * @returns the current particle system
  11864. */
  11865. removeSizeGradient(gradient: number): IParticleSystem;
  11866. /**
  11867. * Adds a new color remap gradient
  11868. * @param gradient defines the gradient to use (between 0 and 1)
  11869. * @param min defines the color remap minimal range
  11870. * @param max defines the color remap maximal range
  11871. * @returns the current particle system
  11872. */
  11873. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11874. /**
  11875. * Remove a specific color remap gradient
  11876. * @param gradient defines the gradient to remove
  11877. * @returns the current particle system
  11878. */
  11879. removeColorRemapGradient(gradient: number): IParticleSystem;
  11880. /**
  11881. * Adds a new alpha remap gradient
  11882. * @param gradient defines the gradient to use (between 0 and 1)
  11883. * @param min defines the alpha remap minimal range
  11884. * @param max defines the alpha remap maximal range
  11885. * @returns the current particle system
  11886. */
  11887. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11888. /**
  11889. * Remove a specific alpha remap gradient
  11890. * @param gradient defines the gradient to remove
  11891. * @returns the current particle system
  11892. */
  11893. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11894. /**
  11895. * Adds a new angular speed gradient
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param factor defines the angular speed to affect to the specified gradient
  11898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11899. * @returns the current particle system
  11900. */
  11901. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11902. /**
  11903. * Remove a specific angular speed gradient
  11904. * @param gradient defines the gradient to remove
  11905. * @returns the current particle system
  11906. */
  11907. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11908. /**
  11909. * Adds a new velocity gradient
  11910. * @param gradient defines the gradient to use (between 0 and 1)
  11911. * @param factor defines the velocity to affect to the specified gradient
  11912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11913. * @returns the current particle system
  11914. */
  11915. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11916. /**
  11917. * Remove a specific velocity gradient
  11918. * @param gradient defines the gradient to remove
  11919. * @returns the current particle system
  11920. */
  11921. removeVelocityGradient(gradient: number): IParticleSystem;
  11922. /**
  11923. * Adds a new limit velocity gradient
  11924. * @param gradient defines the gradient to use (between 0 and 1)
  11925. * @param factor defines the limit velocity value to affect to the specified gradient
  11926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11927. * @returns the current particle system
  11928. */
  11929. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11930. /**
  11931. * Remove a specific limit velocity gradient
  11932. * @param gradient defines the gradient to remove
  11933. * @returns the current particle system
  11934. */
  11935. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11936. /**
  11937. * Adds a new drag gradient
  11938. * @param gradient defines the gradient to use (between 0 and 1)
  11939. * @param factor defines the drag value to affect to the specified gradient
  11940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11941. * @returns the current particle system
  11942. */
  11943. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11944. /**
  11945. * Remove a specific drag gradient
  11946. * @param gradient defines the gradient to remove
  11947. * @returns the current particle system
  11948. */
  11949. removeDragGradient(gradient: number): IParticleSystem;
  11950. /**
  11951. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11952. * @param gradient defines the gradient to use (between 0 and 1)
  11953. * @param factor defines the emit rate value to affect to the specified gradient
  11954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11955. * @returns the current particle system
  11956. */
  11957. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11958. /**
  11959. * Remove a specific emit rate gradient
  11960. * @param gradient defines the gradient to remove
  11961. * @returns the current particle system
  11962. */
  11963. removeEmitRateGradient(gradient: number): IParticleSystem;
  11964. /**
  11965. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11966. * @param gradient defines the gradient to use (between 0 and 1)
  11967. * @param factor defines the start size value to affect to the specified gradient
  11968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11969. * @returns the current particle system
  11970. */
  11971. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11972. /**
  11973. * Remove a specific start size gradient
  11974. * @param gradient defines the gradient to remove
  11975. * @returns the current particle system
  11976. */
  11977. removeStartSizeGradient(gradient: number): IParticleSystem;
  11978. private _createRampGradientTexture;
  11979. /**
  11980. * Gets the current list of ramp gradients.
  11981. * You must use addRampGradient and removeRampGradient to udpate this list
  11982. * @returns the list of ramp gradients
  11983. */
  11984. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11985. /** Force the system to rebuild all gradients that need to be resync */
  11986. forceRefreshGradients(): void;
  11987. private _syncRampGradientTexture;
  11988. /**
  11989. * Adds a new ramp gradient used to remap particle colors
  11990. * @param gradient defines the gradient to use (between 0 and 1)
  11991. * @param color defines the color to affect to the specified gradient
  11992. * @returns the current particle system
  11993. */
  11994. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11995. /**
  11996. * Remove a specific ramp gradient
  11997. * @param gradient defines the gradient to remove
  11998. * @returns the current particle system
  11999. */
  12000. removeRampGradient(gradient: number): ParticleSystem;
  12001. /**
  12002. * Adds a new color gradient
  12003. * @param gradient defines the gradient to use (between 0 and 1)
  12004. * @param color1 defines the color to affect to the specified gradient
  12005. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12006. * @returns this particle system
  12007. */
  12008. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12009. /**
  12010. * Remove a specific color gradient
  12011. * @param gradient defines the gradient to remove
  12012. * @returns this particle system
  12013. */
  12014. removeColorGradient(gradient: number): IParticleSystem;
  12015. private _fetchR;
  12016. protected _reset(): void;
  12017. private _resetEffect;
  12018. private _createVertexBuffers;
  12019. private _createIndexBuffer;
  12020. /**
  12021. * Gets the maximum number of particles active at the same time.
  12022. * @returns The max number of active particles.
  12023. */
  12024. getCapacity(): number;
  12025. /**
  12026. * Gets whether there are still active particles in the system.
  12027. * @returns True if it is alive, otherwise false.
  12028. */
  12029. isAlive(): boolean;
  12030. /**
  12031. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12032. * @returns True if it has been started, otherwise false.
  12033. */
  12034. isStarted(): boolean;
  12035. private _prepareSubEmitterInternalArray;
  12036. /**
  12037. * Starts the particle system and begins to emit
  12038. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12039. */
  12040. start(delay?: number): void;
  12041. /**
  12042. * Stops the particle system.
  12043. * @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.
  12044. */
  12045. stop(stopSubEmitters?: boolean): void;
  12046. /**
  12047. * Remove all active particles
  12048. */
  12049. reset(): void;
  12050. /**
  12051. * @hidden (for internal use only)
  12052. */
  12053. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12054. /**
  12055. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12056. * Its lifetime will start back at 0.
  12057. */
  12058. recycleParticle: (particle: Particle) => void;
  12059. private _stopSubEmitters;
  12060. private _createParticle;
  12061. private _removeFromRoot;
  12062. private _emitFromParticle;
  12063. private _update;
  12064. /** @hidden */
  12065. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12066. /** @hidden */
  12067. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12068. /** @hidden */
  12069. private _getEffect;
  12070. /**
  12071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12073. */
  12074. animate(preWarmOnly?: boolean): void;
  12075. private _appendParticleVertices;
  12076. /**
  12077. * Rebuilds the particle system.
  12078. */
  12079. rebuild(): void;
  12080. /**
  12081. * Is this system ready to be used/rendered
  12082. * @return true if the system is ready
  12083. */
  12084. isReady(): boolean;
  12085. private _render;
  12086. /**
  12087. * Renders the particle system in its current state.
  12088. * @returns the current number of particles
  12089. */
  12090. render(): number;
  12091. /**
  12092. * Disposes the particle system and free the associated resources
  12093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12094. */
  12095. dispose(disposeTexture?: boolean): void;
  12096. /**
  12097. * Clones the particle system.
  12098. * @param name The name of the cloned object
  12099. * @param newEmitter The new emitter to use
  12100. * @returns the cloned particle system
  12101. */
  12102. clone(name: string, newEmitter: any): ParticleSystem;
  12103. /**
  12104. * Serializes the particle system to a JSON object
  12105. * @param serializeTexture defines if the texture must be serialized as well
  12106. * @returns the JSON object
  12107. */
  12108. serialize(serializeTexture?: boolean): any;
  12109. /** @hidden */
  12110. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12111. /** @hidden */
  12112. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12113. /**
  12114. * Parses a JSON object to create a particle system.
  12115. * @param parsedParticleSystem The JSON object to parse
  12116. * @param scene The scene to create the particle system in
  12117. * @param rootUrl The root url to use to load external dependencies like texture
  12118. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12119. * @returns the Parsed particle system
  12120. */
  12121. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12122. }
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * A particle represents one of the element emitted by a particle system.
  12127. * This is mainly define by its coordinates, direction, velocity and age.
  12128. */
  12129. export class Particle {
  12130. /**
  12131. * The particle system the particle belongs to.
  12132. */
  12133. particleSystem: ParticleSystem;
  12134. private static _Count;
  12135. /**
  12136. * Unique ID of the particle
  12137. */
  12138. id: number;
  12139. /**
  12140. * The world position of the particle in the scene.
  12141. */
  12142. position: Vector3;
  12143. /**
  12144. * The world direction of the particle in the scene.
  12145. */
  12146. direction: Vector3;
  12147. /**
  12148. * The color of the particle.
  12149. */
  12150. color: Color4;
  12151. /**
  12152. * The color change of the particle per step.
  12153. */
  12154. colorStep: Color4;
  12155. /**
  12156. * Defines how long will the life of the particle be.
  12157. */
  12158. lifeTime: number;
  12159. /**
  12160. * The current age of the particle.
  12161. */
  12162. age: number;
  12163. /**
  12164. * The current size of the particle.
  12165. */
  12166. size: number;
  12167. /**
  12168. * The current scale of the particle.
  12169. */
  12170. scale: Vector2;
  12171. /**
  12172. * The current angle of the particle.
  12173. */
  12174. angle: number;
  12175. /**
  12176. * Defines how fast is the angle changing.
  12177. */
  12178. angularSpeed: number;
  12179. /**
  12180. * Defines the cell index used by the particle to be rendered from a sprite.
  12181. */
  12182. cellIndex: number;
  12183. /**
  12184. * The information required to support color remapping
  12185. */
  12186. remapData: Vector4;
  12187. /** @hidden */
  12188. _randomCellOffset?: number;
  12189. /** @hidden */
  12190. _initialDirection: Nullable<Vector3>;
  12191. /** @hidden */
  12192. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12193. /** @hidden */
  12194. _initialStartSpriteCellID: number;
  12195. /** @hidden */
  12196. _initialEndSpriteCellID: number;
  12197. /** @hidden */
  12198. _currentColorGradient: Nullable<ColorGradient>;
  12199. /** @hidden */
  12200. _currentColor1: Color4;
  12201. /** @hidden */
  12202. _currentColor2: Color4;
  12203. /** @hidden */
  12204. _currentSizeGradient: Nullable<FactorGradient>;
  12205. /** @hidden */
  12206. _currentSize1: number;
  12207. /** @hidden */
  12208. _currentSize2: number;
  12209. /** @hidden */
  12210. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12211. /** @hidden */
  12212. _currentAngularSpeed1: number;
  12213. /** @hidden */
  12214. _currentAngularSpeed2: number;
  12215. /** @hidden */
  12216. _currentVelocityGradient: Nullable<FactorGradient>;
  12217. /** @hidden */
  12218. _currentVelocity1: number;
  12219. /** @hidden */
  12220. _currentVelocity2: number;
  12221. /** @hidden */
  12222. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12223. /** @hidden */
  12224. _currentLimitVelocity1: number;
  12225. /** @hidden */
  12226. _currentLimitVelocity2: number;
  12227. /** @hidden */
  12228. _currentDragGradient: Nullable<FactorGradient>;
  12229. /** @hidden */
  12230. _currentDrag1: number;
  12231. /** @hidden */
  12232. _currentDrag2: number;
  12233. /** @hidden */
  12234. _randomNoiseCoordinates1: Vector3;
  12235. /** @hidden */
  12236. _randomNoiseCoordinates2: Vector3;
  12237. /** @hidden */
  12238. _localPosition?: Vector3;
  12239. /**
  12240. * Creates a new instance Particle
  12241. * @param particleSystem the particle system the particle belongs to
  12242. */
  12243. constructor(
  12244. /**
  12245. * The particle system the particle belongs to.
  12246. */
  12247. particleSystem: ParticleSystem);
  12248. private updateCellInfoFromSystem;
  12249. /**
  12250. * Defines how the sprite cell index is updated for the particle
  12251. */
  12252. updateCellIndex(): void;
  12253. /** @hidden */
  12254. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12255. /** @hidden */
  12256. _inheritParticleInfoToSubEmitters(): void;
  12257. /** @hidden */
  12258. _reset(): void;
  12259. /**
  12260. * Copy the properties of particle to another one.
  12261. * @param other the particle to copy the information to.
  12262. */
  12263. copyTo(other: Particle): void;
  12264. }
  12265. }
  12266. declare module BABYLON {
  12267. /**
  12268. * Particle emitter represents a volume emitting particles.
  12269. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12270. */
  12271. export interface IParticleEmitterType {
  12272. /**
  12273. * Called by the particle System when the direction is computed for the created particle.
  12274. * @param worldMatrix is the world matrix of the particle system
  12275. * @param directionToUpdate is the direction vector to update with the result
  12276. * @param particle is the particle we are computed the direction for
  12277. * @param isLocal defines if the direction should be set in local space
  12278. */
  12279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12280. /**
  12281. * Called by the particle System when the position is computed for the created particle.
  12282. * @param worldMatrix is the world matrix of the particle system
  12283. * @param positionToUpdate is the position vector to update with the result
  12284. * @param particle is the particle we are computed the position for
  12285. * @param isLocal defines if the position should be set in local space
  12286. */
  12287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12288. /**
  12289. * Clones the current emitter and returns a copy of it
  12290. * @returns the new emitter
  12291. */
  12292. clone(): IParticleEmitterType;
  12293. /**
  12294. * Called by the GPUParticleSystem to setup the update shader
  12295. * @param effect defines the update shader
  12296. */
  12297. applyToShader(effect: Effect): void;
  12298. /**
  12299. * Returns a string to use to update the GPU particles update shader
  12300. * @returns the effect defines string
  12301. */
  12302. getEffectDefines(): string;
  12303. /**
  12304. * Returns a string representing the class name
  12305. * @returns a string containing the class name
  12306. */
  12307. getClassName(): string;
  12308. /**
  12309. * Serializes the particle system to a JSON object.
  12310. * @returns the JSON object
  12311. */
  12312. serialize(): any;
  12313. /**
  12314. * Parse properties from a JSON object
  12315. * @param serializationObject defines the JSON object
  12316. * @param scene defines the hosting scene
  12317. */
  12318. parse(serializationObject: any, scene: Scene): void;
  12319. }
  12320. }
  12321. declare module BABYLON {
  12322. /**
  12323. * Particle emitter emitting particles from the inside of a box.
  12324. * It emits the particles randomly between 2 given directions.
  12325. */
  12326. export class BoxParticleEmitter implements IParticleEmitterType {
  12327. /**
  12328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12329. */
  12330. direction1: Vector3;
  12331. /**
  12332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12333. */
  12334. direction2: Vector3;
  12335. /**
  12336. * 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.
  12337. */
  12338. minEmitBox: Vector3;
  12339. /**
  12340. * 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.
  12341. */
  12342. maxEmitBox: Vector3;
  12343. /**
  12344. * Creates a new instance BoxParticleEmitter
  12345. */
  12346. constructor();
  12347. /**
  12348. * Called by the particle System when the direction is computed for the created particle.
  12349. * @param worldMatrix is the world matrix of the particle system
  12350. * @param directionToUpdate is the direction vector to update with the result
  12351. * @param particle is the particle we are computed the direction for
  12352. * @param isLocal defines if the direction should be set in local space
  12353. */
  12354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12355. /**
  12356. * Called by the particle System when the position is computed for the created particle.
  12357. * @param worldMatrix is the world matrix of the particle system
  12358. * @param positionToUpdate is the position vector to update with the result
  12359. * @param particle is the particle we are computed the position for
  12360. * @param isLocal defines if the position should be set in local space
  12361. */
  12362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12363. /**
  12364. * Clones the current emitter and returns a copy of it
  12365. * @returns the new emitter
  12366. */
  12367. clone(): BoxParticleEmitter;
  12368. /**
  12369. * Called by the GPUParticleSystem to setup the update shader
  12370. * @param effect defines the update shader
  12371. */
  12372. applyToShader(effect: Effect): void;
  12373. /**
  12374. * Returns a string to use to update the GPU particles update shader
  12375. * @returns a string containng the defines string
  12376. */
  12377. getEffectDefines(): string;
  12378. /**
  12379. * Returns the string "BoxParticleEmitter"
  12380. * @returns a string containing the class name
  12381. */
  12382. getClassName(): string;
  12383. /**
  12384. * Serializes the particle system to a JSON object.
  12385. * @returns the JSON object
  12386. */
  12387. serialize(): any;
  12388. /**
  12389. * Parse properties from a JSON object
  12390. * @param serializationObject defines the JSON object
  12391. */
  12392. parse(serializationObject: any): void;
  12393. }
  12394. }
  12395. declare module BABYLON {
  12396. /**
  12397. * Particle emitter emitting particles from the inside of a cone.
  12398. * It emits the particles alongside the cone volume from the base to the particle.
  12399. * The emission direction might be randomized.
  12400. */
  12401. export class ConeParticleEmitter implements IParticleEmitterType {
  12402. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12403. directionRandomizer: number;
  12404. private _radius;
  12405. private _angle;
  12406. private _height;
  12407. /**
  12408. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12409. */
  12410. radiusRange: number;
  12411. /**
  12412. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12413. */
  12414. heightRange: number;
  12415. /**
  12416. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12417. */
  12418. emitFromSpawnPointOnly: boolean;
  12419. /**
  12420. * Gets or sets the radius of the emission cone
  12421. */
  12422. get radius(): number;
  12423. set radius(value: number);
  12424. /**
  12425. * Gets or sets the angle of the emission cone
  12426. */
  12427. get angle(): number;
  12428. set angle(value: number);
  12429. private _buildHeight;
  12430. /**
  12431. * Creates a new instance ConeParticleEmitter
  12432. * @param radius the radius of the emission cone (1 by default)
  12433. * @param angle the cone base angle (PI by default)
  12434. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12435. */
  12436. constructor(radius?: number, angle?: number,
  12437. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12438. directionRandomizer?: number);
  12439. /**
  12440. * Called by the particle System when the direction is computed for the created particle.
  12441. * @param worldMatrix is the world matrix of the particle system
  12442. * @param directionToUpdate is the direction vector to update with the result
  12443. * @param particle is the particle we are computed the direction for
  12444. * @param isLocal defines if the direction should be set in local space
  12445. */
  12446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12447. /**
  12448. * Called by the particle System when the position is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param positionToUpdate is the position vector to update with the result
  12451. * @param particle is the particle we are computed the position for
  12452. * @param isLocal defines if the position should be set in local space
  12453. */
  12454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Clones the current emitter and returns a copy of it
  12457. * @returns the new emitter
  12458. */
  12459. clone(): ConeParticleEmitter;
  12460. /**
  12461. * Called by the GPUParticleSystem to setup the update shader
  12462. * @param effect defines the update shader
  12463. */
  12464. applyToShader(effect: Effect): void;
  12465. /**
  12466. * Returns a string to use to update the GPU particles update shader
  12467. * @returns a string containng the defines string
  12468. */
  12469. getEffectDefines(): string;
  12470. /**
  12471. * Returns the string "ConeParticleEmitter"
  12472. * @returns a string containing the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Serializes the particle system to a JSON object.
  12477. * @returns the JSON object
  12478. */
  12479. serialize(): any;
  12480. /**
  12481. * Parse properties from a JSON object
  12482. * @param serializationObject defines the JSON object
  12483. */
  12484. parse(serializationObject: any): void;
  12485. }
  12486. }
  12487. declare module BABYLON {
  12488. /**
  12489. * Particle emitter emitting particles from the inside of a cylinder.
  12490. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12491. */
  12492. export class CylinderParticleEmitter implements IParticleEmitterType {
  12493. /**
  12494. * The radius of the emission cylinder.
  12495. */
  12496. radius: number;
  12497. /**
  12498. * The height of the emission cylinder.
  12499. */
  12500. height: number;
  12501. /**
  12502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12503. */
  12504. radiusRange: number;
  12505. /**
  12506. * How much to randomize the particle direction [0-1].
  12507. */
  12508. directionRandomizer: number;
  12509. /**
  12510. * Creates a new instance CylinderParticleEmitter
  12511. * @param radius the radius of the emission cylinder (1 by default)
  12512. * @param height the height of the emission cylinder (1 by default)
  12513. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12514. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12515. */
  12516. constructor(
  12517. /**
  12518. * The radius of the emission cylinder.
  12519. */
  12520. radius?: number,
  12521. /**
  12522. * The height of the emission cylinder.
  12523. */
  12524. height?: number,
  12525. /**
  12526. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12527. */
  12528. radiusRange?: number,
  12529. /**
  12530. * How much to randomize the particle direction [0-1].
  12531. */
  12532. directionRandomizer?: number);
  12533. /**
  12534. * Called by the particle System when the direction is computed for the created particle.
  12535. * @param worldMatrix is the world matrix of the particle system
  12536. * @param directionToUpdate is the direction vector to update with the result
  12537. * @param particle is the particle we are computed the direction for
  12538. * @param isLocal defines if the direction should be set in local space
  12539. */
  12540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12541. /**
  12542. * Called by the particle System when the position is computed for the created particle.
  12543. * @param worldMatrix is the world matrix of the particle system
  12544. * @param positionToUpdate is the position vector to update with the result
  12545. * @param particle is the particle we are computed the position for
  12546. * @param isLocal defines if the position should be set in local space
  12547. */
  12548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12549. /**
  12550. * Clones the current emitter and returns a copy of it
  12551. * @returns the new emitter
  12552. */
  12553. clone(): CylinderParticleEmitter;
  12554. /**
  12555. * Called by the GPUParticleSystem to setup the update shader
  12556. * @param effect defines the update shader
  12557. */
  12558. applyToShader(effect: Effect): void;
  12559. /**
  12560. * Returns a string to use to update the GPU particles update shader
  12561. * @returns a string containng the defines string
  12562. */
  12563. getEffectDefines(): string;
  12564. /**
  12565. * Returns the string "CylinderParticleEmitter"
  12566. * @returns a string containing the class name
  12567. */
  12568. getClassName(): string;
  12569. /**
  12570. * Serializes the particle system to a JSON object.
  12571. * @returns the JSON object
  12572. */
  12573. serialize(): any;
  12574. /**
  12575. * Parse properties from a JSON object
  12576. * @param serializationObject defines the JSON object
  12577. */
  12578. parse(serializationObject: any): void;
  12579. }
  12580. /**
  12581. * Particle emitter emitting particles from the inside of a cylinder.
  12582. * It emits the particles randomly between two vectors.
  12583. */
  12584. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12585. /**
  12586. * The min limit of the emission direction.
  12587. */
  12588. direction1: Vector3;
  12589. /**
  12590. * The max limit of the emission direction.
  12591. */
  12592. direction2: Vector3;
  12593. /**
  12594. * Creates a new instance CylinderDirectedParticleEmitter
  12595. * @param radius the radius of the emission cylinder (1 by default)
  12596. * @param height the height of the emission cylinder (1 by default)
  12597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12598. * @param direction1 the min limit of the emission direction (up vector by default)
  12599. * @param direction2 the max limit of the emission direction (up vector by default)
  12600. */
  12601. constructor(radius?: number, height?: number, radiusRange?: number,
  12602. /**
  12603. * The min limit of the emission direction.
  12604. */
  12605. direction1?: Vector3,
  12606. /**
  12607. * The max limit of the emission direction.
  12608. */
  12609. direction2?: Vector3);
  12610. /**
  12611. * Called by the particle System when the direction is computed for the created particle.
  12612. * @param worldMatrix is the world matrix of the particle system
  12613. * @param directionToUpdate is the direction vector to update with the result
  12614. * @param particle is the particle we are computed the direction for
  12615. */
  12616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12617. /**
  12618. * Clones the current emitter and returns a copy of it
  12619. * @returns the new emitter
  12620. */
  12621. clone(): CylinderDirectedParticleEmitter;
  12622. /**
  12623. * Called by the GPUParticleSystem to setup the update shader
  12624. * @param effect defines the update shader
  12625. */
  12626. applyToShader(effect: Effect): void;
  12627. /**
  12628. * Returns a string to use to update the GPU particles update shader
  12629. * @returns a string containng the defines string
  12630. */
  12631. getEffectDefines(): string;
  12632. /**
  12633. * Returns the string "CylinderDirectedParticleEmitter"
  12634. * @returns a string containing the class name
  12635. */
  12636. getClassName(): string;
  12637. /**
  12638. * Serializes the particle system to a JSON object.
  12639. * @returns the JSON object
  12640. */
  12641. serialize(): any;
  12642. /**
  12643. * Parse properties from a JSON object
  12644. * @param serializationObject defines the JSON object
  12645. */
  12646. parse(serializationObject: any): void;
  12647. }
  12648. }
  12649. declare module BABYLON {
  12650. /**
  12651. * Particle emitter emitting particles from the inside of a hemisphere.
  12652. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12653. */
  12654. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12655. /**
  12656. * The radius of the emission hemisphere.
  12657. */
  12658. radius: number;
  12659. /**
  12660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12661. */
  12662. radiusRange: number;
  12663. /**
  12664. * How much to randomize the particle direction [0-1].
  12665. */
  12666. directionRandomizer: number;
  12667. /**
  12668. * Creates a new instance HemisphericParticleEmitter
  12669. * @param radius the radius of the emission hemisphere (1 by default)
  12670. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12671. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12672. */
  12673. constructor(
  12674. /**
  12675. * The radius of the emission hemisphere.
  12676. */
  12677. radius?: number,
  12678. /**
  12679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12680. */
  12681. radiusRange?: number,
  12682. /**
  12683. * How much to randomize the particle direction [0-1].
  12684. */
  12685. directionRandomizer?: number);
  12686. /**
  12687. * Called by the particle System when the direction is computed for the created particle.
  12688. * @param worldMatrix is the world matrix of the particle system
  12689. * @param directionToUpdate is the direction vector to update with the result
  12690. * @param particle is the particle we are computed the direction for
  12691. * @param isLocal defines if the direction should be set in local space
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12694. /**
  12695. * Called by the particle System when the position is computed for the created particle.
  12696. * @param worldMatrix is the world matrix of the particle system
  12697. * @param positionToUpdate is the position vector to update with the result
  12698. * @param particle is the particle we are computed the position for
  12699. * @param isLocal defines if the position should be set in local space
  12700. */
  12701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12702. /**
  12703. * Clones the current emitter and returns a copy of it
  12704. * @returns the new emitter
  12705. */
  12706. clone(): HemisphericParticleEmitter;
  12707. /**
  12708. * Called by the GPUParticleSystem to setup the update shader
  12709. * @param effect defines the update shader
  12710. */
  12711. applyToShader(effect: Effect): void;
  12712. /**
  12713. * Returns a string to use to update the GPU particles update shader
  12714. * @returns a string containng the defines string
  12715. */
  12716. getEffectDefines(): string;
  12717. /**
  12718. * Returns the string "HemisphericParticleEmitter"
  12719. * @returns a string containing the class name
  12720. */
  12721. getClassName(): string;
  12722. /**
  12723. * Serializes the particle system to a JSON object.
  12724. * @returns the JSON object
  12725. */
  12726. serialize(): any;
  12727. /**
  12728. * Parse properties from a JSON object
  12729. * @param serializationObject defines the JSON object
  12730. */
  12731. parse(serializationObject: any): void;
  12732. }
  12733. }
  12734. declare module BABYLON {
  12735. /**
  12736. * Particle emitter emitting particles from a point.
  12737. * It emits the particles randomly between 2 given directions.
  12738. */
  12739. export class PointParticleEmitter implements IParticleEmitterType {
  12740. /**
  12741. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12742. */
  12743. direction1: Vector3;
  12744. /**
  12745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12746. */
  12747. direction2: Vector3;
  12748. /**
  12749. * Creates a new instance PointParticleEmitter
  12750. */
  12751. constructor();
  12752. /**
  12753. * Called by the particle System when the direction is computed for the created particle.
  12754. * @param worldMatrix is the world matrix of the particle system
  12755. * @param directionToUpdate is the direction vector to update with the result
  12756. * @param particle is the particle we are computed the direction for
  12757. * @param isLocal defines if the direction should be set in local space
  12758. */
  12759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12760. /**
  12761. * Called by the particle System when the position is computed for the created particle.
  12762. * @param worldMatrix is the world matrix of the particle system
  12763. * @param positionToUpdate is the position vector to update with the result
  12764. * @param particle is the particle we are computed the position for
  12765. * @param isLocal defines if the position should be set in local space
  12766. */
  12767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12768. /**
  12769. * Clones the current emitter and returns a copy of it
  12770. * @returns the new emitter
  12771. */
  12772. clone(): PointParticleEmitter;
  12773. /**
  12774. * Called by the GPUParticleSystem to setup the update shader
  12775. * @param effect defines the update shader
  12776. */
  12777. applyToShader(effect: Effect): void;
  12778. /**
  12779. * Returns a string to use to update the GPU particles update shader
  12780. * @returns a string containng the defines string
  12781. */
  12782. getEffectDefines(): string;
  12783. /**
  12784. * Returns the string "PointParticleEmitter"
  12785. * @returns a string containing the class name
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Serializes the particle system to a JSON object.
  12790. * @returns the JSON object
  12791. */
  12792. serialize(): any;
  12793. /**
  12794. * Parse properties from a JSON object
  12795. * @param serializationObject defines the JSON object
  12796. */
  12797. parse(serializationObject: any): void;
  12798. }
  12799. }
  12800. declare module BABYLON {
  12801. /**
  12802. * Particle emitter emitting particles from the inside of a sphere.
  12803. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12804. */
  12805. export class SphereParticleEmitter implements IParticleEmitterType {
  12806. /**
  12807. * The radius of the emission sphere.
  12808. */
  12809. radius: number;
  12810. /**
  12811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12812. */
  12813. radiusRange: number;
  12814. /**
  12815. * How much to randomize the particle direction [0-1].
  12816. */
  12817. directionRandomizer: number;
  12818. /**
  12819. * Creates a new instance SphereParticleEmitter
  12820. * @param radius the radius of the emission sphere (1 by default)
  12821. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12822. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12823. */
  12824. constructor(
  12825. /**
  12826. * The radius of the emission sphere.
  12827. */
  12828. radius?: number,
  12829. /**
  12830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12831. */
  12832. radiusRange?: number,
  12833. /**
  12834. * How much to randomize the particle direction [0-1].
  12835. */
  12836. directionRandomizer?: number);
  12837. /**
  12838. * Called by the particle System when the direction is computed for the created particle.
  12839. * @param worldMatrix is the world matrix of the particle system
  12840. * @param directionToUpdate is the direction vector to update with the result
  12841. * @param particle is the particle we are computed the direction for
  12842. * @param isLocal defines if the direction should be set in local space
  12843. */
  12844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12845. /**
  12846. * Called by the particle System when the position is computed for the created particle.
  12847. * @param worldMatrix is the world matrix of the particle system
  12848. * @param positionToUpdate is the position vector to update with the result
  12849. * @param particle is the particle we are computed the position for
  12850. * @param isLocal defines if the position should be set in local space
  12851. */
  12852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12853. /**
  12854. * Clones the current emitter and returns a copy of it
  12855. * @returns the new emitter
  12856. */
  12857. clone(): SphereParticleEmitter;
  12858. /**
  12859. * Called by the GPUParticleSystem to setup the update shader
  12860. * @param effect defines the update shader
  12861. */
  12862. applyToShader(effect: Effect): void;
  12863. /**
  12864. * Returns a string to use to update the GPU particles update shader
  12865. * @returns a string containng the defines string
  12866. */
  12867. getEffectDefines(): string;
  12868. /**
  12869. * Returns the string "SphereParticleEmitter"
  12870. * @returns a string containing the class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Serializes the particle system to a JSON object.
  12875. * @returns the JSON object
  12876. */
  12877. serialize(): any;
  12878. /**
  12879. * Parse properties from a JSON object
  12880. * @param serializationObject defines the JSON object
  12881. */
  12882. parse(serializationObject: any): void;
  12883. }
  12884. /**
  12885. * Particle emitter emitting particles from the inside of a sphere.
  12886. * It emits the particles randomly between two vectors.
  12887. */
  12888. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12889. /**
  12890. * The min limit of the emission direction.
  12891. */
  12892. direction1: Vector3;
  12893. /**
  12894. * The max limit of the emission direction.
  12895. */
  12896. direction2: Vector3;
  12897. /**
  12898. * Creates a new instance SphereDirectedParticleEmitter
  12899. * @param radius the radius of the emission sphere (1 by default)
  12900. * @param direction1 the min limit of the emission direction (up vector by default)
  12901. * @param direction2 the max limit of the emission direction (up vector by default)
  12902. */
  12903. constructor(radius?: number,
  12904. /**
  12905. * The min limit of the emission direction.
  12906. */
  12907. direction1?: Vector3,
  12908. /**
  12909. * The max limit of the emission direction.
  12910. */
  12911. direction2?: Vector3);
  12912. /**
  12913. * Called by the particle System when the direction is computed for the created particle.
  12914. * @param worldMatrix is the world matrix of the particle system
  12915. * @param directionToUpdate is the direction vector to update with the result
  12916. * @param particle is the particle we are computed the direction for
  12917. */
  12918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12919. /**
  12920. * Clones the current emitter and returns a copy of it
  12921. * @returns the new emitter
  12922. */
  12923. clone(): SphereDirectedParticleEmitter;
  12924. /**
  12925. * Called by the GPUParticleSystem to setup the update shader
  12926. * @param effect defines the update shader
  12927. */
  12928. applyToShader(effect: Effect): void;
  12929. /**
  12930. * Returns a string to use to update the GPU particles update shader
  12931. * @returns a string containng the defines string
  12932. */
  12933. getEffectDefines(): string;
  12934. /**
  12935. * Returns the string "SphereDirectedParticleEmitter"
  12936. * @returns a string containing the class name
  12937. */
  12938. getClassName(): string;
  12939. /**
  12940. * Serializes the particle system to a JSON object.
  12941. * @returns the JSON object
  12942. */
  12943. serialize(): any;
  12944. /**
  12945. * Parse properties from a JSON object
  12946. * @param serializationObject defines the JSON object
  12947. */
  12948. parse(serializationObject: any): void;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. /**
  12953. * Particle emitter emitting particles from a custom list of positions.
  12954. */
  12955. export class CustomParticleEmitter implements IParticleEmitterType {
  12956. /**
  12957. * Gets or sets the position generator that will create the inital position of each particle.
  12958. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12959. */
  12960. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12961. /**
  12962. * Gets or sets the destination generator that will create the final destination of each particle.
  12963. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12964. */
  12965. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12966. /**
  12967. * Creates a new instance CustomParticleEmitter
  12968. */
  12969. constructor();
  12970. /**
  12971. * Called by the particle System when the direction is computed for the created particle.
  12972. * @param worldMatrix is the world matrix of the particle system
  12973. * @param directionToUpdate is the direction vector to update with the result
  12974. * @param particle is the particle we are computed the direction for
  12975. * @param isLocal defines if the direction should be set in local space
  12976. */
  12977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12978. /**
  12979. * Called by the particle System when the position is computed for the created particle.
  12980. * @param worldMatrix is the world matrix of the particle system
  12981. * @param positionToUpdate is the position vector to update with the result
  12982. * @param particle is the particle we are computed the position for
  12983. * @param isLocal defines if the position should be set in local space
  12984. */
  12985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12986. /**
  12987. * Clones the current emitter and returns a copy of it
  12988. * @returns the new emitter
  12989. */
  12990. clone(): CustomParticleEmitter;
  12991. /**
  12992. * Called by the GPUParticleSystem to setup the update shader
  12993. * @param effect defines the update shader
  12994. */
  12995. applyToShader(effect: Effect): void;
  12996. /**
  12997. * Returns a string to use to update the GPU particles update shader
  12998. * @returns a string containng the defines string
  12999. */
  13000. getEffectDefines(): string;
  13001. /**
  13002. * Returns the string "PointParticleEmitter"
  13003. * @returns a string containing the class name
  13004. */
  13005. getClassName(): string;
  13006. /**
  13007. * Serializes the particle system to a JSON object.
  13008. * @returns the JSON object
  13009. */
  13010. serialize(): any;
  13011. /**
  13012. * Parse properties from a JSON object
  13013. * @param serializationObject defines the JSON object
  13014. */
  13015. parse(serializationObject: any): void;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Particle emitter emitting particles from the inside of a box.
  13021. * It emits the particles randomly between 2 given directions.
  13022. */
  13023. export class MeshParticleEmitter implements IParticleEmitterType {
  13024. private _indices;
  13025. private _positions;
  13026. private _normals;
  13027. private _storedNormal;
  13028. private _mesh;
  13029. /**
  13030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13031. */
  13032. direction1: Vector3;
  13033. /**
  13034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13035. */
  13036. direction2: Vector3;
  13037. /**
  13038. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13039. */
  13040. useMeshNormalsForDirection: boolean;
  13041. /** Defines the mesh to use as source */
  13042. get mesh(): Nullable<AbstractMesh>;
  13043. set mesh(value: Nullable<AbstractMesh>);
  13044. /**
  13045. * Creates a new instance MeshParticleEmitter
  13046. * @param mesh defines the mesh to use as source
  13047. */
  13048. constructor(mesh?: Nullable<AbstractMesh>);
  13049. /**
  13050. * Called by the particle System when the direction is computed for the created particle.
  13051. * @param worldMatrix is the world matrix of the particle system
  13052. * @param directionToUpdate is the direction vector to update with the result
  13053. * @param particle is the particle we are computed the direction for
  13054. * @param isLocal defines if the direction should be set in local space
  13055. */
  13056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13057. /**
  13058. * Called by the particle System when the position is computed for the created particle.
  13059. * @param worldMatrix is the world matrix of the particle system
  13060. * @param positionToUpdate is the position vector to update with the result
  13061. * @param particle is the particle we are computed the position for
  13062. * @param isLocal defines if the position should be set in local space
  13063. */
  13064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13065. /**
  13066. * Clones the current emitter and returns a copy of it
  13067. * @returns the new emitter
  13068. */
  13069. clone(): MeshParticleEmitter;
  13070. /**
  13071. * Called by the GPUParticleSystem to setup the update shader
  13072. * @param effect defines the update shader
  13073. */
  13074. applyToShader(effect: Effect): void;
  13075. /**
  13076. * Returns a string to use to update the GPU particles update shader
  13077. * @returns a string containng the defines string
  13078. */
  13079. getEffectDefines(): string;
  13080. /**
  13081. * Returns the string "BoxParticleEmitter"
  13082. * @returns a string containing the class name
  13083. */
  13084. getClassName(): string;
  13085. /**
  13086. * Serializes the particle system to a JSON object.
  13087. * @returns the JSON object
  13088. */
  13089. serialize(): any;
  13090. /**
  13091. * Parse properties from a JSON object
  13092. * @param serializationObject defines the JSON object
  13093. * @param scene defines the hosting scene
  13094. */
  13095. parse(serializationObject: any, scene: Scene): void;
  13096. }
  13097. }
  13098. declare module BABYLON {
  13099. /**
  13100. * Interface representing a particle system in Babylon.js.
  13101. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13102. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13103. */
  13104. export interface IParticleSystem {
  13105. /**
  13106. * List of animations used by the particle system.
  13107. */
  13108. animations: Animation[];
  13109. /**
  13110. * The id of the Particle system.
  13111. */
  13112. id: string;
  13113. /**
  13114. * The name of the Particle system.
  13115. */
  13116. name: string;
  13117. /**
  13118. * The emitter represents the Mesh or position we are attaching the particle system to.
  13119. */
  13120. emitter: Nullable<AbstractMesh | Vector3>;
  13121. /**
  13122. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13123. */
  13124. isBillboardBased: boolean;
  13125. /**
  13126. * The rendering group used by the Particle system to chose when to render.
  13127. */
  13128. renderingGroupId: number;
  13129. /**
  13130. * The layer mask we are rendering the particles through.
  13131. */
  13132. layerMask: number;
  13133. /**
  13134. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13135. */
  13136. updateSpeed: number;
  13137. /**
  13138. * The amount of time the particle system is running (depends of the overall update speed).
  13139. */
  13140. targetStopDuration: number;
  13141. /**
  13142. * The texture used to render each particle. (this can be a spritesheet)
  13143. */
  13144. particleTexture: Nullable<Texture>;
  13145. /**
  13146. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13147. */
  13148. blendMode: number;
  13149. /**
  13150. * Minimum life time of emitting particles.
  13151. */
  13152. minLifeTime: number;
  13153. /**
  13154. * Maximum life time of emitting particles.
  13155. */
  13156. maxLifeTime: number;
  13157. /**
  13158. * Minimum Size of emitting particles.
  13159. */
  13160. minSize: number;
  13161. /**
  13162. * Maximum Size of emitting particles.
  13163. */
  13164. maxSize: number;
  13165. /**
  13166. * Minimum scale of emitting particles on X axis.
  13167. */
  13168. minScaleX: number;
  13169. /**
  13170. * Maximum scale of emitting particles on X axis.
  13171. */
  13172. maxScaleX: number;
  13173. /**
  13174. * Minimum scale of emitting particles on Y axis.
  13175. */
  13176. minScaleY: number;
  13177. /**
  13178. * Maximum scale of emitting particles on Y axis.
  13179. */
  13180. maxScaleY: number;
  13181. /**
  13182. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13183. */
  13184. color1: Color4;
  13185. /**
  13186. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13187. */
  13188. color2: Color4;
  13189. /**
  13190. * Color the particle will have at the end of its lifetime.
  13191. */
  13192. colorDead: Color4;
  13193. /**
  13194. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13195. */
  13196. emitRate: number;
  13197. /**
  13198. * You can use gravity if you want to give an orientation to your particles.
  13199. */
  13200. gravity: Vector3;
  13201. /**
  13202. * Minimum power of emitting particles.
  13203. */
  13204. minEmitPower: number;
  13205. /**
  13206. * Maximum power of emitting particles.
  13207. */
  13208. maxEmitPower: number;
  13209. /**
  13210. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13211. */
  13212. minAngularSpeed: number;
  13213. /**
  13214. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13215. */
  13216. maxAngularSpeed: number;
  13217. /**
  13218. * Gets or sets the minimal initial rotation in radians.
  13219. */
  13220. minInitialRotation: number;
  13221. /**
  13222. * Gets or sets the maximal initial rotation in radians.
  13223. */
  13224. maxInitialRotation: number;
  13225. /**
  13226. * The particle emitter type defines the emitter used by the particle system.
  13227. * It can be for example box, sphere, or cone...
  13228. */
  13229. particleEmitterType: Nullable<IParticleEmitterType>;
  13230. /**
  13231. * Defines the delay in milliseconds before starting the system (0 by default)
  13232. */
  13233. startDelay: number;
  13234. /**
  13235. * 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
  13236. */
  13237. preWarmCycles: number;
  13238. /**
  13239. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13240. */
  13241. preWarmStepOffset: number;
  13242. /**
  13243. * 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)
  13244. */
  13245. spriteCellChangeSpeed: number;
  13246. /**
  13247. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13248. */
  13249. startSpriteCellID: number;
  13250. /**
  13251. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13252. */
  13253. endSpriteCellID: number;
  13254. /**
  13255. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13256. */
  13257. spriteCellWidth: number;
  13258. /**
  13259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13260. */
  13261. spriteCellHeight: number;
  13262. /**
  13263. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13264. */
  13265. spriteRandomStartCell: boolean;
  13266. /**
  13267. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13268. */
  13269. isAnimationSheetEnabled: boolean;
  13270. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13271. translationPivot: Vector2;
  13272. /**
  13273. * Gets or sets a texture used to add random noise to particle positions
  13274. */
  13275. noiseTexture: Nullable<BaseTexture>;
  13276. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13277. noiseStrength: Vector3;
  13278. /**
  13279. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13280. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13281. */
  13282. billboardMode: number;
  13283. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13284. limitVelocityDamping: number;
  13285. /**
  13286. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13287. */
  13288. beginAnimationOnStart: boolean;
  13289. /**
  13290. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13291. */
  13292. beginAnimationFrom: number;
  13293. /**
  13294. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13295. */
  13296. beginAnimationTo: number;
  13297. /**
  13298. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13299. */
  13300. beginAnimationLoop: boolean;
  13301. /**
  13302. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13303. */
  13304. disposeOnStop: boolean;
  13305. /**
  13306. * Specifies if the particles are updated in emitter local space or world space
  13307. */
  13308. isLocal: boolean;
  13309. /** Snippet ID if the particle system was created from the snippet server */
  13310. snippetId: string;
  13311. /**
  13312. * Gets the maximum number of particles active at the same time.
  13313. * @returns The max number of active particles.
  13314. */
  13315. getCapacity(): number;
  13316. /**
  13317. * Gets the number of particles active at the same time.
  13318. * @returns The number of active particles.
  13319. */
  13320. getActiveCount(): number;
  13321. /**
  13322. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13323. * @returns True if it has been started, otherwise false.
  13324. */
  13325. isStarted(): boolean;
  13326. /**
  13327. * Animates the particle system for this frame.
  13328. */
  13329. animate(): void;
  13330. /**
  13331. * Renders the particle system in its current state.
  13332. * @returns the current number of particles
  13333. */
  13334. render(): number;
  13335. /**
  13336. * Dispose the particle system and frees its associated resources.
  13337. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13338. */
  13339. dispose(disposeTexture?: boolean): void;
  13340. /**
  13341. * Clones the particle system.
  13342. * @param name The name of the cloned object
  13343. * @param newEmitter The new emitter to use
  13344. * @returns the cloned particle system
  13345. */
  13346. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13347. /**
  13348. * Serializes the particle system to a JSON object
  13349. * @param serializeTexture defines if the texture must be serialized as well
  13350. * @returns the JSON object
  13351. */
  13352. serialize(serializeTexture: boolean): any;
  13353. /**
  13354. * Rebuild the particle system
  13355. */
  13356. rebuild(): void;
  13357. /** Force the system to rebuild all gradients that need to be resync */
  13358. forceRefreshGradients(): void;
  13359. /**
  13360. * Starts the particle system and begins to emit
  13361. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13362. */
  13363. start(delay?: number): void;
  13364. /**
  13365. * Stops the particle system.
  13366. */
  13367. stop(): void;
  13368. /**
  13369. * Remove all active particles
  13370. */
  13371. reset(): void;
  13372. /**
  13373. * Gets a boolean indicating that the system is stopping
  13374. * @returns true if the system is currently stopping
  13375. */
  13376. isStopping(): boolean;
  13377. /**
  13378. * Is this system ready to be used/rendered
  13379. * @return true if the system is ready
  13380. */
  13381. isReady(): boolean;
  13382. /**
  13383. * Returns the string "ParticleSystem"
  13384. * @returns a string containing the class name
  13385. */
  13386. getClassName(): string;
  13387. /**
  13388. * Adds a new color gradient
  13389. * @param gradient defines the gradient to use (between 0 and 1)
  13390. * @param color1 defines the color to affect to the specified gradient
  13391. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13392. * @returns the current particle system
  13393. */
  13394. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13395. /**
  13396. * Remove a specific color gradient
  13397. * @param gradient defines the gradient to remove
  13398. * @returns the current particle system
  13399. */
  13400. removeColorGradient(gradient: number): IParticleSystem;
  13401. /**
  13402. * Adds a new size gradient
  13403. * @param gradient defines the gradient to use (between 0 and 1)
  13404. * @param factor defines the size factor to affect to the specified gradient
  13405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13406. * @returns the current particle system
  13407. */
  13408. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13409. /**
  13410. * Remove a specific size gradient
  13411. * @param gradient defines the gradient to remove
  13412. * @returns the current particle system
  13413. */
  13414. removeSizeGradient(gradient: number): IParticleSystem;
  13415. /**
  13416. * Gets the current list of color gradients.
  13417. * You must use addColorGradient and removeColorGradient to udpate this list
  13418. * @returns the list of color gradients
  13419. */
  13420. getColorGradients(): Nullable<Array<ColorGradient>>;
  13421. /**
  13422. * Gets the current list of size gradients.
  13423. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13424. * @returns the list of size gradients
  13425. */
  13426. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13427. /**
  13428. * Gets the current list of angular speed gradients.
  13429. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13430. * @returns the list of angular speed gradients
  13431. */
  13432. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13433. /**
  13434. * Adds a new angular speed gradient
  13435. * @param gradient defines the gradient to use (between 0 and 1)
  13436. * @param factor defines the angular speed to affect to the specified gradient
  13437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13438. * @returns the current particle system
  13439. */
  13440. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13441. /**
  13442. * Remove a specific angular speed gradient
  13443. * @param gradient defines the gradient to remove
  13444. * @returns the current particle system
  13445. */
  13446. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13447. /**
  13448. * Gets the current list of velocity gradients.
  13449. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13450. * @returns the list of velocity gradients
  13451. */
  13452. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13453. /**
  13454. * Adds a new velocity gradient
  13455. * @param gradient defines the gradient to use (between 0 and 1)
  13456. * @param factor defines the velocity to affect to the specified gradient
  13457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13458. * @returns the current particle system
  13459. */
  13460. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13461. /**
  13462. * Remove a specific velocity gradient
  13463. * @param gradient defines the gradient to remove
  13464. * @returns the current particle system
  13465. */
  13466. removeVelocityGradient(gradient: number): IParticleSystem;
  13467. /**
  13468. * Gets the current list of limit velocity gradients.
  13469. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13470. * @returns the list of limit velocity gradients
  13471. */
  13472. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13473. /**
  13474. * Adds a new limit velocity gradient
  13475. * @param gradient defines the gradient to use (between 0 and 1)
  13476. * @param factor defines the limit velocity to affect to the specified gradient
  13477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13478. * @returns the current particle system
  13479. */
  13480. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13481. /**
  13482. * Remove a specific limit velocity gradient
  13483. * @param gradient defines the gradient to remove
  13484. * @returns the current particle system
  13485. */
  13486. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13487. /**
  13488. * Adds a new drag gradient
  13489. * @param gradient defines the gradient to use (between 0 and 1)
  13490. * @param factor defines the drag to affect to the specified gradient
  13491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13492. * @returns the current particle system
  13493. */
  13494. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13495. /**
  13496. * Remove a specific drag gradient
  13497. * @param gradient defines the gradient to remove
  13498. * @returns the current particle system
  13499. */
  13500. removeDragGradient(gradient: number): IParticleSystem;
  13501. /**
  13502. * Gets the current list of drag gradients.
  13503. * You must use addDragGradient and removeDragGradient to udpate this list
  13504. * @returns the list of drag gradients
  13505. */
  13506. getDragGradients(): Nullable<Array<FactorGradient>>;
  13507. /**
  13508. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the emit rate to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific emit rate gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeEmitRateGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of emit rate gradients.
  13523. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13524. * @returns the list of emit rate gradients
  13525. */
  13526. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13527. /**
  13528. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13529. * @param gradient defines the gradient to use (between 0 and 1)
  13530. * @param factor defines the start size to affect to the specified gradient
  13531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13532. * @returns the current particle system
  13533. */
  13534. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13535. /**
  13536. * Remove a specific start size gradient
  13537. * @param gradient defines the gradient to remove
  13538. * @returns the current particle system
  13539. */
  13540. removeStartSizeGradient(gradient: number): IParticleSystem;
  13541. /**
  13542. * Gets the current list of start size gradients.
  13543. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13544. * @returns the list of start size gradients
  13545. */
  13546. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13547. /**
  13548. * Adds a new life time gradient
  13549. * @param gradient defines the gradient to use (between 0 and 1)
  13550. * @param factor defines the life time factor to affect to the specified gradient
  13551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13552. * @returns the current particle system
  13553. */
  13554. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13555. /**
  13556. * Remove a specific life time gradient
  13557. * @param gradient defines the gradient to remove
  13558. * @returns the current particle system
  13559. */
  13560. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13561. /**
  13562. * Gets the current list of life time gradients.
  13563. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13564. * @returns the list of life time gradients
  13565. */
  13566. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13567. /**
  13568. * Gets the current list of color gradients.
  13569. * You must use addColorGradient and removeColorGradient to udpate this list
  13570. * @returns the list of color gradients
  13571. */
  13572. getColorGradients(): Nullable<Array<ColorGradient>>;
  13573. /**
  13574. * Adds a new ramp gradient used to remap particle colors
  13575. * @param gradient defines the gradient to use (between 0 and 1)
  13576. * @param color defines the color to affect to the specified gradient
  13577. * @returns the current particle system
  13578. */
  13579. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13580. /**
  13581. * Gets the current list of ramp gradients.
  13582. * You must use addRampGradient and removeRampGradient to udpate this list
  13583. * @returns the list of ramp gradients
  13584. */
  13585. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13586. /** Gets or sets a boolean indicating that ramp gradients must be used
  13587. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13588. */
  13589. useRampGradients: boolean;
  13590. /**
  13591. * Adds a new color remap gradient
  13592. * @param gradient defines the gradient to use (between 0 and 1)
  13593. * @param min defines the color remap minimal range
  13594. * @param max defines the color remap maximal range
  13595. * @returns the current particle system
  13596. */
  13597. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13598. /**
  13599. * Gets the current list of color remap gradients.
  13600. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13601. * @returns the list of color remap gradients
  13602. */
  13603. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13604. /**
  13605. * Adds a new alpha remap gradient
  13606. * @param gradient defines the gradient to use (between 0 and 1)
  13607. * @param min defines the alpha remap minimal range
  13608. * @param max defines the alpha remap maximal range
  13609. * @returns the current particle system
  13610. */
  13611. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13612. /**
  13613. * Gets the current list of alpha remap gradients.
  13614. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13615. * @returns the list of alpha remap gradients
  13616. */
  13617. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13618. /**
  13619. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13622. * @returns the emitter
  13623. */
  13624. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13625. /**
  13626. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13627. * @param radius The radius of the hemisphere to emit from
  13628. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13629. * @returns the emitter
  13630. */
  13631. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13632. /**
  13633. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13634. * @param radius The radius of the sphere to emit from
  13635. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13636. * @returns the emitter
  13637. */
  13638. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13639. /**
  13640. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13641. * @param radius The radius of the sphere to emit from
  13642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13644. * @returns the emitter
  13645. */
  13646. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13647. /**
  13648. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13649. * @param radius The radius of the emission cylinder
  13650. * @param height The height of the emission cylinder
  13651. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13652. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13653. * @returns the emitter
  13654. */
  13655. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13656. /**
  13657. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13658. * @param radius The radius of the cylinder to emit from
  13659. * @param height The height of the emission cylinder
  13660. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13661. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13662. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13663. * @returns the emitter
  13664. */
  13665. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13666. /**
  13667. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13668. * @param radius The radius of the cone to emit from
  13669. * @param angle The base angle of the cone
  13670. * @returns the emitter
  13671. */
  13672. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13673. /**
  13674. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13677. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13678. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13679. * @returns the emitter
  13680. */
  13681. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13682. /**
  13683. * Get hosting scene
  13684. * @returns the scene
  13685. */
  13686. getScene(): Scene;
  13687. }
  13688. }
  13689. declare module BABYLON {
  13690. /**
  13691. * 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.
  13692. * @see https://doc.babylonjs.com/how_to/transformnode
  13693. */
  13694. export class TransformNode extends Node {
  13695. /**
  13696. * Object will not rotate to face the camera
  13697. */
  13698. static BILLBOARDMODE_NONE: number;
  13699. /**
  13700. * Object will rotate to face the camera but only on the x axis
  13701. */
  13702. static BILLBOARDMODE_X: number;
  13703. /**
  13704. * Object will rotate to face the camera but only on the y axis
  13705. */
  13706. static BILLBOARDMODE_Y: number;
  13707. /**
  13708. * Object will rotate to face the camera but only on the z axis
  13709. */
  13710. static BILLBOARDMODE_Z: number;
  13711. /**
  13712. * Object will rotate to face the camera
  13713. */
  13714. static BILLBOARDMODE_ALL: number;
  13715. /**
  13716. * Object will rotate to face the camera's position instead of orientation
  13717. */
  13718. static BILLBOARDMODE_USE_POSITION: number;
  13719. private _forward;
  13720. private _forwardInverted;
  13721. private _up;
  13722. private _right;
  13723. private _rightInverted;
  13724. private _position;
  13725. private _rotation;
  13726. private _rotationQuaternion;
  13727. protected _scaling: Vector3;
  13728. protected _isDirty: boolean;
  13729. private _transformToBoneReferal;
  13730. private _isAbsoluteSynced;
  13731. private _billboardMode;
  13732. /**
  13733. * Gets or sets the billboard mode. Default is 0.
  13734. *
  13735. * | Value | Type | Description |
  13736. * | --- | --- | --- |
  13737. * | 0 | BILLBOARDMODE_NONE | |
  13738. * | 1 | BILLBOARDMODE_X | |
  13739. * | 2 | BILLBOARDMODE_Y | |
  13740. * | 4 | BILLBOARDMODE_Z | |
  13741. * | 7 | BILLBOARDMODE_ALL | |
  13742. *
  13743. */
  13744. get billboardMode(): number;
  13745. set billboardMode(value: number);
  13746. private _preserveParentRotationForBillboard;
  13747. /**
  13748. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13749. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13750. */
  13751. get preserveParentRotationForBillboard(): boolean;
  13752. set preserveParentRotationForBillboard(value: boolean);
  13753. /**
  13754. * 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
  13755. */
  13756. scalingDeterminant: number;
  13757. private _infiniteDistance;
  13758. /**
  13759. * Gets or sets the distance of the object to max, often used by skybox
  13760. */
  13761. get infiniteDistance(): boolean;
  13762. set infiniteDistance(value: boolean);
  13763. /**
  13764. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13765. * By default the system will update normals to compensate
  13766. */
  13767. ignoreNonUniformScaling: boolean;
  13768. /**
  13769. * 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
  13770. */
  13771. reIntegrateRotationIntoRotationQuaternion: boolean;
  13772. /** @hidden */
  13773. _poseMatrix: Nullable<Matrix>;
  13774. /** @hidden */
  13775. _localMatrix: Matrix;
  13776. private _usePivotMatrix;
  13777. private _absolutePosition;
  13778. private _absoluteScaling;
  13779. private _absoluteRotationQuaternion;
  13780. private _pivotMatrix;
  13781. private _pivotMatrixInverse;
  13782. protected _postMultiplyPivotMatrix: boolean;
  13783. protected _isWorldMatrixFrozen: boolean;
  13784. /** @hidden */
  13785. _indexInSceneTransformNodesArray: number;
  13786. /**
  13787. * An event triggered after the world matrix is updated
  13788. */
  13789. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13790. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13791. /**
  13792. * Gets a string identifying the name of the class
  13793. * @returns "TransformNode" string
  13794. */
  13795. getClassName(): string;
  13796. /**
  13797. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13798. */
  13799. get position(): Vector3;
  13800. set position(newPosition: Vector3);
  13801. /**
  13802. * 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)).
  13803. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13804. */
  13805. get rotation(): Vector3;
  13806. set rotation(newRotation: Vector3);
  13807. /**
  13808. * 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)).
  13809. */
  13810. get scaling(): Vector3;
  13811. set scaling(newScaling: Vector3);
  13812. /**
  13813. * 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).
  13814. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13815. */
  13816. get rotationQuaternion(): Nullable<Quaternion>;
  13817. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13818. /**
  13819. * The forward direction of that transform in world space.
  13820. */
  13821. get forward(): Vector3;
  13822. /**
  13823. * The up direction of that transform in world space.
  13824. */
  13825. get up(): Vector3;
  13826. /**
  13827. * The right direction of that transform in world space.
  13828. */
  13829. get right(): Vector3;
  13830. /**
  13831. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13832. * @param matrix the matrix to copy the pose from
  13833. * @returns this TransformNode.
  13834. */
  13835. updatePoseMatrix(matrix: Matrix): TransformNode;
  13836. /**
  13837. * Returns the mesh Pose matrix.
  13838. * @returns the pose matrix
  13839. */
  13840. getPoseMatrix(): Matrix;
  13841. /** @hidden */
  13842. _isSynchronized(): boolean;
  13843. /** @hidden */
  13844. _initCache(): void;
  13845. /**
  13846. * Flag the transform node as dirty (Forcing it to update everything)
  13847. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13848. * @returns this transform node
  13849. */
  13850. markAsDirty(property: string): TransformNode;
  13851. /**
  13852. * Returns the current mesh absolute position.
  13853. * Returns a Vector3.
  13854. */
  13855. get absolutePosition(): Vector3;
  13856. /**
  13857. * Returns the current mesh absolute scaling.
  13858. * Returns a Vector3.
  13859. */
  13860. get absoluteScaling(): Vector3;
  13861. /**
  13862. * Returns the current mesh absolute rotation.
  13863. * Returns a Quaternion.
  13864. */
  13865. get absoluteRotationQuaternion(): Quaternion;
  13866. /**
  13867. * Sets a new matrix to apply before all other transformation
  13868. * @param matrix defines the transform matrix
  13869. * @returns the current TransformNode
  13870. */
  13871. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13872. /**
  13873. * Sets a new pivot matrix to the current node
  13874. * @param matrix defines the new pivot matrix to use
  13875. * @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
  13876. * @returns the current TransformNode
  13877. */
  13878. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13879. /**
  13880. * Returns the mesh pivot matrix.
  13881. * Default : Identity.
  13882. * @returns the matrix
  13883. */
  13884. getPivotMatrix(): Matrix;
  13885. /**
  13886. * Instantiate (when possible) or clone that node with its hierarchy
  13887. * @param newParent defines the new parent to use for the instance (or clone)
  13888. * @param options defines options to configure how copy is done
  13889. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13890. * @returns an instance (or a clone) of the current node with its hiearchy
  13891. */
  13892. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13893. doNotInstantiate: boolean;
  13894. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13895. /**
  13896. * Prevents the World matrix to be computed any longer
  13897. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13898. * @returns the TransformNode.
  13899. */
  13900. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13901. /**
  13902. * Allows back the World matrix computation.
  13903. * @returns the TransformNode.
  13904. */
  13905. unfreezeWorldMatrix(): this;
  13906. /**
  13907. * True if the World matrix has been frozen.
  13908. */
  13909. get isWorldMatrixFrozen(): boolean;
  13910. /**
  13911. * Retuns the mesh absolute position in the World.
  13912. * @returns a Vector3.
  13913. */
  13914. getAbsolutePosition(): Vector3;
  13915. /**
  13916. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13917. * @param absolutePosition the absolute position to set
  13918. * @returns the TransformNode.
  13919. */
  13920. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13921. /**
  13922. * Sets the mesh position in its local space.
  13923. * @param vector3 the position to set in localspace
  13924. * @returns the TransformNode.
  13925. */
  13926. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13927. /**
  13928. * Returns the mesh position in the local space from the current World matrix values.
  13929. * @returns a new Vector3.
  13930. */
  13931. getPositionExpressedInLocalSpace(): Vector3;
  13932. /**
  13933. * Translates the mesh along the passed Vector3 in its local space.
  13934. * @param vector3 the distance to translate in localspace
  13935. * @returns the TransformNode.
  13936. */
  13937. locallyTranslate(vector3: Vector3): TransformNode;
  13938. private static _lookAtVectorCache;
  13939. /**
  13940. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13941. * @param targetPoint the position (must be in same space as current mesh) to look at
  13942. * @param yawCor optional yaw (y-axis) correction in radians
  13943. * @param pitchCor optional pitch (x-axis) correction in radians
  13944. * @param rollCor optional roll (z-axis) correction in radians
  13945. * @param space the choosen space of the target
  13946. * @returns the TransformNode.
  13947. */
  13948. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13949. /**
  13950. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13951. * This Vector3 is expressed in the World space.
  13952. * @param localAxis axis to rotate
  13953. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13954. */
  13955. getDirection(localAxis: Vector3): Vector3;
  13956. /**
  13957. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13958. * localAxis is expressed in the mesh local space.
  13959. * result is computed in the Wordl space from the mesh World matrix.
  13960. * @param localAxis axis to rotate
  13961. * @param result the resulting transformnode
  13962. * @returns this TransformNode.
  13963. */
  13964. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13965. /**
  13966. * Sets this transform node rotation to the given local axis.
  13967. * @param localAxis the axis in local space
  13968. * @param yawCor optional yaw (y-axis) correction in radians
  13969. * @param pitchCor optional pitch (x-axis) correction in radians
  13970. * @param rollCor optional roll (z-axis) correction in radians
  13971. * @returns this TransformNode
  13972. */
  13973. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13974. /**
  13975. * Sets a new pivot point to the current node
  13976. * @param point defines the new pivot point to use
  13977. * @param space defines if the point is in world or local space (local by default)
  13978. * @returns the current TransformNode
  13979. */
  13980. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13981. /**
  13982. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13983. * @returns the pivot point
  13984. */
  13985. getPivotPoint(): Vector3;
  13986. /**
  13987. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13988. * @param result the vector3 to store the result
  13989. * @returns this TransformNode.
  13990. */
  13991. getPivotPointToRef(result: Vector3): TransformNode;
  13992. /**
  13993. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13994. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13995. */
  13996. getAbsolutePivotPoint(): Vector3;
  13997. /**
  13998. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13999. * @param result vector3 to store the result
  14000. * @returns this TransformNode.
  14001. */
  14002. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14003. /**
  14004. * Defines the passed node as the parent of the current node.
  14005. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14006. * @see https://doc.babylonjs.com/how_to/parenting
  14007. * @param node the node ot set as the parent
  14008. * @returns this TransformNode.
  14009. */
  14010. setParent(node: Nullable<Node>): TransformNode;
  14011. private _nonUniformScaling;
  14012. /**
  14013. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14014. */
  14015. get nonUniformScaling(): boolean;
  14016. /** @hidden */
  14017. _updateNonUniformScalingState(value: boolean): boolean;
  14018. /**
  14019. * Attach the current TransformNode to another TransformNode associated with a bone
  14020. * @param bone Bone affecting the TransformNode
  14021. * @param affectedTransformNode TransformNode associated with the bone
  14022. * @returns this object
  14023. */
  14024. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14025. /**
  14026. * Detach the transform node if its associated with a bone
  14027. * @returns this object
  14028. */
  14029. detachFromBone(): TransformNode;
  14030. private static _rotationAxisCache;
  14031. /**
  14032. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14033. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14034. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14035. * The passed axis is also normalized.
  14036. * @param axis the axis to rotate around
  14037. * @param amount the amount to rotate in radians
  14038. * @param space Space to rotate in (Default: local)
  14039. * @returns the TransformNode.
  14040. */
  14041. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14042. /**
  14043. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14044. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14045. * The passed axis is also normalized. .
  14046. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14047. * @param point the point to rotate around
  14048. * @param axis the axis to rotate around
  14049. * @param amount the amount to rotate in radians
  14050. * @returns the TransformNode
  14051. */
  14052. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14053. /**
  14054. * Translates the mesh along the axis vector for the passed distance in the given space.
  14055. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14056. * @param axis the axis to translate in
  14057. * @param distance the distance to translate
  14058. * @param space Space to rotate in (Default: local)
  14059. * @returns the TransformNode.
  14060. */
  14061. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14062. /**
  14063. * Adds a rotation step to the mesh current rotation.
  14064. * x, y, z are Euler angles expressed in radians.
  14065. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14066. * This means this rotation is made in the mesh local space only.
  14067. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14068. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14069. * ```javascript
  14070. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14071. * ```
  14072. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14073. * 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.
  14074. * @param x Rotation to add
  14075. * @param y Rotation to add
  14076. * @param z Rotation to add
  14077. * @returns the TransformNode.
  14078. */
  14079. addRotation(x: number, y: number, z: number): TransformNode;
  14080. /**
  14081. * @hidden
  14082. */
  14083. protected _getEffectiveParent(): Nullable<Node>;
  14084. /**
  14085. * Computes the world matrix of the node
  14086. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14087. * @returns the world matrix
  14088. */
  14089. computeWorldMatrix(force?: boolean): Matrix;
  14090. /**
  14091. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14092. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14093. */
  14094. resetLocalMatrix(independentOfChildren?: boolean): void;
  14095. protected _afterComputeWorldMatrix(): void;
  14096. /**
  14097. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14098. * @param func callback function to add
  14099. *
  14100. * @returns the TransformNode.
  14101. */
  14102. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14103. /**
  14104. * Removes a registered callback function.
  14105. * @param func callback function to remove
  14106. * @returns the TransformNode.
  14107. */
  14108. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14109. /**
  14110. * Gets the position of the current mesh in camera space
  14111. * @param camera defines the camera to use
  14112. * @returns a position
  14113. */
  14114. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14115. /**
  14116. * Returns the distance from the mesh to the active camera
  14117. * @param camera defines the camera to use
  14118. * @returns the distance
  14119. */
  14120. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14121. /**
  14122. * Clone the current transform node
  14123. * @param name Name of the new clone
  14124. * @param newParent New parent for the clone
  14125. * @param doNotCloneChildren Do not clone children hierarchy
  14126. * @returns the new transform node
  14127. */
  14128. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14129. /**
  14130. * Serializes the objects information.
  14131. * @param currentSerializationObject defines the object to serialize in
  14132. * @returns the serialized object
  14133. */
  14134. serialize(currentSerializationObject?: any): any;
  14135. /**
  14136. * Returns a new TransformNode object parsed from the source provided.
  14137. * @param parsedTransformNode is the source.
  14138. * @param scene the scne the object belongs to
  14139. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14140. * @returns a new TransformNode object parsed from the source provided.
  14141. */
  14142. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14143. /**
  14144. * Get all child-transformNodes of this node
  14145. * @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
  14146. * @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
  14147. * @returns an array of TransformNode
  14148. */
  14149. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14150. /**
  14151. * Releases resources associated with this transform node.
  14152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14154. */
  14155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14156. /**
  14157. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14158. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14159. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14160. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14161. * @returns the current mesh
  14162. */
  14163. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14164. private _syncAbsoluteScalingAndRotation;
  14165. }
  14166. }
  14167. declare module BABYLON {
  14168. /**
  14169. * Class used to override all child animations of a given target
  14170. */
  14171. export class AnimationPropertiesOverride {
  14172. /**
  14173. * Gets or sets a value indicating if animation blending must be used
  14174. */
  14175. enableBlending: boolean;
  14176. /**
  14177. * Gets or sets the blending speed to use when enableBlending is true
  14178. */
  14179. blendingSpeed: number;
  14180. /**
  14181. * Gets or sets the default loop mode to use
  14182. */
  14183. loopMode: number;
  14184. }
  14185. }
  14186. declare module BABYLON {
  14187. /**
  14188. * Class used to store bone information
  14189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14190. */
  14191. export class Bone extends Node {
  14192. /**
  14193. * defines the bone name
  14194. */
  14195. name: string;
  14196. private static _tmpVecs;
  14197. private static _tmpQuat;
  14198. private static _tmpMats;
  14199. /**
  14200. * Gets the list of child bones
  14201. */
  14202. children: Bone[];
  14203. /** Gets the animations associated with this bone */
  14204. animations: Animation[];
  14205. /**
  14206. * Gets or sets bone length
  14207. */
  14208. length: number;
  14209. /**
  14210. * @hidden Internal only
  14211. * Set this value to map this bone to a different index in the transform matrices
  14212. * Set this value to -1 to exclude the bone from the transform matrices
  14213. */
  14214. _index: Nullable<number>;
  14215. private _skeleton;
  14216. private _localMatrix;
  14217. private _restPose;
  14218. private _baseMatrix;
  14219. private _absoluteTransform;
  14220. private _invertedAbsoluteTransform;
  14221. private _parent;
  14222. private _scalingDeterminant;
  14223. private _worldTransform;
  14224. private _localScaling;
  14225. private _localRotation;
  14226. private _localPosition;
  14227. private _needToDecompose;
  14228. private _needToCompose;
  14229. /** @hidden */
  14230. _linkedTransformNode: Nullable<TransformNode>;
  14231. /** @hidden */
  14232. _waitingTransformNodeId: Nullable<string>;
  14233. /** @hidden */
  14234. get _matrix(): Matrix;
  14235. /** @hidden */
  14236. set _matrix(value: Matrix);
  14237. /**
  14238. * Create a new bone
  14239. * @param name defines the bone name
  14240. * @param skeleton defines the parent skeleton
  14241. * @param parentBone defines the parent (can be null if the bone is the root)
  14242. * @param localMatrix defines the local matrix
  14243. * @param restPose defines the rest pose matrix
  14244. * @param baseMatrix defines the base matrix
  14245. * @param index defines index of the bone in the hiearchy
  14246. */
  14247. constructor(
  14248. /**
  14249. * defines the bone name
  14250. */
  14251. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14252. /**
  14253. * Gets the current object class name.
  14254. * @return the class name
  14255. */
  14256. getClassName(): string;
  14257. /**
  14258. * Gets the parent skeleton
  14259. * @returns a skeleton
  14260. */
  14261. getSkeleton(): Skeleton;
  14262. /**
  14263. * Gets parent bone
  14264. * @returns a bone or null if the bone is the root of the bone hierarchy
  14265. */
  14266. getParent(): Nullable<Bone>;
  14267. /**
  14268. * Returns an array containing the root bones
  14269. * @returns an array containing the root bones
  14270. */
  14271. getChildren(): Array<Bone>;
  14272. /**
  14273. * Gets the node index in matrix array generated for rendering
  14274. * @returns the node index
  14275. */
  14276. getIndex(): number;
  14277. /**
  14278. * Sets the parent bone
  14279. * @param parent defines the parent (can be null if the bone is the root)
  14280. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14281. */
  14282. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14283. /**
  14284. * Gets the local matrix
  14285. * @returns a matrix
  14286. */
  14287. getLocalMatrix(): Matrix;
  14288. /**
  14289. * Gets the base matrix (initial matrix which remains unchanged)
  14290. * @returns a matrix
  14291. */
  14292. getBaseMatrix(): Matrix;
  14293. /**
  14294. * Gets the rest pose matrix
  14295. * @returns a matrix
  14296. */
  14297. getRestPose(): Matrix;
  14298. /**
  14299. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14300. */
  14301. getWorldMatrix(): Matrix;
  14302. /**
  14303. * Sets the local matrix to rest pose matrix
  14304. */
  14305. returnToRest(): void;
  14306. /**
  14307. * Gets the inverse of the absolute transform matrix.
  14308. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14309. * @returns a matrix
  14310. */
  14311. getInvertedAbsoluteTransform(): Matrix;
  14312. /**
  14313. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14314. * @returns a matrix
  14315. */
  14316. getAbsoluteTransform(): Matrix;
  14317. /**
  14318. * Links with the given transform node.
  14319. * The local matrix of this bone is copied from the transform node every frame.
  14320. * @param transformNode defines the transform node to link to
  14321. */
  14322. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14323. /**
  14324. * Gets the node used to drive the bone's transformation
  14325. * @returns a transform node or null
  14326. */
  14327. getTransformNode(): Nullable<TransformNode>;
  14328. /** Gets or sets current position (in local space) */
  14329. get position(): Vector3;
  14330. set position(newPosition: Vector3);
  14331. /** Gets or sets current rotation (in local space) */
  14332. get rotation(): Vector3;
  14333. set rotation(newRotation: Vector3);
  14334. /** Gets or sets current rotation quaternion (in local space) */
  14335. get rotationQuaternion(): Quaternion;
  14336. set rotationQuaternion(newRotation: Quaternion);
  14337. /** Gets or sets current scaling (in local space) */
  14338. get scaling(): Vector3;
  14339. set scaling(newScaling: Vector3);
  14340. /**
  14341. * Gets the animation properties override
  14342. */
  14343. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14344. private _decompose;
  14345. private _compose;
  14346. /**
  14347. * Update the base and local matrices
  14348. * @param matrix defines the new base or local matrix
  14349. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14350. * @param updateLocalMatrix defines if the local matrix should be updated
  14351. */
  14352. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14353. /** @hidden */
  14354. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14355. /**
  14356. * Flag the bone as dirty (Forcing it to update everything)
  14357. */
  14358. markAsDirty(): void;
  14359. /** @hidden */
  14360. _markAsDirtyAndCompose(): void;
  14361. private _markAsDirtyAndDecompose;
  14362. /**
  14363. * Translate the bone in local or world space
  14364. * @param vec The amount to translate the bone
  14365. * @param space The space that the translation is in
  14366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14367. */
  14368. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14369. /**
  14370. * Set the postion of the bone in local or world space
  14371. * @param position The position to set the bone
  14372. * @param space The space that the position is in
  14373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14374. */
  14375. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14376. /**
  14377. * Set the absolute position of the bone (world space)
  14378. * @param position The position to set the bone
  14379. * @param mesh The mesh that this bone is attached to
  14380. */
  14381. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14382. /**
  14383. * Scale the bone on the x, y and z axes (in local space)
  14384. * @param x The amount to scale the bone on the x axis
  14385. * @param y The amount to scale the bone on the y axis
  14386. * @param z The amount to scale the bone on the z axis
  14387. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14388. */
  14389. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14390. /**
  14391. * Set the bone scaling in local space
  14392. * @param scale defines the scaling vector
  14393. */
  14394. setScale(scale: Vector3): void;
  14395. /**
  14396. * Gets the current scaling in local space
  14397. * @returns the current scaling vector
  14398. */
  14399. getScale(): Vector3;
  14400. /**
  14401. * Gets the current scaling in local space and stores it in a target vector
  14402. * @param result defines the target vector
  14403. */
  14404. getScaleToRef(result: Vector3): void;
  14405. /**
  14406. * Set the yaw, pitch, and roll of the bone in local or world space
  14407. * @param yaw The rotation of the bone on the y axis
  14408. * @param pitch The rotation of the bone on the x axis
  14409. * @param roll The rotation of the bone on the z axis
  14410. * @param space The space that the axes of rotation are in
  14411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14412. */
  14413. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14414. /**
  14415. * Add a rotation to the bone on an axis in local or world space
  14416. * @param axis The axis to rotate the bone on
  14417. * @param amount The amount to rotate the bone
  14418. * @param space The space that the axis is in
  14419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14420. */
  14421. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14422. /**
  14423. * Set the rotation of the bone to a particular axis angle in local or world space
  14424. * @param axis The axis to rotate the bone on
  14425. * @param angle The angle that the bone should be rotated to
  14426. * @param space The space that the axis is in
  14427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14428. */
  14429. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14430. /**
  14431. * Set the euler rotation of the bone in local of world space
  14432. * @param rotation The euler rotation that the bone should be set to
  14433. * @param space The space that the rotation is in
  14434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14435. */
  14436. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14437. /**
  14438. * Set the quaternion rotation of the bone in local of world space
  14439. * @param quat The quaternion rotation that the bone should be set to
  14440. * @param space The space that the rotation is in
  14441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14442. */
  14443. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14444. /**
  14445. * Set the rotation matrix of the bone in local of world space
  14446. * @param rotMat The rotation matrix that the bone should be set to
  14447. * @param space The space that the rotation is in
  14448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14449. */
  14450. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14451. private _rotateWithMatrix;
  14452. private _getNegativeRotationToRef;
  14453. /**
  14454. * Get the position of the bone in local or world space
  14455. * @param space The space that the returned position is in
  14456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14457. * @returns The position of the bone
  14458. */
  14459. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14460. /**
  14461. * Copy the position of the bone to a vector3 in local or world space
  14462. * @param space The space that the returned position is in
  14463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14464. * @param result The vector3 to copy the position to
  14465. */
  14466. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14467. /**
  14468. * Get the absolute position of the bone (world space)
  14469. * @param mesh The mesh that this bone is attached to
  14470. * @returns The absolute position of the bone
  14471. */
  14472. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14473. /**
  14474. * Copy the absolute position of the bone (world space) to the result param
  14475. * @param mesh The mesh that this bone is attached to
  14476. * @param result The vector3 to copy the absolute position to
  14477. */
  14478. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14479. /**
  14480. * Compute the absolute transforms of this bone and its children
  14481. */
  14482. computeAbsoluteTransforms(): void;
  14483. /**
  14484. * Get the world direction from an axis that is in the local space of the bone
  14485. * @param localAxis The local direction that is used to compute the world direction
  14486. * @param mesh The mesh that this bone is attached to
  14487. * @returns The world direction
  14488. */
  14489. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14490. /**
  14491. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14492. * @param localAxis The local direction that is used to compute the world direction
  14493. * @param mesh The mesh that this bone is attached to
  14494. * @param result The vector3 that the world direction will be copied to
  14495. */
  14496. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14497. /**
  14498. * Get the euler rotation of the bone in local or world space
  14499. * @param space The space that the rotation should be in
  14500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14501. * @returns The euler rotation
  14502. */
  14503. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14504. /**
  14505. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14506. * @param space The space that the rotation should be in
  14507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14508. * @param result The vector3 that the rotation should be copied to
  14509. */
  14510. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14511. /**
  14512. * Get the quaternion rotation of the bone in either local or world space
  14513. * @param space The space that the rotation should be in
  14514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14515. * @returns The quaternion rotation
  14516. */
  14517. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14518. /**
  14519. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14520. * @param space The space that the rotation should be in
  14521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14522. * @param result The quaternion that the rotation should be copied to
  14523. */
  14524. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14525. /**
  14526. * Get the rotation matrix of the bone in local or world space
  14527. * @param space The space that the rotation should be in
  14528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14529. * @returns The rotation matrix
  14530. */
  14531. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14532. /**
  14533. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14534. * @param space The space that the rotation should be in
  14535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14536. * @param result The quaternion that the rotation should be copied to
  14537. */
  14538. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14539. /**
  14540. * Get the world position of a point that is in the local space of the bone
  14541. * @param position The local position
  14542. * @param mesh The mesh that this bone is attached to
  14543. * @returns The world position
  14544. */
  14545. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14546. /**
  14547. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14548. * @param position The local position
  14549. * @param mesh The mesh that this bone is attached to
  14550. * @param result The vector3 that the world position should be copied to
  14551. */
  14552. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14553. /**
  14554. * Get the local position of a point that is in world space
  14555. * @param position The world position
  14556. * @param mesh The mesh that this bone is attached to
  14557. * @returns The local position
  14558. */
  14559. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14560. /**
  14561. * Get the local position of a point that is in world space and copy it to the result param
  14562. * @param position The world position
  14563. * @param mesh The mesh that this bone is attached to
  14564. * @param result The vector3 that the local position should be copied to
  14565. */
  14566. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14567. }
  14568. }
  14569. declare module BABYLON {
  14570. /**
  14571. * Defines a runtime animation
  14572. */
  14573. export class RuntimeAnimation {
  14574. private _events;
  14575. /**
  14576. * The current frame of the runtime animation
  14577. */
  14578. private _currentFrame;
  14579. /**
  14580. * The animation used by the runtime animation
  14581. */
  14582. private _animation;
  14583. /**
  14584. * The target of the runtime animation
  14585. */
  14586. private _target;
  14587. /**
  14588. * The initiating animatable
  14589. */
  14590. private _host;
  14591. /**
  14592. * The original value of the runtime animation
  14593. */
  14594. private _originalValue;
  14595. /**
  14596. * The original blend value of the runtime animation
  14597. */
  14598. private _originalBlendValue;
  14599. /**
  14600. * The offsets cache of the runtime animation
  14601. */
  14602. private _offsetsCache;
  14603. /**
  14604. * The high limits cache of the runtime animation
  14605. */
  14606. private _highLimitsCache;
  14607. /**
  14608. * Specifies if the runtime animation has been stopped
  14609. */
  14610. private _stopped;
  14611. /**
  14612. * The blending factor of the runtime animation
  14613. */
  14614. private _blendingFactor;
  14615. /**
  14616. * The BabylonJS scene
  14617. */
  14618. private _scene;
  14619. /**
  14620. * The current value of the runtime animation
  14621. */
  14622. private _currentValue;
  14623. /** @hidden */
  14624. _animationState: _IAnimationState;
  14625. /**
  14626. * The active target of the runtime animation
  14627. */
  14628. private _activeTargets;
  14629. private _currentActiveTarget;
  14630. private _directTarget;
  14631. /**
  14632. * The target path of the runtime animation
  14633. */
  14634. private _targetPath;
  14635. /**
  14636. * The weight of the runtime animation
  14637. */
  14638. private _weight;
  14639. /**
  14640. * The ratio offset of the runtime animation
  14641. */
  14642. private _ratioOffset;
  14643. /**
  14644. * The previous delay of the runtime animation
  14645. */
  14646. private _previousDelay;
  14647. /**
  14648. * The previous ratio of the runtime animation
  14649. */
  14650. private _previousRatio;
  14651. private _enableBlending;
  14652. private _keys;
  14653. private _minFrame;
  14654. private _maxFrame;
  14655. private _minValue;
  14656. private _maxValue;
  14657. private _targetIsArray;
  14658. /**
  14659. * Gets the current frame of the runtime animation
  14660. */
  14661. get currentFrame(): number;
  14662. /**
  14663. * Gets the weight of the runtime animation
  14664. */
  14665. get weight(): number;
  14666. /**
  14667. * Gets the current value of the runtime animation
  14668. */
  14669. get currentValue(): any;
  14670. /**
  14671. * Gets the target path of the runtime animation
  14672. */
  14673. get targetPath(): string;
  14674. /**
  14675. * Gets the actual target of the runtime animation
  14676. */
  14677. get target(): any;
  14678. /**
  14679. * Gets the additive state of the runtime animation
  14680. */
  14681. get isAdditive(): boolean;
  14682. /** @hidden */
  14683. _onLoop: () => void;
  14684. /**
  14685. * Create a new RuntimeAnimation object
  14686. * @param target defines the target of the animation
  14687. * @param animation defines the source animation object
  14688. * @param scene defines the hosting scene
  14689. * @param host defines the initiating Animatable
  14690. */
  14691. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14692. private _preparePath;
  14693. /**
  14694. * Gets the animation from the runtime animation
  14695. */
  14696. get animation(): Animation;
  14697. /**
  14698. * Resets the runtime animation to the beginning
  14699. * @param restoreOriginal defines whether to restore the target property to the original value
  14700. */
  14701. reset(restoreOriginal?: boolean): void;
  14702. /**
  14703. * Specifies if the runtime animation is stopped
  14704. * @returns Boolean specifying if the runtime animation is stopped
  14705. */
  14706. isStopped(): boolean;
  14707. /**
  14708. * Disposes of the runtime animation
  14709. */
  14710. dispose(): void;
  14711. /**
  14712. * Apply the interpolated value to the target
  14713. * @param currentValue defines the value computed by the animation
  14714. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14715. */
  14716. setValue(currentValue: any, weight: number): void;
  14717. private _getOriginalValues;
  14718. private _setValue;
  14719. /**
  14720. * Gets the loop pmode of the runtime animation
  14721. * @returns Loop Mode
  14722. */
  14723. private _getCorrectLoopMode;
  14724. /**
  14725. * Move the current animation to a given frame
  14726. * @param frame defines the frame to move to
  14727. */
  14728. goToFrame(frame: number): void;
  14729. /**
  14730. * @hidden Internal use only
  14731. */
  14732. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14733. /**
  14734. * Execute the current animation
  14735. * @param delay defines the delay to add to the current frame
  14736. * @param from defines the lower bound of the animation range
  14737. * @param to defines the upper bound of the animation range
  14738. * @param loop defines if the current animation must loop
  14739. * @param speedRatio defines the current speed ratio
  14740. * @param weight defines the weight of the animation (default is -1 so no weight)
  14741. * @param onLoop optional callback called when animation loops
  14742. * @returns a boolean indicating if the animation is running
  14743. */
  14744. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. /**
  14749. * Class used to store an actual running animation
  14750. */
  14751. export class Animatable {
  14752. /** defines the target object */
  14753. target: any;
  14754. /** defines the starting frame number (default is 0) */
  14755. fromFrame: number;
  14756. /** defines the ending frame number (default is 100) */
  14757. toFrame: number;
  14758. /** defines if the animation must loop (default is false) */
  14759. loopAnimation: boolean;
  14760. /** defines a callback to call when animation ends if it is not looping */
  14761. onAnimationEnd?: (() => void) | null | undefined;
  14762. /** defines a callback to call when animation loops */
  14763. onAnimationLoop?: (() => void) | null | undefined;
  14764. /** defines whether the animation should be evaluated additively */
  14765. isAdditive: boolean;
  14766. private _localDelayOffset;
  14767. private _pausedDelay;
  14768. private _runtimeAnimations;
  14769. private _paused;
  14770. private _scene;
  14771. private _speedRatio;
  14772. private _weight;
  14773. private _syncRoot;
  14774. /**
  14775. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14776. * This will only apply for non looping animation (default is true)
  14777. */
  14778. disposeOnEnd: boolean;
  14779. /**
  14780. * Gets a boolean indicating if the animation has started
  14781. */
  14782. animationStarted: boolean;
  14783. /**
  14784. * Observer raised when the animation ends
  14785. */
  14786. onAnimationEndObservable: Observable<Animatable>;
  14787. /**
  14788. * Observer raised when the animation loops
  14789. */
  14790. onAnimationLoopObservable: Observable<Animatable>;
  14791. /**
  14792. * Gets the root Animatable used to synchronize and normalize animations
  14793. */
  14794. get syncRoot(): Nullable<Animatable>;
  14795. /**
  14796. * Gets the current frame of the first RuntimeAnimation
  14797. * Used to synchronize Animatables
  14798. */
  14799. get masterFrame(): number;
  14800. /**
  14801. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14802. */
  14803. get weight(): number;
  14804. set weight(value: number);
  14805. /**
  14806. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14807. */
  14808. get speedRatio(): number;
  14809. set speedRatio(value: number);
  14810. /**
  14811. * Creates a new Animatable
  14812. * @param scene defines the hosting scene
  14813. * @param target defines the target object
  14814. * @param fromFrame defines the starting frame number (default is 0)
  14815. * @param toFrame defines the ending frame number (default is 100)
  14816. * @param loopAnimation defines if the animation must loop (default is false)
  14817. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14818. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14819. * @param animations defines a group of animation to add to the new Animatable
  14820. * @param onAnimationLoop defines a callback to call when animation loops
  14821. * @param isAdditive defines whether the animation should be evaluated additively
  14822. */
  14823. constructor(scene: Scene,
  14824. /** defines the target object */
  14825. target: any,
  14826. /** defines the starting frame number (default is 0) */
  14827. fromFrame?: number,
  14828. /** defines the ending frame number (default is 100) */
  14829. toFrame?: number,
  14830. /** defines if the animation must loop (default is false) */
  14831. loopAnimation?: boolean, speedRatio?: number,
  14832. /** defines a callback to call when animation ends if it is not looping */
  14833. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14834. /** defines a callback to call when animation loops */
  14835. onAnimationLoop?: (() => void) | null | undefined,
  14836. /** defines whether the animation should be evaluated additively */
  14837. isAdditive?: boolean);
  14838. /**
  14839. * Synchronize and normalize current Animatable with a source Animatable
  14840. * This is useful when using animation weights and when animations are not of the same length
  14841. * @param root defines the root Animatable to synchronize with
  14842. * @returns the current Animatable
  14843. */
  14844. syncWith(root: Animatable): Animatable;
  14845. /**
  14846. * Gets the list of runtime animations
  14847. * @returns an array of RuntimeAnimation
  14848. */
  14849. getAnimations(): RuntimeAnimation[];
  14850. /**
  14851. * Adds more animations to the current animatable
  14852. * @param target defines the target of the animations
  14853. * @param animations defines the new animations to add
  14854. */
  14855. appendAnimations(target: any, animations: Animation[]): void;
  14856. /**
  14857. * Gets the source animation for a specific property
  14858. * @param property defines the propertyu to look for
  14859. * @returns null or the source animation for the given property
  14860. */
  14861. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14862. /**
  14863. * Gets the runtime animation for a specific property
  14864. * @param property defines the propertyu to look for
  14865. * @returns null or the runtime animation for the given property
  14866. */
  14867. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14868. /**
  14869. * Resets the animatable to its original state
  14870. */
  14871. reset(): void;
  14872. /**
  14873. * Allows the animatable to blend with current running animations
  14874. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14875. * @param blendingSpeed defines the blending speed to use
  14876. */
  14877. enableBlending(blendingSpeed: number): void;
  14878. /**
  14879. * Disable animation blending
  14880. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14881. */
  14882. disableBlending(): void;
  14883. /**
  14884. * Jump directly to a given frame
  14885. * @param frame defines the frame to jump to
  14886. */
  14887. goToFrame(frame: number): void;
  14888. /**
  14889. * Pause the animation
  14890. */
  14891. pause(): void;
  14892. /**
  14893. * Restart the animation
  14894. */
  14895. restart(): void;
  14896. private _raiseOnAnimationEnd;
  14897. /**
  14898. * Stop and delete the current animation
  14899. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14900. * @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)
  14901. */
  14902. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14903. /**
  14904. * Wait asynchronously for the animation to end
  14905. * @returns a promise which will be fullfilled when the animation ends
  14906. */
  14907. waitAsync(): Promise<Animatable>;
  14908. /** @hidden */
  14909. _animate(delay: number): boolean;
  14910. }
  14911. interface Scene {
  14912. /** @hidden */
  14913. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14914. /** @hidden */
  14915. _processLateAnimationBindingsForMatrices(holder: {
  14916. totalWeight: number;
  14917. totalAdditiveWeight: number;
  14918. animations: RuntimeAnimation[];
  14919. additiveAnimations: RuntimeAnimation[];
  14920. originalValue: Matrix;
  14921. }): any;
  14922. /** @hidden */
  14923. _processLateAnimationBindingsForQuaternions(holder: {
  14924. totalWeight: number;
  14925. totalAdditiveWeight: number;
  14926. animations: RuntimeAnimation[];
  14927. additiveAnimations: RuntimeAnimation[];
  14928. originalValue: Quaternion;
  14929. }, refQuaternion: Quaternion): Quaternion;
  14930. /** @hidden */
  14931. _processLateAnimationBindings(): void;
  14932. /**
  14933. * Will start the animation sequence of a given target
  14934. * @param target defines the target
  14935. * @param from defines from which frame should animation start
  14936. * @param to defines until which frame should animation run.
  14937. * @param weight defines the weight to apply to the animation (1.0 by default)
  14938. * @param loop defines if the animation loops
  14939. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14940. * @param onAnimationEnd defines the function to be executed when the animation ends
  14941. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14942. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14943. * @param onAnimationLoop defines the callback to call when an animation loops
  14944. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14945. * @returns the animatable object created for this animation
  14946. */
  14947. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14948. /**
  14949. * Will start the animation sequence of a given target
  14950. * @param target defines the target
  14951. * @param from defines from which frame should animation start
  14952. * @param to defines until which frame should animation run.
  14953. * @param loop defines if the animation loops
  14954. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14955. * @param onAnimationEnd defines the function to be executed when the animation ends
  14956. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14957. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14958. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14959. * @param onAnimationLoop defines the callback to call when an animation loops
  14960. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14961. * @returns the animatable object created for this animation
  14962. */
  14963. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14964. /**
  14965. * Will start the animation sequence of a given target and its hierarchy
  14966. * @param target defines the target
  14967. * @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.
  14968. * @param from defines from which frame should animation start
  14969. * @param to defines until which frame should animation run.
  14970. * @param loop defines if the animation loops
  14971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14972. * @param onAnimationEnd defines the function to be executed when the animation ends
  14973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14974. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14976. * @param onAnimationLoop defines the callback to call when an animation loops
  14977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14978. * @returns the list of created animatables
  14979. */
  14980. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14981. /**
  14982. * Begin a new animation on a given node
  14983. * @param target defines the target where the animation will take place
  14984. * @param animations defines the list of animations to start
  14985. * @param from defines the initial value
  14986. * @param to defines the final value
  14987. * @param loop defines if you want animation to loop (off by default)
  14988. * @param speedRatio defines the speed ratio to apply to all animations
  14989. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14990. * @param onAnimationLoop defines the callback to call when an animation loops
  14991. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14992. * @returns the list of created animatables
  14993. */
  14994. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14995. /**
  14996. * Begin a new animation on a given node and its hierarchy
  14997. * @param target defines the root node where the animation will take place
  14998. * @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.
  14999. * @param animations defines the list of animations to start
  15000. * @param from defines the initial value
  15001. * @param to defines the final value
  15002. * @param loop defines if you want animation to loop (off by default)
  15003. * @param speedRatio defines the speed ratio to apply to all animations
  15004. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15005. * @param onAnimationLoop defines the callback to call when an animation loops
  15006. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15007. * @returns the list of animatables created for all nodes
  15008. */
  15009. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15010. /**
  15011. * Gets the animatable associated with a specific target
  15012. * @param target defines the target of the animatable
  15013. * @returns the required animatable if found
  15014. */
  15015. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15016. /**
  15017. * Gets all animatables associated with a given target
  15018. * @param target defines the target to look animatables for
  15019. * @returns an array of Animatables
  15020. */
  15021. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15022. /**
  15023. * Stops and removes all animations that have been applied to the scene
  15024. */
  15025. stopAllAnimations(): void;
  15026. /**
  15027. * Gets the current delta time used by animation engine
  15028. */
  15029. deltaTime: number;
  15030. }
  15031. interface Bone {
  15032. /**
  15033. * Copy an animation range from another bone
  15034. * @param source defines the source bone
  15035. * @param rangeName defines the range name to copy
  15036. * @param frameOffset defines the frame offset
  15037. * @param rescaleAsRequired defines if rescaling must be applied if required
  15038. * @param skelDimensionsRatio defines the scaling ratio
  15039. * @returns true if operation was successful
  15040. */
  15041. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15042. }
  15043. }
  15044. declare module BABYLON {
  15045. /**
  15046. * Class used to handle skinning animations
  15047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15048. */
  15049. export class Skeleton implements IAnimatable {
  15050. /** defines the skeleton name */
  15051. name: string;
  15052. /** defines the skeleton Id */
  15053. id: string;
  15054. /**
  15055. * Defines the list of child bones
  15056. */
  15057. bones: Bone[];
  15058. /**
  15059. * Defines an estimate of the dimension of the skeleton at rest
  15060. */
  15061. dimensionsAtRest: Vector3;
  15062. /**
  15063. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15064. */
  15065. needInitialSkinMatrix: boolean;
  15066. /**
  15067. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15068. */
  15069. overrideMesh: Nullable<AbstractMesh>;
  15070. /**
  15071. * Gets the list of animations attached to this skeleton
  15072. */
  15073. animations: Array<Animation>;
  15074. private _scene;
  15075. private _isDirty;
  15076. private _transformMatrices;
  15077. private _transformMatrixTexture;
  15078. private _meshesWithPoseMatrix;
  15079. private _animatables;
  15080. private _identity;
  15081. private _synchronizedWithMesh;
  15082. private _ranges;
  15083. private _lastAbsoluteTransformsUpdateId;
  15084. private _canUseTextureForBones;
  15085. private _uniqueId;
  15086. /** @hidden */
  15087. _numBonesWithLinkedTransformNode: number;
  15088. /** @hidden */
  15089. _hasWaitingData: Nullable<boolean>;
  15090. /**
  15091. * Specifies if the skeleton should be serialized
  15092. */
  15093. doNotSerialize: boolean;
  15094. private _useTextureToStoreBoneMatrices;
  15095. /**
  15096. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15097. * Please note that this option is not available if the hardware does not support it
  15098. */
  15099. get useTextureToStoreBoneMatrices(): boolean;
  15100. set useTextureToStoreBoneMatrices(value: boolean);
  15101. private _animationPropertiesOverride;
  15102. /**
  15103. * Gets or sets the animation properties override
  15104. */
  15105. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15106. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15107. /**
  15108. * List of inspectable custom properties (used by the Inspector)
  15109. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15110. */
  15111. inspectableCustomProperties: IInspectable[];
  15112. /**
  15113. * An observable triggered before computing the skeleton's matrices
  15114. */
  15115. onBeforeComputeObservable: Observable<Skeleton>;
  15116. /**
  15117. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15118. */
  15119. get isUsingTextureForMatrices(): boolean;
  15120. /**
  15121. * Gets the unique ID of this skeleton
  15122. */
  15123. get uniqueId(): number;
  15124. /**
  15125. * Creates a new skeleton
  15126. * @param name defines the skeleton name
  15127. * @param id defines the skeleton Id
  15128. * @param scene defines the hosting scene
  15129. */
  15130. constructor(
  15131. /** defines the skeleton name */
  15132. name: string,
  15133. /** defines the skeleton Id */
  15134. id: string, scene: Scene);
  15135. /**
  15136. * Gets the current object class name.
  15137. * @return the class name
  15138. */
  15139. getClassName(): string;
  15140. /**
  15141. * Returns an array containing the root bones
  15142. * @returns an array containing the root bones
  15143. */
  15144. getChildren(): Array<Bone>;
  15145. /**
  15146. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15147. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15148. * @returns a Float32Array containing matrices data
  15149. */
  15150. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15151. /**
  15152. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15153. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15154. * @returns a raw texture containing the data
  15155. */
  15156. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15157. /**
  15158. * Gets the current hosting scene
  15159. * @returns a scene object
  15160. */
  15161. getScene(): Scene;
  15162. /**
  15163. * Gets a string representing the current skeleton data
  15164. * @param fullDetails defines a boolean indicating if we want a verbose version
  15165. * @returns a string representing the current skeleton data
  15166. */
  15167. toString(fullDetails?: boolean): string;
  15168. /**
  15169. * Get bone's index searching by name
  15170. * @param name defines bone's name to search for
  15171. * @return the indice of the bone. Returns -1 if not found
  15172. */
  15173. getBoneIndexByName(name: string): number;
  15174. /**
  15175. * Creater a new animation range
  15176. * @param name defines the name of the range
  15177. * @param from defines the start key
  15178. * @param to defines the end key
  15179. */
  15180. createAnimationRange(name: string, from: number, to: number): void;
  15181. /**
  15182. * Delete a specific animation range
  15183. * @param name defines the name of the range
  15184. * @param deleteFrames defines if frames must be removed as well
  15185. */
  15186. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15187. /**
  15188. * Gets a specific animation range
  15189. * @param name defines the name of the range to look for
  15190. * @returns the requested animation range or null if not found
  15191. */
  15192. getAnimationRange(name: string): Nullable<AnimationRange>;
  15193. /**
  15194. * Gets the list of all animation ranges defined on this skeleton
  15195. * @returns an array
  15196. */
  15197. getAnimationRanges(): Nullable<AnimationRange>[];
  15198. /**
  15199. * Copy animation range from a source skeleton.
  15200. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15201. * @param source defines the source skeleton
  15202. * @param name defines the name of the range to copy
  15203. * @param rescaleAsRequired defines if rescaling must be applied if required
  15204. * @returns true if operation was successful
  15205. */
  15206. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15207. /**
  15208. * Forces the skeleton to go to rest pose
  15209. */
  15210. returnToRest(): void;
  15211. private _getHighestAnimationFrame;
  15212. /**
  15213. * Begin a specific animation range
  15214. * @param name defines the name of the range to start
  15215. * @param loop defines if looping must be turned on (false by default)
  15216. * @param speedRatio defines the speed ratio to apply (1 by default)
  15217. * @param onAnimationEnd defines a callback which will be called when animation will end
  15218. * @returns a new animatable
  15219. */
  15220. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15221. /**
  15222. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15223. * @param skeleton defines the Skeleton containing the animation range to convert
  15224. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15225. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15226. * @returns the original skeleton
  15227. */
  15228. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15229. /** @hidden */
  15230. _markAsDirty(): void;
  15231. /** @hidden */
  15232. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15233. /** @hidden */
  15234. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15235. private _computeTransformMatrices;
  15236. /**
  15237. * Build all resources required to render a skeleton
  15238. */
  15239. prepare(): void;
  15240. /**
  15241. * Gets the list of animatables currently running for this skeleton
  15242. * @returns an array of animatables
  15243. */
  15244. getAnimatables(): IAnimatable[];
  15245. /**
  15246. * Clone the current skeleton
  15247. * @param name defines the name of the new skeleton
  15248. * @param id defines the id of the new skeleton
  15249. * @returns the new skeleton
  15250. */
  15251. clone(name: string, id?: string): Skeleton;
  15252. /**
  15253. * Enable animation blending for this skeleton
  15254. * @param blendingSpeed defines the blending speed to apply
  15255. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15256. */
  15257. enableBlending(blendingSpeed?: number): void;
  15258. /**
  15259. * Releases all resources associated with the current skeleton
  15260. */
  15261. dispose(): void;
  15262. /**
  15263. * Serialize the skeleton in a JSON object
  15264. * @returns a JSON object
  15265. */
  15266. serialize(): any;
  15267. /**
  15268. * Creates a new skeleton from serialized data
  15269. * @param parsedSkeleton defines the serialized data
  15270. * @param scene defines the hosting scene
  15271. * @returns a new skeleton
  15272. */
  15273. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15274. /**
  15275. * Compute all node absolute transforms
  15276. * @param forceUpdate defines if computation must be done even if cache is up to date
  15277. */
  15278. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15279. /**
  15280. * Gets the root pose matrix
  15281. * @returns a matrix
  15282. */
  15283. getPoseMatrix(): Nullable<Matrix>;
  15284. /**
  15285. * Sorts bones per internal index
  15286. */
  15287. sortBones(): void;
  15288. private _sortBones;
  15289. }
  15290. }
  15291. declare module BABYLON {
  15292. /**
  15293. * Creates an instance based on a source mesh.
  15294. */
  15295. export class InstancedMesh extends AbstractMesh {
  15296. private _sourceMesh;
  15297. private _currentLOD;
  15298. /** @hidden */
  15299. _indexInSourceMeshInstanceArray: number;
  15300. constructor(name: string, source: Mesh);
  15301. /**
  15302. * Returns the string "InstancedMesh".
  15303. */
  15304. getClassName(): string;
  15305. /** Gets the list of lights affecting that mesh */
  15306. get lightSources(): Light[];
  15307. _resyncLightSources(): void;
  15308. _resyncLightSource(light: Light): void;
  15309. _removeLightSource(light: Light, dispose: boolean): void;
  15310. /**
  15311. * If the source mesh receives shadows
  15312. */
  15313. get receiveShadows(): boolean;
  15314. /**
  15315. * The material of the source mesh
  15316. */
  15317. get material(): Nullable<Material>;
  15318. /**
  15319. * Visibility of the source mesh
  15320. */
  15321. get visibility(): number;
  15322. /**
  15323. * Skeleton of the source mesh
  15324. */
  15325. get skeleton(): Nullable<Skeleton>;
  15326. /**
  15327. * Rendering ground id of the source mesh
  15328. */
  15329. get renderingGroupId(): number;
  15330. set renderingGroupId(value: number);
  15331. /**
  15332. * Returns the total number of vertices (integer).
  15333. */
  15334. getTotalVertices(): number;
  15335. /**
  15336. * Returns a positive integer : the total number of indices in this mesh geometry.
  15337. * @returns the numner of indices or zero if the mesh has no geometry.
  15338. */
  15339. getTotalIndices(): number;
  15340. /**
  15341. * The source mesh of the instance
  15342. */
  15343. get sourceMesh(): Mesh;
  15344. /**
  15345. * Is this node ready to be used/rendered
  15346. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15347. * @return {boolean} is it ready
  15348. */
  15349. isReady(completeCheck?: boolean): boolean;
  15350. /**
  15351. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15352. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15353. * @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.
  15354. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15355. */
  15356. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15357. /**
  15358. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15359. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15360. * The `data` are either a numeric array either a Float32Array.
  15361. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15362. * 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).
  15363. * Note that a new underlying VertexBuffer object is created each call.
  15364. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15365. *
  15366. * Possible `kind` values :
  15367. * - VertexBuffer.PositionKind
  15368. * - VertexBuffer.UVKind
  15369. * - VertexBuffer.UV2Kind
  15370. * - VertexBuffer.UV3Kind
  15371. * - VertexBuffer.UV4Kind
  15372. * - VertexBuffer.UV5Kind
  15373. * - VertexBuffer.UV6Kind
  15374. * - VertexBuffer.ColorKind
  15375. * - VertexBuffer.MatricesIndicesKind
  15376. * - VertexBuffer.MatricesIndicesExtraKind
  15377. * - VertexBuffer.MatricesWeightsKind
  15378. * - VertexBuffer.MatricesWeightsExtraKind
  15379. *
  15380. * Returns the Mesh.
  15381. */
  15382. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15383. /**
  15384. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15385. * If the mesh has no geometry, it is simply returned as it is.
  15386. * The `data` are either a numeric array either a Float32Array.
  15387. * No new underlying VertexBuffer object is created.
  15388. * 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.
  15389. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15390. *
  15391. * Possible `kind` values :
  15392. * - VertexBuffer.PositionKind
  15393. * - VertexBuffer.UVKind
  15394. * - VertexBuffer.UV2Kind
  15395. * - VertexBuffer.UV3Kind
  15396. * - VertexBuffer.UV4Kind
  15397. * - VertexBuffer.UV5Kind
  15398. * - VertexBuffer.UV6Kind
  15399. * - VertexBuffer.ColorKind
  15400. * - VertexBuffer.MatricesIndicesKind
  15401. * - VertexBuffer.MatricesIndicesExtraKind
  15402. * - VertexBuffer.MatricesWeightsKind
  15403. * - VertexBuffer.MatricesWeightsExtraKind
  15404. *
  15405. * Returns the Mesh.
  15406. */
  15407. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15408. /**
  15409. * Sets the mesh indices.
  15410. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15411. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15412. * This method creates a new index buffer each call.
  15413. * Returns the Mesh.
  15414. */
  15415. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15416. /**
  15417. * Boolean : True if the mesh owns the requested kind of data.
  15418. */
  15419. isVerticesDataPresent(kind: string): boolean;
  15420. /**
  15421. * Returns an array of indices (IndicesArray).
  15422. */
  15423. getIndices(): Nullable<IndicesArray>;
  15424. get _positions(): Nullable<Vector3[]>;
  15425. /**
  15426. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15427. * This means the mesh underlying bounding box and sphere are recomputed.
  15428. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15429. * @returns the current mesh
  15430. */
  15431. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15432. /** @hidden */
  15433. _preActivate(): InstancedMesh;
  15434. /** @hidden */
  15435. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15436. /** @hidden */
  15437. _postActivate(): void;
  15438. getWorldMatrix(): Matrix;
  15439. get isAnInstance(): boolean;
  15440. /**
  15441. * Returns the current associated LOD AbstractMesh.
  15442. */
  15443. getLOD(camera: Camera): AbstractMesh;
  15444. /** @hidden */
  15445. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15446. /** @hidden */
  15447. _syncSubMeshes(): InstancedMesh;
  15448. /** @hidden */
  15449. _generatePointsArray(): boolean;
  15450. /**
  15451. * Creates a new InstancedMesh from the current mesh.
  15452. * - name (string) : the cloned mesh name
  15453. * - newParent (optional Node) : the optional Node to parent the clone to.
  15454. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15455. *
  15456. * Returns the clone.
  15457. */
  15458. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15459. /**
  15460. * Disposes the InstancedMesh.
  15461. * Returns nothing.
  15462. */
  15463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15464. }
  15465. interface Mesh {
  15466. /**
  15467. * Register a custom buffer that will be instanced
  15468. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15469. * @param kind defines the buffer kind
  15470. * @param stride defines the stride in floats
  15471. */
  15472. registerInstancedBuffer(kind: string, stride: number): void;
  15473. /** @hidden */
  15474. _userInstancedBuffersStorage: {
  15475. data: {
  15476. [key: string]: Float32Array;
  15477. };
  15478. sizes: {
  15479. [key: string]: number;
  15480. };
  15481. vertexBuffers: {
  15482. [key: string]: Nullable<VertexBuffer>;
  15483. };
  15484. strides: {
  15485. [key: string]: number;
  15486. };
  15487. };
  15488. }
  15489. interface AbstractMesh {
  15490. /**
  15491. * Object used to store instanced buffers defined by user
  15492. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15493. */
  15494. instancedBuffers: {
  15495. [key: string]: any;
  15496. };
  15497. }
  15498. }
  15499. declare module BABYLON {
  15500. /**
  15501. * Defines the options associated with the creation of a shader material.
  15502. */
  15503. export interface IShaderMaterialOptions {
  15504. /**
  15505. * Does the material work in alpha blend mode
  15506. */
  15507. needAlphaBlending: boolean;
  15508. /**
  15509. * Does the material work in alpha test mode
  15510. */
  15511. needAlphaTesting: boolean;
  15512. /**
  15513. * The list of attribute names used in the shader
  15514. */
  15515. attributes: string[];
  15516. /**
  15517. * The list of unifrom names used in the shader
  15518. */
  15519. uniforms: string[];
  15520. /**
  15521. * The list of UBO names used in the shader
  15522. */
  15523. uniformBuffers: string[];
  15524. /**
  15525. * The list of sampler names used in the shader
  15526. */
  15527. samplers: string[];
  15528. /**
  15529. * The list of defines used in the shader
  15530. */
  15531. defines: string[];
  15532. }
  15533. /**
  15534. * 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.
  15535. *
  15536. * This returned material effects how the mesh will look based on the code in the shaders.
  15537. *
  15538. * @see http://doc.babylonjs.com/how_to/shader_material
  15539. */
  15540. export class ShaderMaterial extends Material {
  15541. private _shaderPath;
  15542. private _options;
  15543. private _textures;
  15544. private _textureArrays;
  15545. private _floats;
  15546. private _ints;
  15547. private _floatsArrays;
  15548. private _colors3;
  15549. private _colors3Arrays;
  15550. private _colors4;
  15551. private _colors4Arrays;
  15552. private _vectors2;
  15553. private _vectors3;
  15554. private _vectors4;
  15555. private _matrices;
  15556. private _matrixArrays;
  15557. private _matrices3x3;
  15558. private _matrices2x2;
  15559. private _vectors2Arrays;
  15560. private _vectors3Arrays;
  15561. private _vectors4Arrays;
  15562. private _cachedWorldViewMatrix;
  15563. private _cachedWorldViewProjectionMatrix;
  15564. private _renderId;
  15565. private _multiview;
  15566. private _cachedDefines;
  15567. /**
  15568. * Instantiate a new shader material.
  15569. * 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.
  15570. * This returned material effects how the mesh will look based on the code in the shaders.
  15571. * @see http://doc.babylonjs.com/how_to/shader_material
  15572. * @param name Define the name of the material in the scene
  15573. * @param scene Define the scene the material belongs to
  15574. * @param shaderPath Defines the route to the shader code in one of three ways:
  15575. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15576. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15577. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15578. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15579. * @param options Define the options used to create the shader
  15580. */
  15581. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15582. /**
  15583. * Gets the shader path used to define the shader code
  15584. * It can be modified to trigger a new compilation
  15585. */
  15586. get shaderPath(): any;
  15587. /**
  15588. * Sets the shader path used to define the shader code
  15589. * It can be modified to trigger a new compilation
  15590. */
  15591. set shaderPath(shaderPath: any);
  15592. /**
  15593. * Gets the options used to compile the shader.
  15594. * They can be modified to trigger a new compilation
  15595. */
  15596. get options(): IShaderMaterialOptions;
  15597. /**
  15598. * Gets the current class name of the material e.g. "ShaderMaterial"
  15599. * Mainly use in serialization.
  15600. * @returns the class name
  15601. */
  15602. getClassName(): string;
  15603. /**
  15604. * Specifies if the material will require alpha blending
  15605. * @returns a boolean specifying if alpha blending is needed
  15606. */
  15607. needAlphaBlending(): boolean;
  15608. /**
  15609. * Specifies if this material should be rendered in alpha test mode
  15610. * @returns a boolean specifying if an alpha test is needed.
  15611. */
  15612. needAlphaTesting(): boolean;
  15613. private _checkUniform;
  15614. /**
  15615. * Set a texture in the shader.
  15616. * @param name Define the name of the uniform samplers as defined in the shader
  15617. * @param texture Define the texture to bind to this sampler
  15618. * @return the material itself allowing "fluent" like uniform updates
  15619. */
  15620. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15621. /**
  15622. * Set a texture array in the shader.
  15623. * @param name Define the name of the uniform sampler array as defined in the shader
  15624. * @param textures Define the list of textures to bind to this sampler
  15625. * @return the material itself allowing "fluent" like uniform updates
  15626. */
  15627. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15628. /**
  15629. * Set a float in the shader.
  15630. * @param name Define the name of the uniform as defined in the shader
  15631. * @param value Define the value to give to the uniform
  15632. * @return the material itself allowing "fluent" like uniform updates
  15633. */
  15634. setFloat(name: string, value: number): ShaderMaterial;
  15635. /**
  15636. * Set a int in the shader.
  15637. * @param name Define the name of the uniform as defined in the shader
  15638. * @param value Define the value to give to the uniform
  15639. * @return the material itself allowing "fluent" like uniform updates
  15640. */
  15641. setInt(name: string, value: number): ShaderMaterial;
  15642. /**
  15643. * Set an array of floats in the shader.
  15644. * @param name Define the name of the uniform as defined in the shader
  15645. * @param value Define the value to give to the uniform
  15646. * @return the material itself allowing "fluent" like uniform updates
  15647. */
  15648. setFloats(name: string, value: number[]): ShaderMaterial;
  15649. /**
  15650. * Set a vec3 in the shader from a Color3.
  15651. * @param name Define the name of the uniform as defined in the shader
  15652. * @param value Define the value to give to the uniform
  15653. * @return the material itself allowing "fluent" like uniform updates
  15654. */
  15655. setColor3(name: string, value: Color3): ShaderMaterial;
  15656. /**
  15657. * Set a vec3 array in the shader from a Color3 array.
  15658. * @param name Define the name of the uniform as defined in the shader
  15659. * @param value Define the value to give to the uniform
  15660. * @return the material itself allowing "fluent" like uniform updates
  15661. */
  15662. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15663. /**
  15664. * Set a vec4 in the shader from a Color4.
  15665. * @param name Define the name of the uniform as defined in the shader
  15666. * @param value Define the value to give to the uniform
  15667. * @return the material itself allowing "fluent" like uniform updates
  15668. */
  15669. setColor4(name: string, value: Color4): ShaderMaterial;
  15670. /**
  15671. * Set a vec4 array in the shader from a Color4 array.
  15672. * @param name Define the name of the uniform as defined in the shader
  15673. * @param value Define the value to give to the uniform
  15674. * @return the material itself allowing "fluent" like uniform updates
  15675. */
  15676. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15677. /**
  15678. * Set a vec2 in the shader from a Vector2.
  15679. * @param name Define the name of the uniform as defined in the shader
  15680. * @param value Define the value to give to the uniform
  15681. * @return the material itself allowing "fluent" like uniform updates
  15682. */
  15683. setVector2(name: string, value: Vector2): ShaderMaterial;
  15684. /**
  15685. * Set a vec3 in the shader from a Vector3.
  15686. * @param name Define the name of the uniform as defined in the shader
  15687. * @param value Define the value to give to the uniform
  15688. * @return the material itself allowing "fluent" like uniform updates
  15689. */
  15690. setVector3(name: string, value: Vector3): ShaderMaterial;
  15691. /**
  15692. * Set a vec4 in the shader from a Vector4.
  15693. * @param name Define the name of the uniform as defined in the shader
  15694. * @param value Define the value to give to the uniform
  15695. * @return the material itself allowing "fluent" like uniform updates
  15696. */
  15697. setVector4(name: string, value: Vector4): ShaderMaterial;
  15698. /**
  15699. * Set a mat4 in the shader from a Matrix.
  15700. * @param name Define the name of the uniform as defined in the shader
  15701. * @param value Define the value to give to the uniform
  15702. * @return the material itself allowing "fluent" like uniform updates
  15703. */
  15704. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15705. /**
  15706. * Set a float32Array in the shader from a matrix array.
  15707. * @param name Define the name of the uniform as defined in the shader
  15708. * @param value Define the value to give to the uniform
  15709. * @return the material itself allowing "fluent" like uniform updates
  15710. */
  15711. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15712. /**
  15713. * Set a mat3 in the shader from a Float32Array.
  15714. * @param name Define the name of the uniform as defined in the shader
  15715. * @param value Define the value to give to the uniform
  15716. * @return the material itself allowing "fluent" like uniform updates
  15717. */
  15718. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15719. /**
  15720. * Set a mat2 in the shader from a Float32Array.
  15721. * @param name Define the name of the uniform as defined in the shader
  15722. * @param value Define the value to give to the uniform
  15723. * @return the material itself allowing "fluent" like uniform updates
  15724. */
  15725. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15726. /**
  15727. * Set a vec2 array in the shader from a number array.
  15728. * @param name Define the name of the uniform as defined in the shader
  15729. * @param value Define the value to give to the uniform
  15730. * @return the material itself allowing "fluent" like uniform updates
  15731. */
  15732. setArray2(name: string, value: number[]): ShaderMaterial;
  15733. /**
  15734. * Set a vec3 array in the shader from a number array.
  15735. * @param name Define the name of the uniform as defined in the shader
  15736. * @param value Define the value to give to the uniform
  15737. * @return the material itself allowing "fluent" like uniform updates
  15738. */
  15739. setArray3(name: string, value: number[]): ShaderMaterial;
  15740. /**
  15741. * Set a vec4 array in the shader from a number array.
  15742. * @param name Define the name of the uniform as defined in the shader
  15743. * @param value Define the value to give to the uniform
  15744. * @return the material itself allowing "fluent" like uniform updates
  15745. */
  15746. setArray4(name: string, value: number[]): ShaderMaterial;
  15747. private _checkCache;
  15748. /**
  15749. * Specifies that the submesh is ready to be used
  15750. * @param mesh defines the mesh to check
  15751. * @param subMesh defines which submesh to check
  15752. * @param useInstances specifies that instances should be used
  15753. * @returns a boolean indicating that the submesh is ready or not
  15754. */
  15755. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15756. /**
  15757. * Checks if the material is ready to render the requested mesh
  15758. * @param mesh Define the mesh to render
  15759. * @param useInstances Define whether or not the material is used with instances
  15760. * @returns true if ready, otherwise false
  15761. */
  15762. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15763. /**
  15764. * Binds the world matrix to the material
  15765. * @param world defines the world transformation matrix
  15766. * @param effectOverride - If provided, use this effect instead of internal effect
  15767. */
  15768. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15769. /**
  15770. * Binds the submesh to this material by preparing the effect and shader to draw
  15771. * @param world defines the world transformation matrix
  15772. * @param mesh defines the mesh containing the submesh
  15773. * @param subMesh defines the submesh to bind the material to
  15774. */
  15775. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15776. /**
  15777. * Binds the material to the mesh
  15778. * @param world defines the world transformation matrix
  15779. * @param mesh defines the mesh to bind the material to
  15780. * @param effectOverride - If provided, use this effect instead of internal effect
  15781. */
  15782. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15783. protected _afterBind(mesh?: Mesh): void;
  15784. /**
  15785. * Gets the active textures from the material
  15786. * @returns an array of textures
  15787. */
  15788. getActiveTextures(): BaseTexture[];
  15789. /**
  15790. * Specifies if the material uses a texture
  15791. * @param texture defines the texture to check against the material
  15792. * @returns a boolean specifying if the material uses the texture
  15793. */
  15794. hasTexture(texture: BaseTexture): boolean;
  15795. /**
  15796. * Makes a duplicate of the material, and gives it a new name
  15797. * @param name defines the new name for the duplicated material
  15798. * @returns the cloned material
  15799. */
  15800. clone(name: string): ShaderMaterial;
  15801. /**
  15802. * Disposes the material
  15803. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15804. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15805. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15806. */
  15807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15808. /**
  15809. * Serializes this material in a JSON representation
  15810. * @returns the serialized material object
  15811. */
  15812. serialize(): any;
  15813. /**
  15814. * Creates a shader material from parsed shader material data
  15815. * @param source defines the JSON represnetation of the material
  15816. * @param scene defines the hosting scene
  15817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15818. * @returns a new material
  15819. */
  15820. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15821. }
  15822. }
  15823. declare module BABYLON {
  15824. /** @hidden */
  15825. export var colorPixelShader: {
  15826. name: string;
  15827. shader: string;
  15828. };
  15829. }
  15830. declare module BABYLON {
  15831. /** @hidden */
  15832. export var colorVertexShader: {
  15833. name: string;
  15834. shader: string;
  15835. };
  15836. }
  15837. declare module BABYLON {
  15838. /**
  15839. * Line mesh
  15840. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15841. */
  15842. export class LinesMesh extends Mesh {
  15843. /**
  15844. * If vertex color should be applied to the mesh
  15845. */
  15846. readonly useVertexColor?: boolean | undefined;
  15847. /**
  15848. * If vertex alpha should be applied to the mesh
  15849. */
  15850. readonly useVertexAlpha?: boolean | undefined;
  15851. /**
  15852. * Color of the line (Default: White)
  15853. */
  15854. color: Color3;
  15855. /**
  15856. * Alpha of the line (Default: 1)
  15857. */
  15858. alpha: number;
  15859. /**
  15860. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15861. * This margin is expressed in world space coordinates, so its value may vary.
  15862. * Default value is 0.1
  15863. */
  15864. intersectionThreshold: number;
  15865. private _colorShader;
  15866. private color4;
  15867. /**
  15868. * Creates a new LinesMesh
  15869. * @param name defines the name
  15870. * @param scene defines the hosting scene
  15871. * @param parent defines the parent mesh if any
  15872. * @param source defines the optional source LinesMesh used to clone data from
  15873. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15874. * When false, achieved by calling a clone(), also passing False.
  15875. * This will make creation of children, recursive.
  15876. * @param useVertexColor defines if this LinesMesh supports vertex color
  15877. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15878. */
  15879. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15880. /**
  15881. * If vertex color should be applied to the mesh
  15882. */
  15883. useVertexColor?: boolean | undefined,
  15884. /**
  15885. * If vertex alpha should be applied to the mesh
  15886. */
  15887. useVertexAlpha?: boolean | undefined);
  15888. private _addClipPlaneDefine;
  15889. private _removeClipPlaneDefine;
  15890. isReady(): boolean;
  15891. /**
  15892. * Returns the string "LineMesh"
  15893. */
  15894. getClassName(): string;
  15895. /**
  15896. * @hidden
  15897. */
  15898. get material(): Material;
  15899. /**
  15900. * @hidden
  15901. */
  15902. set material(value: Material);
  15903. /**
  15904. * @hidden
  15905. */
  15906. get checkCollisions(): boolean;
  15907. /** @hidden */
  15908. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15909. /** @hidden */
  15910. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15911. /**
  15912. * Disposes of the line mesh
  15913. * @param doNotRecurse If children should be disposed
  15914. */
  15915. dispose(doNotRecurse?: boolean): void;
  15916. /**
  15917. * Returns a new LineMesh object cloned from the current one.
  15918. */
  15919. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15920. /**
  15921. * Creates a new InstancedLinesMesh object from the mesh model.
  15922. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15923. * @param name defines the name of the new instance
  15924. * @returns a new InstancedLinesMesh
  15925. */
  15926. createInstance(name: string): InstancedLinesMesh;
  15927. }
  15928. /**
  15929. * Creates an instance based on a source LinesMesh
  15930. */
  15931. export class InstancedLinesMesh extends InstancedMesh {
  15932. /**
  15933. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15934. * This margin is expressed in world space coordinates, so its value may vary.
  15935. * Initilized with the intersectionThreshold value of the source LinesMesh
  15936. */
  15937. intersectionThreshold: number;
  15938. constructor(name: string, source: LinesMesh);
  15939. /**
  15940. * Returns the string "InstancedLinesMesh".
  15941. */
  15942. getClassName(): string;
  15943. }
  15944. }
  15945. declare module BABYLON {
  15946. /** @hidden */
  15947. export var linePixelShader: {
  15948. name: string;
  15949. shader: string;
  15950. };
  15951. }
  15952. declare module BABYLON {
  15953. /** @hidden */
  15954. export var lineVertexShader: {
  15955. name: string;
  15956. shader: string;
  15957. };
  15958. }
  15959. declare module BABYLON {
  15960. interface AbstractMesh {
  15961. /**
  15962. * Gets the edgesRenderer associated with the mesh
  15963. */
  15964. edgesRenderer: Nullable<EdgesRenderer>;
  15965. }
  15966. interface LinesMesh {
  15967. /**
  15968. * Enables the edge rendering mode on the mesh.
  15969. * This mode makes the mesh edges visible
  15970. * @param epsilon defines the maximal distance between two angles to detect a face
  15971. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15972. * @returns the currentAbstractMesh
  15973. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15974. */
  15975. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15976. }
  15977. interface InstancedLinesMesh {
  15978. /**
  15979. * Enables the edge rendering mode on the mesh.
  15980. * This mode makes the mesh edges visible
  15981. * @param epsilon defines the maximal distance between two angles to detect a face
  15982. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15983. * @returns the current InstancedLinesMesh
  15984. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15985. */
  15986. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15987. }
  15988. /**
  15989. * Defines the minimum contract an Edges renderer should follow.
  15990. */
  15991. export interface IEdgesRenderer extends IDisposable {
  15992. /**
  15993. * Gets or sets a boolean indicating if the edgesRenderer is active
  15994. */
  15995. isEnabled: boolean;
  15996. /**
  15997. * Renders the edges of the attached mesh,
  15998. */
  15999. render(): void;
  16000. /**
  16001. * Checks wether or not the edges renderer is ready to render.
  16002. * @return true if ready, otherwise false.
  16003. */
  16004. isReady(): boolean;
  16005. }
  16006. /**
  16007. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16008. */
  16009. export class EdgesRenderer implements IEdgesRenderer {
  16010. /**
  16011. * Define the size of the edges with an orthographic camera
  16012. */
  16013. edgesWidthScalerForOrthographic: number;
  16014. /**
  16015. * Define the size of the edges with a perspective camera
  16016. */
  16017. edgesWidthScalerForPerspective: number;
  16018. protected _source: AbstractMesh;
  16019. protected _linesPositions: number[];
  16020. protected _linesNormals: number[];
  16021. protected _linesIndices: number[];
  16022. protected _epsilon: number;
  16023. protected _indicesCount: number;
  16024. protected _lineShader: ShaderMaterial;
  16025. protected _ib: DataBuffer;
  16026. protected _buffers: {
  16027. [key: string]: Nullable<VertexBuffer>;
  16028. };
  16029. protected _checkVerticesInsteadOfIndices: boolean;
  16030. private _meshRebuildObserver;
  16031. private _meshDisposeObserver;
  16032. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16033. isEnabled: boolean;
  16034. /**
  16035. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16036. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16037. * @param source Mesh used to create edges
  16038. * @param epsilon sum of angles in adjacency to check for edge
  16039. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16040. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16041. */
  16042. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16043. protected _prepareRessources(): void;
  16044. /** @hidden */
  16045. _rebuild(): void;
  16046. /**
  16047. * Releases the required resources for the edges renderer
  16048. */
  16049. dispose(): void;
  16050. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16051. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16052. /**
  16053. * Checks if the pair of p0 and p1 is en edge
  16054. * @param faceIndex
  16055. * @param edge
  16056. * @param faceNormals
  16057. * @param p0
  16058. * @param p1
  16059. * @private
  16060. */
  16061. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16062. /**
  16063. * push line into the position, normal and index buffer
  16064. * @protected
  16065. */
  16066. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16067. /**
  16068. * Generates lines edges from adjacencjes
  16069. * @private
  16070. */
  16071. _generateEdgesLines(): void;
  16072. /**
  16073. * Checks wether or not the edges renderer is ready to render.
  16074. * @return true if ready, otherwise false.
  16075. */
  16076. isReady(): boolean;
  16077. /**
  16078. * Renders the edges of the attached mesh,
  16079. */
  16080. render(): void;
  16081. }
  16082. /**
  16083. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16084. */
  16085. export class LineEdgesRenderer extends EdgesRenderer {
  16086. /**
  16087. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16088. * @param source LineMesh used to generate edges
  16089. * @param epsilon not important (specified angle for edge detection)
  16090. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16091. */
  16092. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16093. /**
  16094. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16095. */
  16096. _generateEdgesLines(): void;
  16097. }
  16098. }
  16099. declare module BABYLON {
  16100. /**
  16101. * This represents the object necessary to create a rendering group.
  16102. * This is exclusively used and created by the rendering manager.
  16103. * To modify the behavior, you use the available helpers in your scene or meshes.
  16104. * @hidden
  16105. */
  16106. export class RenderingGroup {
  16107. index: number;
  16108. private static _zeroVector;
  16109. private _scene;
  16110. private _opaqueSubMeshes;
  16111. private _transparentSubMeshes;
  16112. private _alphaTestSubMeshes;
  16113. private _depthOnlySubMeshes;
  16114. private _particleSystems;
  16115. private _spriteManagers;
  16116. private _opaqueSortCompareFn;
  16117. private _alphaTestSortCompareFn;
  16118. private _transparentSortCompareFn;
  16119. private _renderOpaque;
  16120. private _renderAlphaTest;
  16121. private _renderTransparent;
  16122. /** @hidden */
  16123. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16124. onBeforeTransparentRendering: () => void;
  16125. /**
  16126. * Set the opaque sort comparison function.
  16127. * If null the sub meshes will be render in the order they were created
  16128. */
  16129. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16130. /**
  16131. * Set the alpha test sort comparison function.
  16132. * If null the sub meshes will be render in the order they were created
  16133. */
  16134. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16135. /**
  16136. * Set the transparent sort comparison function.
  16137. * If null the sub meshes will be render in the order they were created
  16138. */
  16139. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16140. /**
  16141. * Creates a new rendering group.
  16142. * @param index The rendering group index
  16143. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16144. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16145. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16146. */
  16147. 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>);
  16148. /**
  16149. * Render all the sub meshes contained in the group.
  16150. * @param customRenderFunction Used to override the default render behaviour of the group.
  16151. * @returns true if rendered some submeshes.
  16152. */
  16153. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16154. /**
  16155. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16156. * @param subMeshes The submeshes to render
  16157. */
  16158. private renderOpaqueSorted;
  16159. /**
  16160. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16161. * @param subMeshes The submeshes to render
  16162. */
  16163. private renderAlphaTestSorted;
  16164. /**
  16165. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16166. * @param subMeshes The submeshes to render
  16167. */
  16168. private renderTransparentSorted;
  16169. /**
  16170. * Renders the submeshes in a specified order.
  16171. * @param subMeshes The submeshes to sort before render
  16172. * @param sortCompareFn The comparison function use to sort
  16173. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16174. * @param transparent Specifies to activate blending if true
  16175. */
  16176. private static renderSorted;
  16177. /**
  16178. * Renders the submeshes in the order they were dispatched (no sort applied).
  16179. * @param subMeshes The submeshes to render
  16180. */
  16181. private static renderUnsorted;
  16182. /**
  16183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16184. * are rendered back to front if in the same alpha index.
  16185. *
  16186. * @param a The first submesh
  16187. * @param b The second submesh
  16188. * @returns The result of the comparison
  16189. */
  16190. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16191. /**
  16192. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16193. * are rendered back to front.
  16194. *
  16195. * @param a The first submesh
  16196. * @param b The second submesh
  16197. * @returns The result of the comparison
  16198. */
  16199. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16200. /**
  16201. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16202. * are rendered front to back (prevent overdraw).
  16203. *
  16204. * @param a The first submesh
  16205. * @param b The second submesh
  16206. * @returns The result of the comparison
  16207. */
  16208. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16209. /**
  16210. * Resets the different lists of submeshes to prepare a new frame.
  16211. */
  16212. prepare(): void;
  16213. dispose(): void;
  16214. /**
  16215. * Inserts the submesh in its correct queue depending on its material.
  16216. * @param subMesh The submesh to dispatch
  16217. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16218. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16219. */
  16220. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16221. dispatchSprites(spriteManager: ISpriteManager): void;
  16222. dispatchParticles(particleSystem: IParticleSystem): void;
  16223. private _renderParticles;
  16224. private _renderSprites;
  16225. }
  16226. }
  16227. declare module BABYLON {
  16228. /**
  16229. * Interface describing the different options available in the rendering manager
  16230. * regarding Auto Clear between groups.
  16231. */
  16232. export interface IRenderingManagerAutoClearSetup {
  16233. /**
  16234. * Defines whether or not autoclear is enable.
  16235. */
  16236. autoClear: boolean;
  16237. /**
  16238. * Defines whether or not to autoclear the depth buffer.
  16239. */
  16240. depth: boolean;
  16241. /**
  16242. * Defines whether or not to autoclear the stencil buffer.
  16243. */
  16244. stencil: boolean;
  16245. }
  16246. /**
  16247. * This class is used by the onRenderingGroupObservable
  16248. */
  16249. export class RenderingGroupInfo {
  16250. /**
  16251. * The Scene that being rendered
  16252. */
  16253. scene: Scene;
  16254. /**
  16255. * The camera currently used for the rendering pass
  16256. */
  16257. camera: Nullable<Camera>;
  16258. /**
  16259. * The ID of the renderingGroup being processed
  16260. */
  16261. renderingGroupId: number;
  16262. }
  16263. /**
  16264. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16265. * It is enable to manage the different groups as well as the different necessary sort functions.
  16266. * This should not be used directly aside of the few static configurations
  16267. */
  16268. export class RenderingManager {
  16269. /**
  16270. * The max id used for rendering groups (not included)
  16271. */
  16272. static MAX_RENDERINGGROUPS: number;
  16273. /**
  16274. * The min id used for rendering groups (included)
  16275. */
  16276. static MIN_RENDERINGGROUPS: number;
  16277. /**
  16278. * Used to globally prevent autoclearing scenes.
  16279. */
  16280. static AUTOCLEAR: boolean;
  16281. /**
  16282. * @hidden
  16283. */
  16284. _useSceneAutoClearSetup: boolean;
  16285. private _scene;
  16286. private _renderingGroups;
  16287. private _depthStencilBufferAlreadyCleaned;
  16288. private _autoClearDepthStencil;
  16289. private _customOpaqueSortCompareFn;
  16290. private _customAlphaTestSortCompareFn;
  16291. private _customTransparentSortCompareFn;
  16292. private _renderingGroupInfo;
  16293. /**
  16294. * Instantiates a new rendering group for a particular scene
  16295. * @param scene Defines the scene the groups belongs to
  16296. */
  16297. constructor(scene: Scene);
  16298. private _clearDepthStencilBuffer;
  16299. /**
  16300. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16301. * @hidden
  16302. */
  16303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16304. /**
  16305. * Resets the different information of the group to prepare a new frame
  16306. * @hidden
  16307. */
  16308. reset(): void;
  16309. /**
  16310. * Dispose and release the group and its associated resources.
  16311. * @hidden
  16312. */
  16313. dispose(): void;
  16314. /**
  16315. * Clear the info related to rendering groups preventing retention points during dispose.
  16316. */
  16317. freeRenderingGroups(): void;
  16318. private _prepareRenderingGroup;
  16319. /**
  16320. * Add a sprite manager to the rendering manager in order to render it this frame.
  16321. * @param spriteManager Define the sprite manager to render
  16322. */
  16323. dispatchSprites(spriteManager: ISpriteManager): void;
  16324. /**
  16325. * Add a particle system to the rendering manager in order to render it this frame.
  16326. * @param particleSystem Define the particle system to render
  16327. */
  16328. dispatchParticles(particleSystem: IParticleSystem): void;
  16329. /**
  16330. * Add a submesh to the manager in order to render it this frame
  16331. * @param subMesh The submesh to dispatch
  16332. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16333. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16334. */
  16335. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16336. /**
  16337. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16338. * This allowed control for front to back rendering or reversly depending of the special needs.
  16339. *
  16340. * @param renderingGroupId The rendering group id corresponding to its index
  16341. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16342. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16343. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16344. */
  16345. 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;
  16346. /**
  16347. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16348. *
  16349. * @param renderingGroupId The rendering group id corresponding to its index
  16350. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16351. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16352. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16353. */
  16354. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16355. /**
  16356. * Gets the current auto clear configuration for one rendering group of the rendering
  16357. * manager.
  16358. * @param index the rendering group index to get the information for
  16359. * @returns The auto clear setup for the requested rendering group
  16360. */
  16361. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16362. }
  16363. }
  16364. declare module BABYLON {
  16365. /**
  16366. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16367. */
  16368. export interface ICustomShaderOptions {
  16369. /**
  16370. * Gets or sets the custom shader name to use
  16371. */
  16372. shaderName: string;
  16373. /**
  16374. * The list of attribute names used in the shader
  16375. */
  16376. attributes?: string[];
  16377. /**
  16378. * The list of unifrom names used in the shader
  16379. */
  16380. uniforms?: string[];
  16381. /**
  16382. * The list of sampler names used in the shader
  16383. */
  16384. samplers?: string[];
  16385. /**
  16386. * The list of defines used in the shader
  16387. */
  16388. defines?: string[];
  16389. }
  16390. /**
  16391. * Interface to implement to create a shadow generator compatible with BJS.
  16392. */
  16393. export interface IShadowGenerator {
  16394. /**
  16395. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16396. * @returns The render target texture if present otherwise, null
  16397. */
  16398. getShadowMap(): Nullable<RenderTargetTexture>;
  16399. /**
  16400. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16401. * @param subMesh The submesh we want to render in the shadow map
  16402. * @param useInstances Defines wether will draw in the map using instances
  16403. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16404. * @returns true if ready otherwise, false
  16405. */
  16406. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16407. /**
  16408. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16409. * @param defines Defines of the material we want to update
  16410. * @param lightIndex Index of the light in the enabled light list of the material
  16411. */
  16412. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16413. /**
  16414. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16415. * defined in the generator but impacting the effect).
  16416. * It implies the unifroms available on the materials are the standard BJS ones.
  16417. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16418. * @param effect The effect we are binfing the information for
  16419. */
  16420. bindShadowLight(lightIndex: string, effect: Effect): void;
  16421. /**
  16422. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16423. * (eq to shadow prjection matrix * light transform matrix)
  16424. * @returns The transform matrix used to create the shadow map
  16425. */
  16426. getTransformMatrix(): Matrix;
  16427. /**
  16428. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16429. * Cube and 2D textures for instance.
  16430. */
  16431. recreateShadowMap(): void;
  16432. /**
  16433. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16434. * @param onCompiled Callback triggered at the and of the effects compilation
  16435. * @param options Sets of optional options forcing the compilation with different modes
  16436. */
  16437. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16438. useInstances: boolean;
  16439. }>): void;
  16440. /**
  16441. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16442. * @param options Sets of optional options forcing the compilation with different modes
  16443. * @returns A promise that resolves when the compilation completes
  16444. */
  16445. forceCompilationAsync(options?: Partial<{
  16446. useInstances: boolean;
  16447. }>): Promise<void>;
  16448. /**
  16449. * Serializes the shadow generator setup to a json object.
  16450. * @returns The serialized JSON object
  16451. */
  16452. serialize(): any;
  16453. /**
  16454. * Disposes the Shadow map and related Textures and effects.
  16455. */
  16456. dispose(): void;
  16457. }
  16458. /**
  16459. * Default implementation IShadowGenerator.
  16460. * This is the main object responsible of generating shadows in the framework.
  16461. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16462. */
  16463. export class ShadowGenerator implements IShadowGenerator {
  16464. /**
  16465. * Name of the shadow generator class
  16466. */
  16467. static CLASSNAME: string;
  16468. /**
  16469. * Shadow generator mode None: no filtering applied.
  16470. */
  16471. static readonly FILTER_NONE: number;
  16472. /**
  16473. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16475. */
  16476. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16477. /**
  16478. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16479. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16480. */
  16481. static readonly FILTER_POISSONSAMPLING: number;
  16482. /**
  16483. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16485. */
  16486. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16487. /**
  16488. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16489. * edge artifacts on steep falloff.
  16490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16491. */
  16492. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16493. /**
  16494. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16495. * edge artifacts on steep falloff.
  16496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16497. */
  16498. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16499. /**
  16500. * Shadow generator mode PCF: Percentage Closer Filtering
  16501. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16502. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16503. */
  16504. static readonly FILTER_PCF: number;
  16505. /**
  16506. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16507. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16508. * Contact Hardening
  16509. */
  16510. static readonly FILTER_PCSS: number;
  16511. /**
  16512. * Reserved for PCF and PCSS
  16513. * Highest Quality.
  16514. *
  16515. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16516. *
  16517. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16518. */
  16519. static readonly QUALITY_HIGH: number;
  16520. /**
  16521. * Reserved for PCF and PCSS
  16522. * Good tradeoff for quality/perf cross devices
  16523. *
  16524. * Execute PCF on a 3*3 kernel.
  16525. *
  16526. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16527. */
  16528. static readonly QUALITY_MEDIUM: number;
  16529. /**
  16530. * Reserved for PCF and PCSS
  16531. * The lowest quality but the fastest.
  16532. *
  16533. * Execute PCF on a 1*1 kernel.
  16534. *
  16535. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16536. */
  16537. static readonly QUALITY_LOW: number;
  16538. /** Gets or sets the custom shader name to use */
  16539. customShaderOptions: ICustomShaderOptions;
  16540. /**
  16541. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16542. */
  16543. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16544. /**
  16545. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16546. */
  16547. onAfterShadowMapRenderObservable: Observable<Effect>;
  16548. /**
  16549. * Observable triggered before a mesh is rendered in the shadow map.
  16550. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16551. */
  16552. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16553. /**
  16554. * Observable triggered after a mesh is rendered in the shadow map.
  16555. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16556. */
  16557. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16558. protected _bias: number;
  16559. /**
  16560. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16561. */
  16562. get bias(): number;
  16563. /**
  16564. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16565. */
  16566. set bias(bias: number);
  16567. protected _normalBias: number;
  16568. /**
  16569. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16570. */
  16571. get normalBias(): number;
  16572. /**
  16573. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16574. */
  16575. set normalBias(normalBias: number);
  16576. protected _blurBoxOffset: number;
  16577. /**
  16578. * Gets the blur box offset: offset applied during the blur pass.
  16579. * Only useful if useKernelBlur = false
  16580. */
  16581. get blurBoxOffset(): number;
  16582. /**
  16583. * Sets the blur box offset: offset applied during the blur pass.
  16584. * Only useful if useKernelBlur = false
  16585. */
  16586. set blurBoxOffset(value: number);
  16587. protected _blurScale: number;
  16588. /**
  16589. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16590. * 2 means half of the size.
  16591. */
  16592. get blurScale(): number;
  16593. /**
  16594. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16595. * 2 means half of the size.
  16596. */
  16597. set blurScale(value: number);
  16598. protected _blurKernel: number;
  16599. /**
  16600. * Gets the blur kernel: kernel size of the blur pass.
  16601. * Only useful if useKernelBlur = true
  16602. */
  16603. get blurKernel(): number;
  16604. /**
  16605. * Sets the blur kernel: kernel size of the blur pass.
  16606. * Only useful if useKernelBlur = true
  16607. */
  16608. set blurKernel(value: number);
  16609. protected _useKernelBlur: boolean;
  16610. /**
  16611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16613. */
  16614. get useKernelBlur(): boolean;
  16615. /**
  16616. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16617. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16618. */
  16619. set useKernelBlur(value: boolean);
  16620. protected _depthScale: number;
  16621. /**
  16622. * Gets the depth scale used in ESM mode.
  16623. */
  16624. get depthScale(): number;
  16625. /**
  16626. * Sets the depth scale used in ESM mode.
  16627. * This can override the scale stored on the light.
  16628. */
  16629. set depthScale(value: number);
  16630. protected _validateFilter(filter: number): number;
  16631. protected _filter: number;
  16632. /**
  16633. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16634. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16635. */
  16636. get filter(): number;
  16637. /**
  16638. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16639. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16640. */
  16641. set filter(value: number);
  16642. /**
  16643. * Gets if the current filter is set to Poisson Sampling.
  16644. */
  16645. get usePoissonSampling(): boolean;
  16646. /**
  16647. * Sets the current filter to Poisson Sampling.
  16648. */
  16649. set usePoissonSampling(value: boolean);
  16650. /**
  16651. * Gets if the current filter is set to ESM.
  16652. */
  16653. get useExponentialShadowMap(): boolean;
  16654. /**
  16655. * Sets the current filter is to ESM.
  16656. */
  16657. set useExponentialShadowMap(value: boolean);
  16658. /**
  16659. * Gets if the current filter is set to filtered ESM.
  16660. */
  16661. get useBlurExponentialShadowMap(): boolean;
  16662. /**
  16663. * Gets if the current filter is set to filtered ESM.
  16664. */
  16665. set useBlurExponentialShadowMap(value: boolean);
  16666. /**
  16667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16668. * exponential to prevent steep falloff artifacts).
  16669. */
  16670. get useCloseExponentialShadowMap(): boolean;
  16671. /**
  16672. * Sets the current filter to "close ESM" (using the inverse of the
  16673. * exponential to prevent steep falloff artifacts).
  16674. */
  16675. set useCloseExponentialShadowMap(value: boolean);
  16676. /**
  16677. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16678. * exponential to prevent steep falloff artifacts).
  16679. */
  16680. get useBlurCloseExponentialShadowMap(): boolean;
  16681. /**
  16682. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16683. * exponential to prevent steep falloff artifacts).
  16684. */
  16685. set useBlurCloseExponentialShadowMap(value: boolean);
  16686. /**
  16687. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16688. */
  16689. get usePercentageCloserFiltering(): boolean;
  16690. /**
  16691. * Sets the current filter to "PCF" (percentage closer filtering).
  16692. */
  16693. set usePercentageCloserFiltering(value: boolean);
  16694. protected _filteringQuality: number;
  16695. /**
  16696. * Gets the PCF or PCSS Quality.
  16697. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16698. */
  16699. get filteringQuality(): number;
  16700. /**
  16701. * Sets the PCF or PCSS Quality.
  16702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16703. */
  16704. set filteringQuality(filteringQuality: number);
  16705. /**
  16706. * Gets if the current filter is set to "PCSS" (contact hardening).
  16707. */
  16708. get useContactHardeningShadow(): boolean;
  16709. /**
  16710. * Sets the current filter to "PCSS" (contact hardening).
  16711. */
  16712. set useContactHardeningShadow(value: boolean);
  16713. protected _contactHardeningLightSizeUVRatio: number;
  16714. /**
  16715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16716. * Using a ratio helps keeping shape stability independently of the map size.
  16717. *
  16718. * It does not account for the light projection as it was having too much
  16719. * instability during the light setup or during light position changes.
  16720. *
  16721. * Only valid if useContactHardeningShadow is true.
  16722. */
  16723. get contactHardeningLightSizeUVRatio(): number;
  16724. /**
  16725. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16726. * Using a ratio helps keeping shape stability independently of the map size.
  16727. *
  16728. * It does not account for the light projection as it was having too much
  16729. * instability during the light setup or during light position changes.
  16730. *
  16731. * Only valid if useContactHardeningShadow is true.
  16732. */
  16733. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16734. protected _darkness: number;
  16735. /** Gets or sets the actual darkness of a shadow */
  16736. get darkness(): number;
  16737. set darkness(value: number);
  16738. /**
  16739. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16740. * 0 means strongest and 1 would means no shadow.
  16741. * @returns the darkness.
  16742. */
  16743. getDarkness(): number;
  16744. /**
  16745. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16746. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16747. * @returns the shadow generator allowing fluent coding.
  16748. */
  16749. setDarkness(darkness: number): ShadowGenerator;
  16750. protected _transparencyShadow: boolean;
  16751. /** Gets or sets the ability to have transparent shadow */
  16752. get transparencyShadow(): boolean;
  16753. set transparencyShadow(value: boolean);
  16754. /**
  16755. * Sets the ability to have transparent shadow (boolean).
  16756. * @param transparent True if transparent else False
  16757. * @returns the shadow generator allowing fluent coding
  16758. */
  16759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16760. /**
  16761. * Enables or disables shadows with varying strength based on the transparency
  16762. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  16763. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  16764. * mesh.visibility * alphaTexture.a
  16765. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  16766. */
  16767. enableSoftTransparentShadow: boolean;
  16768. protected _shadowMap: Nullable<RenderTargetTexture>;
  16769. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16770. /**
  16771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16772. * @returns The render target texture if present otherwise, null
  16773. */
  16774. getShadowMap(): Nullable<RenderTargetTexture>;
  16775. /**
  16776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16777. * @returns The render target texture if the shadow map is present otherwise, null
  16778. */
  16779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16780. /**
  16781. * Gets the class name of that object
  16782. * @returns "ShadowGenerator"
  16783. */
  16784. getClassName(): string;
  16785. /**
  16786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16787. * @param mesh Mesh to add
  16788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16789. * @returns the Shadow Generator itself
  16790. */
  16791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16792. /**
  16793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16794. * @param mesh Mesh to remove
  16795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16796. * @returns the Shadow Generator itself
  16797. */
  16798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16799. /**
  16800. * Controls the extent to which the shadows fade out at the edge of the frustum
  16801. */
  16802. frustumEdgeFalloff: number;
  16803. protected _light: IShadowLight;
  16804. /**
  16805. * Returns the associated light object.
  16806. * @returns the light generating the shadow
  16807. */
  16808. getLight(): IShadowLight;
  16809. /**
  16810. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16811. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16812. * It might on the other hand introduce peter panning.
  16813. */
  16814. forceBackFacesOnly: boolean;
  16815. protected _scene: Scene;
  16816. protected _lightDirection: Vector3;
  16817. protected _effect: Effect;
  16818. protected _viewMatrix: Matrix;
  16819. protected _projectionMatrix: Matrix;
  16820. protected _transformMatrix: Matrix;
  16821. protected _cachedPosition: Vector3;
  16822. protected _cachedDirection: Vector3;
  16823. protected _cachedDefines: string;
  16824. protected _currentRenderID: number;
  16825. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16826. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16827. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16828. protected _blurPostProcesses: PostProcess[];
  16829. protected _mapSize: number;
  16830. protected _currentFaceIndex: number;
  16831. protected _currentFaceIndexCache: number;
  16832. protected _textureType: number;
  16833. protected _defaultTextureMatrix: Matrix;
  16834. protected _storedUniqueId: Nullable<number>;
  16835. /** @hidden */
  16836. static _SceneComponentInitialization: (scene: Scene) => void;
  16837. /**
  16838. * Creates a ShadowGenerator object.
  16839. * A ShadowGenerator is the required tool to use the shadows.
  16840. * Each light casting shadows needs to use its own ShadowGenerator.
  16841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16843. * @param light The light object generating the shadows.
  16844. * @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.
  16845. */
  16846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16847. protected _initializeGenerator(): void;
  16848. protected _createTargetRenderTexture(): void;
  16849. protected _initializeShadowMap(): void;
  16850. protected _initializeBlurRTTAndPostProcesses(): void;
  16851. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16852. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16853. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  16854. protected _applyFilterValues(): void;
  16855. /**
  16856. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16857. * @param onCompiled Callback triggered at the and of the effects compilation
  16858. * @param options Sets of optional options forcing the compilation with different modes
  16859. */
  16860. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16861. useInstances: boolean;
  16862. }>): void;
  16863. /**
  16864. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16865. * @param options Sets of optional options forcing the compilation with different modes
  16866. * @returns A promise that resolves when the compilation completes
  16867. */
  16868. forceCompilationAsync(options?: Partial<{
  16869. useInstances: boolean;
  16870. }>): Promise<void>;
  16871. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16872. private _prepareShadowDefines;
  16873. /**
  16874. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16875. * @param subMesh The submesh we want to render in the shadow map
  16876. * @param useInstances Defines wether will draw in the map using instances
  16877. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16878. * @returns true if ready otherwise, false
  16879. */
  16880. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16881. /**
  16882. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16883. * @param defines Defines of the material we want to update
  16884. * @param lightIndex Index of the light in the enabled light list of the material
  16885. */
  16886. prepareDefines(defines: any, lightIndex: number): void;
  16887. /**
  16888. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16889. * defined in the generator but impacting the effect).
  16890. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16891. * @param effect The effect we are binfing the information for
  16892. */
  16893. bindShadowLight(lightIndex: string, effect: Effect): void;
  16894. /**
  16895. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16896. * (eq to shadow prjection matrix * light transform matrix)
  16897. * @returns The transform matrix used to create the shadow map
  16898. */
  16899. getTransformMatrix(): Matrix;
  16900. /**
  16901. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16902. * Cube and 2D textures for instance.
  16903. */
  16904. recreateShadowMap(): void;
  16905. protected _disposeBlurPostProcesses(): void;
  16906. protected _disposeRTTandPostProcesses(): void;
  16907. /**
  16908. * Disposes the ShadowGenerator.
  16909. * Returns nothing.
  16910. */
  16911. dispose(): void;
  16912. /**
  16913. * Serializes the shadow generator setup to a json object.
  16914. * @returns The serialized JSON object
  16915. */
  16916. serialize(): any;
  16917. /**
  16918. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16919. * @param parsedShadowGenerator The JSON object to parse
  16920. * @param scene The scene to create the shadow map for
  16921. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16922. * @returns The parsed shadow generator
  16923. */
  16924. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16925. }
  16926. }
  16927. declare module BABYLON {
  16928. /**
  16929. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16930. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16931. * 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.
  16932. */
  16933. export abstract class Light extends Node {
  16934. /**
  16935. * Falloff Default: light is falling off following the material specification:
  16936. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16937. */
  16938. static readonly FALLOFF_DEFAULT: number;
  16939. /**
  16940. * Falloff Physical: light is falling off following the inverse squared distance law.
  16941. */
  16942. static readonly FALLOFF_PHYSICAL: number;
  16943. /**
  16944. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16945. * to enhance interoperability with other engines.
  16946. */
  16947. static readonly FALLOFF_GLTF: number;
  16948. /**
  16949. * Falloff Standard: light is falling off like in the standard material
  16950. * to enhance interoperability with other materials.
  16951. */
  16952. static readonly FALLOFF_STANDARD: number;
  16953. /**
  16954. * If every light affecting the material is in this lightmapMode,
  16955. * material.lightmapTexture adds or multiplies
  16956. * (depends on material.useLightmapAsShadowmap)
  16957. * after every other light calculations.
  16958. */
  16959. static readonly LIGHTMAP_DEFAULT: number;
  16960. /**
  16961. * material.lightmapTexture as only diffuse lighting from this light
  16962. * adds only specular lighting from this light
  16963. * adds dynamic shadows
  16964. */
  16965. static readonly LIGHTMAP_SPECULAR: number;
  16966. /**
  16967. * material.lightmapTexture as only lighting
  16968. * no light calculation from this light
  16969. * only adds dynamic shadows from this light
  16970. */
  16971. static readonly LIGHTMAP_SHADOWSONLY: number;
  16972. /**
  16973. * Each light type uses the default quantity according to its type:
  16974. * point/spot lights use luminous intensity
  16975. * directional lights use illuminance
  16976. */
  16977. static readonly INTENSITYMODE_AUTOMATIC: number;
  16978. /**
  16979. * lumen (lm)
  16980. */
  16981. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16982. /**
  16983. * candela (lm/sr)
  16984. */
  16985. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16986. /**
  16987. * lux (lm/m^2)
  16988. */
  16989. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16990. /**
  16991. * nit (cd/m^2)
  16992. */
  16993. static readonly INTENSITYMODE_LUMINANCE: number;
  16994. /**
  16995. * Light type const id of the point light.
  16996. */
  16997. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16998. /**
  16999. * Light type const id of the directional light.
  17000. */
  17001. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17002. /**
  17003. * Light type const id of the spot light.
  17004. */
  17005. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17006. /**
  17007. * Light type const id of the hemispheric light.
  17008. */
  17009. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17010. /**
  17011. * Diffuse gives the basic color to an object.
  17012. */
  17013. diffuse: Color3;
  17014. /**
  17015. * Specular produces a highlight color on an object.
  17016. * Note: This is note affecting PBR materials.
  17017. */
  17018. specular: Color3;
  17019. /**
  17020. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17021. * falling off base on range or angle.
  17022. * This can be set to any values in Light.FALLOFF_x.
  17023. *
  17024. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17025. * other types of materials.
  17026. */
  17027. falloffType: number;
  17028. /**
  17029. * Strength of the light.
  17030. * Note: By default it is define in the framework own unit.
  17031. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17032. */
  17033. intensity: number;
  17034. private _range;
  17035. protected _inverseSquaredRange: number;
  17036. /**
  17037. * Defines how far from the source the light is impacting in scene units.
  17038. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17039. */
  17040. get range(): number;
  17041. /**
  17042. * Defines how far from the source the light is impacting in scene units.
  17043. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17044. */
  17045. set range(value: number);
  17046. /**
  17047. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17048. * of light.
  17049. */
  17050. private _photometricScale;
  17051. private _intensityMode;
  17052. /**
  17053. * Gets the photometric scale used to interpret the intensity.
  17054. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17055. */
  17056. get intensityMode(): number;
  17057. /**
  17058. * Sets the photometric scale used to interpret the intensity.
  17059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17060. */
  17061. set intensityMode(value: number);
  17062. private _radius;
  17063. /**
  17064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17065. */
  17066. get radius(): number;
  17067. /**
  17068. * sets the light radius used by PBR Materials to simulate soft area lights.
  17069. */
  17070. set radius(value: number);
  17071. private _renderPriority;
  17072. /**
  17073. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17074. * exceeding the number allowed of the materials.
  17075. */
  17076. renderPriority: number;
  17077. private _shadowEnabled;
  17078. /**
  17079. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17080. * the current shadow generator.
  17081. */
  17082. get shadowEnabled(): boolean;
  17083. /**
  17084. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17085. * the current shadow generator.
  17086. */
  17087. set shadowEnabled(value: boolean);
  17088. private _includedOnlyMeshes;
  17089. /**
  17090. * Gets the only meshes impacted by this light.
  17091. */
  17092. get includedOnlyMeshes(): AbstractMesh[];
  17093. /**
  17094. * Sets the only meshes impacted by this light.
  17095. */
  17096. set includedOnlyMeshes(value: AbstractMesh[]);
  17097. private _excludedMeshes;
  17098. /**
  17099. * Gets the meshes not impacted by this light.
  17100. */
  17101. get excludedMeshes(): AbstractMesh[];
  17102. /**
  17103. * Sets the meshes not impacted by this light.
  17104. */
  17105. set excludedMeshes(value: AbstractMesh[]);
  17106. private _excludeWithLayerMask;
  17107. /**
  17108. * Gets the layer id use to find what meshes are not impacted by the light.
  17109. * Inactive if 0
  17110. */
  17111. get excludeWithLayerMask(): number;
  17112. /**
  17113. * Sets the layer id use to find what meshes are not impacted by the light.
  17114. * Inactive if 0
  17115. */
  17116. set excludeWithLayerMask(value: number);
  17117. private _includeOnlyWithLayerMask;
  17118. /**
  17119. * Gets the layer id use to find what meshes are impacted by the light.
  17120. * Inactive if 0
  17121. */
  17122. get includeOnlyWithLayerMask(): number;
  17123. /**
  17124. * Sets the layer id use to find what meshes are impacted by the light.
  17125. * Inactive if 0
  17126. */
  17127. set includeOnlyWithLayerMask(value: number);
  17128. private _lightmapMode;
  17129. /**
  17130. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17131. */
  17132. get lightmapMode(): number;
  17133. /**
  17134. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17135. */
  17136. set lightmapMode(value: number);
  17137. /**
  17138. * Shadow generator associted to the light.
  17139. * @hidden Internal use only.
  17140. */
  17141. _shadowGenerator: Nullable<IShadowGenerator>;
  17142. /**
  17143. * @hidden Internal use only.
  17144. */
  17145. _excludedMeshesIds: string[];
  17146. /**
  17147. * @hidden Internal use only.
  17148. */
  17149. _includedOnlyMeshesIds: string[];
  17150. /**
  17151. * The current light unifom buffer.
  17152. * @hidden Internal use only.
  17153. */
  17154. _uniformBuffer: UniformBuffer;
  17155. /** @hidden */
  17156. _renderId: number;
  17157. /**
  17158. * Creates a Light object in the scene.
  17159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17160. * @param name The firendly name of the light
  17161. * @param scene The scene the light belongs too
  17162. */
  17163. constructor(name: string, scene: Scene);
  17164. protected abstract _buildUniformLayout(): void;
  17165. /**
  17166. * Sets the passed Effect "effect" with the Light information.
  17167. * @param effect The effect to update
  17168. * @param lightIndex The index of the light in the effect to update
  17169. * @returns The light
  17170. */
  17171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17172. /**
  17173. * Sets the passed Effect "effect" with the Light textures.
  17174. * @param effect The effect to update
  17175. * @param lightIndex The index of the light in the effect to update
  17176. * @returns The light
  17177. */
  17178. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17179. /**
  17180. * Binds the lights information from the scene to the effect for the given mesh.
  17181. * @param lightIndex Light index
  17182. * @param scene The scene where the light belongs to
  17183. * @param effect The effect we are binding the data to
  17184. * @param useSpecular Defines if specular is supported
  17185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17186. */
  17187. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17188. /**
  17189. * Sets the passed Effect "effect" with the Light information.
  17190. * @param effect The effect to update
  17191. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17192. * @returns The light
  17193. */
  17194. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17195. /**
  17196. * Returns the string "Light".
  17197. * @returns the class name
  17198. */
  17199. getClassName(): string;
  17200. /** @hidden */
  17201. readonly _isLight: boolean;
  17202. /**
  17203. * Converts the light information to a readable string for debug purpose.
  17204. * @param fullDetails Supports for multiple levels of logging within scene loading
  17205. * @returns the human readable light info
  17206. */
  17207. toString(fullDetails?: boolean): string;
  17208. /** @hidden */
  17209. protected _syncParentEnabledState(): void;
  17210. /**
  17211. * Set the enabled state of this node.
  17212. * @param value - the new enabled state
  17213. */
  17214. setEnabled(value: boolean): void;
  17215. /**
  17216. * Returns the Light associated shadow generator if any.
  17217. * @return the associated shadow generator.
  17218. */
  17219. getShadowGenerator(): Nullable<IShadowGenerator>;
  17220. /**
  17221. * Returns a Vector3, the absolute light position in the World.
  17222. * @returns the world space position of the light
  17223. */
  17224. getAbsolutePosition(): Vector3;
  17225. /**
  17226. * Specifies if the light will affect the passed mesh.
  17227. * @param mesh The mesh to test against the light
  17228. * @return true the mesh is affected otherwise, false.
  17229. */
  17230. canAffectMesh(mesh: AbstractMesh): boolean;
  17231. /**
  17232. * Sort function to order lights for rendering.
  17233. * @param a First Light object to compare to second.
  17234. * @param b Second Light object to compare first.
  17235. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17236. */
  17237. static CompareLightsPriority(a: Light, b: Light): number;
  17238. /**
  17239. * Releases resources associated with this node.
  17240. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17241. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17242. */
  17243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17244. /**
  17245. * Returns the light type ID (integer).
  17246. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17247. */
  17248. getTypeID(): number;
  17249. /**
  17250. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17251. * @returns the scaled intensity in intensity mode unit
  17252. */
  17253. getScaledIntensity(): number;
  17254. /**
  17255. * Returns a new Light object, named "name", from the current one.
  17256. * @param name The name of the cloned light
  17257. * @param newParent The parent of this light, if it has one
  17258. * @returns the new created light
  17259. */
  17260. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  17261. /**
  17262. * Serializes the current light into a Serialization object.
  17263. * @returns the serialized object.
  17264. */
  17265. serialize(): any;
  17266. /**
  17267. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17268. * This new light is named "name" and added to the passed scene.
  17269. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17270. * @param name The friendly name of the light
  17271. * @param scene The scene the new light will belong to
  17272. * @returns the constructor function
  17273. */
  17274. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17275. /**
  17276. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17277. * @param parsedLight The JSON representation of the light
  17278. * @param scene The scene to create the parsed light in
  17279. * @returns the created light after parsing
  17280. */
  17281. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17282. private _hookArrayForExcluded;
  17283. private _hookArrayForIncludedOnly;
  17284. private _resyncMeshes;
  17285. /**
  17286. * Forces the meshes to update their light related information in their rendering used effects
  17287. * @hidden Internal Use Only
  17288. */
  17289. _markMeshesAsLightDirty(): void;
  17290. /**
  17291. * Recomputes the cached photometric scale if needed.
  17292. */
  17293. private _computePhotometricScale;
  17294. /**
  17295. * Returns the Photometric Scale according to the light type and intensity mode.
  17296. */
  17297. private _getPhotometricScale;
  17298. /**
  17299. * Reorder the light in the scene according to their defined priority.
  17300. * @hidden Internal Use Only
  17301. */
  17302. _reorderLightsInScene(): void;
  17303. /**
  17304. * Prepares the list of defines specific to the light type.
  17305. * @param defines the list of defines
  17306. * @param lightIndex defines the index of the light for the effect
  17307. */
  17308. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17309. }
  17310. }
  17311. declare module BABYLON {
  17312. /**
  17313. * Interface used to define Action
  17314. */
  17315. export interface IAction {
  17316. /**
  17317. * Trigger for the action
  17318. */
  17319. trigger: number;
  17320. /** Options of the trigger */
  17321. triggerOptions: any;
  17322. /**
  17323. * Gets the trigger parameters
  17324. * @returns the trigger parameters
  17325. */
  17326. getTriggerParameter(): any;
  17327. /**
  17328. * Internal only - executes current action event
  17329. * @hidden
  17330. */
  17331. _executeCurrent(evt?: ActionEvent): void;
  17332. /**
  17333. * Serialize placeholder for child classes
  17334. * @param parent of child
  17335. * @returns the serialized object
  17336. */
  17337. serialize(parent: any): any;
  17338. /**
  17339. * Internal only
  17340. * @hidden
  17341. */
  17342. _prepare(): void;
  17343. /**
  17344. * Internal only - manager for action
  17345. * @hidden
  17346. */
  17347. _actionManager: AbstractActionManager;
  17348. /**
  17349. * Adds action to chain of actions, may be a DoNothingAction
  17350. * @param action defines the next action to execute
  17351. * @returns The action passed in
  17352. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17353. */
  17354. then(action: IAction): IAction;
  17355. }
  17356. /**
  17357. * The action to be carried out following a trigger
  17358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17359. */
  17360. export class Action implements IAction {
  17361. /** the trigger, with or without parameters, for the action */
  17362. triggerOptions: any;
  17363. /**
  17364. * Trigger for the action
  17365. */
  17366. trigger: number;
  17367. /**
  17368. * Internal only - manager for action
  17369. * @hidden
  17370. */
  17371. _actionManager: ActionManager;
  17372. private _nextActiveAction;
  17373. private _child;
  17374. private _condition?;
  17375. private _triggerParameter;
  17376. /**
  17377. * An event triggered prior to action being executed.
  17378. */
  17379. onBeforeExecuteObservable: Observable<Action>;
  17380. /**
  17381. * Creates a new Action
  17382. * @param triggerOptions the trigger, with or without parameters, for the action
  17383. * @param condition an optional determinant of action
  17384. */
  17385. constructor(
  17386. /** the trigger, with or without parameters, for the action */
  17387. triggerOptions: any, condition?: Condition);
  17388. /**
  17389. * Internal only
  17390. * @hidden
  17391. */
  17392. _prepare(): void;
  17393. /**
  17394. * Gets the trigger parameters
  17395. * @returns the trigger parameters
  17396. */
  17397. getTriggerParameter(): any;
  17398. /**
  17399. * Internal only - executes current action event
  17400. * @hidden
  17401. */
  17402. _executeCurrent(evt?: ActionEvent): void;
  17403. /**
  17404. * Execute placeholder for child classes
  17405. * @param evt optional action event
  17406. */
  17407. execute(evt?: ActionEvent): void;
  17408. /**
  17409. * Skips to next active action
  17410. */
  17411. skipToNextActiveAction(): void;
  17412. /**
  17413. * Adds action to chain of actions, may be a DoNothingAction
  17414. * @param action defines the next action to execute
  17415. * @returns The action passed in
  17416. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17417. */
  17418. then(action: Action): Action;
  17419. /**
  17420. * Internal only
  17421. * @hidden
  17422. */
  17423. _getProperty(propertyPath: string): string;
  17424. /**
  17425. * Internal only
  17426. * @hidden
  17427. */
  17428. _getEffectiveTarget(target: any, propertyPath: string): any;
  17429. /**
  17430. * Serialize placeholder for child classes
  17431. * @param parent of child
  17432. * @returns the serialized object
  17433. */
  17434. serialize(parent: any): any;
  17435. /**
  17436. * Internal only called by serialize
  17437. * @hidden
  17438. */
  17439. protected _serialize(serializedAction: any, parent?: any): any;
  17440. /**
  17441. * Internal only
  17442. * @hidden
  17443. */
  17444. static _SerializeValueAsString: (value: any) => string;
  17445. /**
  17446. * Internal only
  17447. * @hidden
  17448. */
  17449. static _GetTargetProperty: (target: Node | Scene) => {
  17450. name: string;
  17451. targetType: string;
  17452. value: string;
  17453. };
  17454. }
  17455. }
  17456. declare module BABYLON {
  17457. /**
  17458. * A Condition applied to an Action
  17459. */
  17460. export class Condition {
  17461. /**
  17462. * Internal only - manager for action
  17463. * @hidden
  17464. */
  17465. _actionManager: ActionManager;
  17466. /**
  17467. * Internal only
  17468. * @hidden
  17469. */
  17470. _evaluationId: number;
  17471. /**
  17472. * Internal only
  17473. * @hidden
  17474. */
  17475. _currentResult: boolean;
  17476. /**
  17477. * Creates a new Condition
  17478. * @param actionManager the manager of the action the condition is applied to
  17479. */
  17480. constructor(actionManager: ActionManager);
  17481. /**
  17482. * Check if the current condition is valid
  17483. * @returns a boolean
  17484. */
  17485. isValid(): boolean;
  17486. /**
  17487. * Internal only
  17488. * @hidden
  17489. */
  17490. _getProperty(propertyPath: string): string;
  17491. /**
  17492. * Internal only
  17493. * @hidden
  17494. */
  17495. _getEffectiveTarget(target: any, propertyPath: string): any;
  17496. /**
  17497. * Serialize placeholder for child classes
  17498. * @returns the serialized object
  17499. */
  17500. serialize(): any;
  17501. /**
  17502. * Internal only
  17503. * @hidden
  17504. */
  17505. protected _serialize(serializedCondition: any): any;
  17506. }
  17507. /**
  17508. * Defines specific conditional operators as extensions of Condition
  17509. */
  17510. export class ValueCondition extends Condition {
  17511. /** path to specify the property of the target the conditional operator uses */
  17512. propertyPath: string;
  17513. /** the value compared by the conditional operator against the current value of the property */
  17514. value: any;
  17515. /** the conditional operator, default ValueCondition.IsEqual */
  17516. operator: number;
  17517. /**
  17518. * Internal only
  17519. * @hidden
  17520. */
  17521. private static _IsEqual;
  17522. /**
  17523. * Internal only
  17524. * @hidden
  17525. */
  17526. private static _IsDifferent;
  17527. /**
  17528. * Internal only
  17529. * @hidden
  17530. */
  17531. private static _IsGreater;
  17532. /**
  17533. * Internal only
  17534. * @hidden
  17535. */
  17536. private static _IsLesser;
  17537. /**
  17538. * returns the number for IsEqual
  17539. */
  17540. static get IsEqual(): number;
  17541. /**
  17542. * Returns the number for IsDifferent
  17543. */
  17544. static get IsDifferent(): number;
  17545. /**
  17546. * Returns the number for IsGreater
  17547. */
  17548. static get IsGreater(): number;
  17549. /**
  17550. * Returns the number for IsLesser
  17551. */
  17552. static get IsLesser(): number;
  17553. /**
  17554. * Internal only The action manager for the condition
  17555. * @hidden
  17556. */
  17557. _actionManager: ActionManager;
  17558. /**
  17559. * Internal only
  17560. * @hidden
  17561. */
  17562. private _target;
  17563. /**
  17564. * Internal only
  17565. * @hidden
  17566. */
  17567. private _effectiveTarget;
  17568. /**
  17569. * Internal only
  17570. * @hidden
  17571. */
  17572. private _property;
  17573. /**
  17574. * Creates a new ValueCondition
  17575. * @param actionManager manager for the action the condition applies to
  17576. * @param target for the action
  17577. * @param propertyPath path to specify the property of the target the conditional operator uses
  17578. * @param value the value compared by the conditional operator against the current value of the property
  17579. * @param operator the conditional operator, default ValueCondition.IsEqual
  17580. */
  17581. constructor(actionManager: ActionManager, target: any,
  17582. /** path to specify the property of the target the conditional operator uses */
  17583. propertyPath: string,
  17584. /** the value compared by the conditional operator against the current value of the property */
  17585. value: any,
  17586. /** the conditional operator, default ValueCondition.IsEqual */
  17587. operator?: number);
  17588. /**
  17589. * Compares the given value with the property value for the specified conditional operator
  17590. * @returns the result of the comparison
  17591. */
  17592. isValid(): boolean;
  17593. /**
  17594. * Serialize the ValueCondition into a JSON compatible object
  17595. * @returns serialization object
  17596. */
  17597. serialize(): any;
  17598. /**
  17599. * Gets the name of the conditional operator for the ValueCondition
  17600. * @param operator the conditional operator
  17601. * @returns the name
  17602. */
  17603. static GetOperatorName(operator: number): string;
  17604. }
  17605. /**
  17606. * Defines a predicate condition as an extension of Condition
  17607. */
  17608. export class PredicateCondition extends Condition {
  17609. /** defines the predicate function used to validate the condition */
  17610. predicate: () => boolean;
  17611. /**
  17612. * Internal only - manager for action
  17613. * @hidden
  17614. */
  17615. _actionManager: ActionManager;
  17616. /**
  17617. * Creates a new PredicateCondition
  17618. * @param actionManager manager for the action the condition applies to
  17619. * @param predicate defines the predicate function used to validate the condition
  17620. */
  17621. constructor(actionManager: ActionManager,
  17622. /** defines the predicate function used to validate the condition */
  17623. predicate: () => boolean);
  17624. /**
  17625. * @returns the validity of the predicate condition
  17626. */
  17627. isValid(): boolean;
  17628. }
  17629. /**
  17630. * Defines a state condition as an extension of Condition
  17631. */
  17632. export class StateCondition extends Condition {
  17633. /** Value to compare with target state */
  17634. value: string;
  17635. /**
  17636. * Internal only - manager for action
  17637. * @hidden
  17638. */
  17639. _actionManager: ActionManager;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. private _target;
  17645. /**
  17646. * Creates a new StateCondition
  17647. * @param actionManager manager for the action the condition applies to
  17648. * @param target of the condition
  17649. * @param value to compare with target state
  17650. */
  17651. constructor(actionManager: ActionManager, target: any,
  17652. /** Value to compare with target state */
  17653. value: string);
  17654. /**
  17655. * Gets a boolean indicating if the current condition is met
  17656. * @returns the validity of the state
  17657. */
  17658. isValid(): boolean;
  17659. /**
  17660. * Serialize the StateCondition into a JSON compatible object
  17661. * @returns serialization object
  17662. */
  17663. serialize(): any;
  17664. }
  17665. }
  17666. declare module BABYLON {
  17667. /**
  17668. * This defines an action responsible to toggle a boolean once triggered.
  17669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17670. */
  17671. export class SwitchBooleanAction extends Action {
  17672. /**
  17673. * The path to the boolean property in the target object
  17674. */
  17675. propertyPath: string;
  17676. private _target;
  17677. private _effectiveTarget;
  17678. private _property;
  17679. /**
  17680. * Instantiate the action
  17681. * @param triggerOptions defines the trigger options
  17682. * @param target defines the object containing the boolean
  17683. * @param propertyPath defines the path to the boolean property in the target object
  17684. * @param condition defines the trigger related conditions
  17685. */
  17686. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17687. /** @hidden */
  17688. _prepare(): void;
  17689. /**
  17690. * Execute the action toggle the boolean value.
  17691. */
  17692. execute(): void;
  17693. /**
  17694. * Serializes the actions and its related information.
  17695. * @param parent defines the object to serialize in
  17696. * @returns the serialized object
  17697. */
  17698. serialize(parent: any): any;
  17699. }
  17700. /**
  17701. * This defines an action responsible to set a the state field of the target
  17702. * to a desired value once triggered.
  17703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17704. */
  17705. export class SetStateAction extends Action {
  17706. /**
  17707. * The value to store in the state field.
  17708. */
  17709. value: string;
  17710. private _target;
  17711. /**
  17712. * Instantiate the action
  17713. * @param triggerOptions defines the trigger options
  17714. * @param target defines the object containing the state property
  17715. * @param value defines the value to store in the state field
  17716. * @param condition defines the trigger related conditions
  17717. */
  17718. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17719. /**
  17720. * Execute the action and store the value on the target state property.
  17721. */
  17722. execute(): void;
  17723. /**
  17724. * Serializes the actions and its related information.
  17725. * @param parent defines the object to serialize in
  17726. * @returns the serialized object
  17727. */
  17728. serialize(parent: any): any;
  17729. }
  17730. /**
  17731. * This defines an action responsible to set a property of the target
  17732. * to a desired value once triggered.
  17733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17734. */
  17735. export class SetValueAction extends Action {
  17736. /**
  17737. * The path of the property to set in the target.
  17738. */
  17739. propertyPath: string;
  17740. /**
  17741. * The value to set in the property
  17742. */
  17743. value: any;
  17744. private _target;
  17745. private _effectiveTarget;
  17746. private _property;
  17747. /**
  17748. * Instantiate the action
  17749. * @param triggerOptions defines the trigger options
  17750. * @param target defines the object containing the property
  17751. * @param propertyPath defines the path of the property to set in the target
  17752. * @param value defines the value to set in the property
  17753. * @param condition defines the trigger related conditions
  17754. */
  17755. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17756. /** @hidden */
  17757. _prepare(): void;
  17758. /**
  17759. * Execute the action and set the targetted property to the desired value.
  17760. */
  17761. execute(): void;
  17762. /**
  17763. * Serializes the actions and its related information.
  17764. * @param parent defines the object to serialize in
  17765. * @returns the serialized object
  17766. */
  17767. serialize(parent: any): any;
  17768. }
  17769. /**
  17770. * This defines an action responsible to increment the target value
  17771. * to a desired value once triggered.
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17773. */
  17774. export class IncrementValueAction extends Action {
  17775. /**
  17776. * The path of the property to increment in the target.
  17777. */
  17778. propertyPath: string;
  17779. /**
  17780. * The value we should increment the property by.
  17781. */
  17782. value: any;
  17783. private _target;
  17784. private _effectiveTarget;
  17785. private _property;
  17786. /**
  17787. * Instantiate the action
  17788. * @param triggerOptions defines the trigger options
  17789. * @param target defines the object containing the property
  17790. * @param propertyPath defines the path of the property to increment in the target
  17791. * @param value defines the value value we should increment the property by
  17792. * @param condition defines the trigger related conditions
  17793. */
  17794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17795. /** @hidden */
  17796. _prepare(): void;
  17797. /**
  17798. * Execute the action and increment the target of the value amount.
  17799. */
  17800. execute(): void;
  17801. /**
  17802. * Serializes the actions and its related information.
  17803. * @param parent defines the object to serialize in
  17804. * @returns the serialized object
  17805. */
  17806. serialize(parent: any): any;
  17807. }
  17808. /**
  17809. * This defines an action responsible to start an animation once triggered.
  17810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17811. */
  17812. export class PlayAnimationAction extends Action {
  17813. /**
  17814. * Where the animation should start (animation frame)
  17815. */
  17816. from: number;
  17817. /**
  17818. * Where the animation should stop (animation frame)
  17819. */
  17820. to: number;
  17821. /**
  17822. * Define if the animation should loop or stop after the first play.
  17823. */
  17824. loop?: boolean;
  17825. private _target;
  17826. /**
  17827. * Instantiate the action
  17828. * @param triggerOptions defines the trigger options
  17829. * @param target defines the target animation or animation name
  17830. * @param from defines from where the animation should start (animation frame)
  17831. * @param end defines where the animation should stop (animation frame)
  17832. * @param loop defines if the animation should loop or stop after the first play
  17833. * @param condition defines the trigger related conditions
  17834. */
  17835. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17836. /** @hidden */
  17837. _prepare(): void;
  17838. /**
  17839. * Execute the action and play the animation.
  17840. */
  17841. execute(): void;
  17842. /**
  17843. * Serializes the actions and its related information.
  17844. * @param parent defines the object to serialize in
  17845. * @returns the serialized object
  17846. */
  17847. serialize(parent: any): any;
  17848. }
  17849. /**
  17850. * This defines an action responsible to stop an animation once triggered.
  17851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17852. */
  17853. export class StopAnimationAction extends Action {
  17854. private _target;
  17855. /**
  17856. * Instantiate the action
  17857. * @param triggerOptions defines the trigger options
  17858. * @param target defines the target animation or animation name
  17859. * @param condition defines the trigger related conditions
  17860. */
  17861. constructor(triggerOptions: any, target: any, condition?: Condition);
  17862. /** @hidden */
  17863. _prepare(): void;
  17864. /**
  17865. * Execute the action and stop the animation.
  17866. */
  17867. execute(): void;
  17868. /**
  17869. * Serializes the actions and its related information.
  17870. * @param parent defines the object to serialize in
  17871. * @returns the serialized object
  17872. */
  17873. serialize(parent: any): any;
  17874. }
  17875. /**
  17876. * This defines an action responsible that does nothing once triggered.
  17877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17878. */
  17879. export class DoNothingAction extends Action {
  17880. /**
  17881. * Instantiate the action
  17882. * @param triggerOptions defines the trigger options
  17883. * @param condition defines the trigger related conditions
  17884. */
  17885. constructor(triggerOptions?: any, condition?: Condition);
  17886. /**
  17887. * Execute the action and do nothing.
  17888. */
  17889. execute(): void;
  17890. /**
  17891. * Serializes the actions and its related information.
  17892. * @param parent defines the object to serialize in
  17893. * @returns the serialized object
  17894. */
  17895. serialize(parent: any): any;
  17896. }
  17897. /**
  17898. * This defines an action responsible to trigger several actions once triggered.
  17899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17900. */
  17901. export class CombineAction extends Action {
  17902. /**
  17903. * The list of aggregated animations to run.
  17904. */
  17905. children: Action[];
  17906. /**
  17907. * Instantiate the action
  17908. * @param triggerOptions defines the trigger options
  17909. * @param children defines the list of aggregated animations to run
  17910. * @param condition defines the trigger related conditions
  17911. */
  17912. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17913. /** @hidden */
  17914. _prepare(): void;
  17915. /**
  17916. * Execute the action and executes all the aggregated actions.
  17917. */
  17918. execute(evt: ActionEvent): void;
  17919. /**
  17920. * Serializes the actions and its related information.
  17921. * @param parent defines the object to serialize in
  17922. * @returns the serialized object
  17923. */
  17924. serialize(parent: any): any;
  17925. }
  17926. /**
  17927. * This defines an action responsible to run code (external event) once triggered.
  17928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17929. */
  17930. export class ExecuteCodeAction extends Action {
  17931. /**
  17932. * The callback function to run.
  17933. */
  17934. func: (evt: ActionEvent) => void;
  17935. /**
  17936. * Instantiate the action
  17937. * @param triggerOptions defines the trigger options
  17938. * @param func defines the callback function to run
  17939. * @param condition defines the trigger related conditions
  17940. */
  17941. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17942. /**
  17943. * Execute the action and run the attached code.
  17944. */
  17945. execute(evt: ActionEvent): void;
  17946. }
  17947. /**
  17948. * This defines an action responsible to set the parent property of the target once triggered.
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17950. */
  17951. export class SetParentAction extends Action {
  17952. private _parent;
  17953. private _target;
  17954. /**
  17955. * Instantiate the action
  17956. * @param triggerOptions defines the trigger options
  17957. * @param target defines the target containing the parent property
  17958. * @param parent defines from where the animation should start (animation frame)
  17959. * @param condition defines the trigger related conditions
  17960. */
  17961. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17962. /** @hidden */
  17963. _prepare(): void;
  17964. /**
  17965. * Execute the action and set the parent property.
  17966. */
  17967. execute(): void;
  17968. /**
  17969. * Serializes the actions and its related information.
  17970. * @param parent defines the object to serialize in
  17971. * @returns the serialized object
  17972. */
  17973. serialize(parent: any): any;
  17974. }
  17975. }
  17976. declare module BABYLON {
  17977. /**
  17978. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17979. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17981. */
  17982. export class ActionManager extends AbstractActionManager {
  17983. /**
  17984. * Nothing
  17985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17986. */
  17987. static readonly NothingTrigger: number;
  17988. /**
  17989. * On pick
  17990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17991. */
  17992. static readonly OnPickTrigger: number;
  17993. /**
  17994. * On left pick
  17995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17996. */
  17997. static readonly OnLeftPickTrigger: number;
  17998. /**
  17999. * On right pick
  18000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18001. */
  18002. static readonly OnRightPickTrigger: number;
  18003. /**
  18004. * On center pick
  18005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18006. */
  18007. static readonly OnCenterPickTrigger: number;
  18008. /**
  18009. * On pick down
  18010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18011. */
  18012. static readonly OnPickDownTrigger: number;
  18013. /**
  18014. * On double pick
  18015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18016. */
  18017. static readonly OnDoublePickTrigger: number;
  18018. /**
  18019. * On pick up
  18020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18021. */
  18022. static readonly OnPickUpTrigger: number;
  18023. /**
  18024. * On pick out.
  18025. * This trigger will only be raised if you also declared a OnPickDown
  18026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18027. */
  18028. static readonly OnPickOutTrigger: number;
  18029. /**
  18030. * On long press
  18031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18032. */
  18033. static readonly OnLongPressTrigger: number;
  18034. /**
  18035. * On pointer over
  18036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18037. */
  18038. static readonly OnPointerOverTrigger: number;
  18039. /**
  18040. * On pointer out
  18041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18042. */
  18043. static readonly OnPointerOutTrigger: number;
  18044. /**
  18045. * On every frame
  18046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18047. */
  18048. static readonly OnEveryFrameTrigger: number;
  18049. /**
  18050. * On intersection enter
  18051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18052. */
  18053. static readonly OnIntersectionEnterTrigger: number;
  18054. /**
  18055. * On intersection exit
  18056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18057. */
  18058. static readonly OnIntersectionExitTrigger: number;
  18059. /**
  18060. * On key down
  18061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18062. */
  18063. static readonly OnKeyDownTrigger: number;
  18064. /**
  18065. * On key up
  18066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18067. */
  18068. static readonly OnKeyUpTrigger: number;
  18069. private _scene;
  18070. /**
  18071. * Creates a new action manager
  18072. * @param scene defines the hosting scene
  18073. */
  18074. constructor(scene: Scene);
  18075. /**
  18076. * Releases all associated resources
  18077. */
  18078. dispose(): void;
  18079. /**
  18080. * Gets hosting scene
  18081. * @returns the hosting scene
  18082. */
  18083. getScene(): Scene;
  18084. /**
  18085. * Does this action manager handles actions of any of the given triggers
  18086. * @param triggers defines the triggers to be tested
  18087. * @return a boolean indicating whether one (or more) of the triggers is handled
  18088. */
  18089. hasSpecificTriggers(triggers: number[]): boolean;
  18090. /**
  18091. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18092. * speed.
  18093. * @param triggerA defines the trigger to be tested
  18094. * @param triggerB defines the trigger to be tested
  18095. * @return a boolean indicating whether one (or more) of the triggers is handled
  18096. */
  18097. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18098. /**
  18099. * Does this action manager handles actions of a given trigger
  18100. * @param trigger defines the trigger to be tested
  18101. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18102. * @return whether the trigger is handled
  18103. */
  18104. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18105. /**
  18106. * Does this action manager has pointer triggers
  18107. */
  18108. get hasPointerTriggers(): boolean;
  18109. /**
  18110. * Does this action manager has pick triggers
  18111. */
  18112. get hasPickTriggers(): boolean;
  18113. /**
  18114. * Registers an action to this action manager
  18115. * @param action defines the action to be registered
  18116. * @return the action amended (prepared) after registration
  18117. */
  18118. registerAction(action: IAction): Nullable<IAction>;
  18119. /**
  18120. * Unregisters an action to this action manager
  18121. * @param action defines the action to be unregistered
  18122. * @return a boolean indicating whether the action has been unregistered
  18123. */
  18124. unregisterAction(action: IAction): Boolean;
  18125. /**
  18126. * Process a specific trigger
  18127. * @param trigger defines the trigger to process
  18128. * @param evt defines the event details to be processed
  18129. */
  18130. processTrigger(trigger: number, evt?: IActionEvent): void;
  18131. /** @hidden */
  18132. _getEffectiveTarget(target: any, propertyPath: string): any;
  18133. /** @hidden */
  18134. _getProperty(propertyPath: string): string;
  18135. /**
  18136. * Serialize this manager to a JSON object
  18137. * @param name defines the property name to store this manager
  18138. * @returns a JSON representation of this manager
  18139. */
  18140. serialize(name: string): any;
  18141. /**
  18142. * Creates a new ActionManager from a JSON data
  18143. * @param parsedActions defines the JSON data to read from
  18144. * @param object defines the hosting mesh
  18145. * @param scene defines the hosting scene
  18146. */
  18147. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18148. /**
  18149. * Get a trigger name by index
  18150. * @param trigger defines the trigger index
  18151. * @returns a trigger name
  18152. */
  18153. static GetTriggerName(trigger: number): string;
  18154. }
  18155. }
  18156. declare module BABYLON {
  18157. /**
  18158. * Class used to represent a sprite
  18159. * @see http://doc.babylonjs.com/babylon101/sprites
  18160. */
  18161. export class Sprite {
  18162. /** defines the name */
  18163. name: string;
  18164. /** Gets or sets the current world position */
  18165. position: Vector3;
  18166. /** Gets or sets the main color */
  18167. color: Color4;
  18168. /** Gets or sets the width */
  18169. width: number;
  18170. /** Gets or sets the height */
  18171. height: number;
  18172. /** Gets or sets rotation angle */
  18173. angle: number;
  18174. /** Gets or sets the cell index in the sprite sheet */
  18175. cellIndex: number;
  18176. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18177. cellRef: string;
  18178. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18179. invertU: number;
  18180. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18181. invertV: number;
  18182. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18183. disposeWhenFinishedAnimating: boolean;
  18184. /** Gets the list of attached animations */
  18185. animations: Animation[];
  18186. /** Gets or sets a boolean indicating if the sprite can be picked */
  18187. isPickable: boolean;
  18188. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18189. useAlphaForPicking: boolean;
  18190. /** @hidden */
  18191. _xOffset: number;
  18192. /** @hidden */
  18193. _yOffset: number;
  18194. /** @hidden */
  18195. _xSize: number;
  18196. /** @hidden */
  18197. _ySize: number;
  18198. /**
  18199. * Gets or sets the associated action manager
  18200. */
  18201. actionManager: Nullable<ActionManager>;
  18202. /**
  18203. * An event triggered when the control has been disposed
  18204. */
  18205. onDisposeObservable: Observable<Sprite>;
  18206. private _animationStarted;
  18207. private _loopAnimation;
  18208. private _fromIndex;
  18209. private _toIndex;
  18210. private _delay;
  18211. private _direction;
  18212. private _manager;
  18213. private _time;
  18214. private _onAnimationEnd;
  18215. /**
  18216. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18217. */
  18218. isVisible: boolean;
  18219. /**
  18220. * Gets or sets the sprite size
  18221. */
  18222. get size(): number;
  18223. set size(value: number);
  18224. /**
  18225. * Gets or sets the unique id of the sprite
  18226. */
  18227. uniqueId: number;
  18228. /**
  18229. * Creates a new Sprite
  18230. * @param name defines the name
  18231. * @param manager defines the manager
  18232. */
  18233. constructor(
  18234. /** defines the name */
  18235. name: string, manager: ISpriteManager);
  18236. /**
  18237. * Returns the string "Sprite"
  18238. * @returns "Sprite"
  18239. */
  18240. getClassName(): string;
  18241. /**
  18242. * Starts an animation
  18243. * @param from defines the initial key
  18244. * @param to defines the end key
  18245. * @param loop defines if the animation must loop
  18246. * @param delay defines the start delay (in ms)
  18247. * @param onAnimationEnd defines a callback to call when animation ends
  18248. */
  18249. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18250. /** Stops current animation (if any) */
  18251. stopAnimation(): void;
  18252. /** @hidden */
  18253. _animate(deltaTime: number): void;
  18254. /** Release associated resources */
  18255. dispose(): void;
  18256. }
  18257. }
  18258. declare module BABYLON {
  18259. /**
  18260. * Information about the result of picking within a scene
  18261. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18262. */
  18263. export class PickingInfo {
  18264. /** @hidden */
  18265. _pickingUnavailable: boolean;
  18266. /**
  18267. * If the pick collided with an object
  18268. */
  18269. hit: boolean;
  18270. /**
  18271. * Distance away where the pick collided
  18272. */
  18273. distance: number;
  18274. /**
  18275. * The location of pick collision
  18276. */
  18277. pickedPoint: Nullable<Vector3>;
  18278. /**
  18279. * The mesh corresponding the the pick collision
  18280. */
  18281. pickedMesh: Nullable<AbstractMesh>;
  18282. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18283. bu: number;
  18284. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18285. bv: number;
  18286. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18287. faceId: number;
  18288. /** Id of the the submesh that was picked */
  18289. subMeshId: number;
  18290. /** If a sprite was picked, this will be the sprite the pick collided with */
  18291. pickedSprite: Nullable<Sprite>;
  18292. /**
  18293. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18294. */
  18295. originMesh: Nullable<AbstractMesh>;
  18296. /**
  18297. * The ray that was used to perform the picking.
  18298. */
  18299. ray: Nullable<Ray>;
  18300. /**
  18301. * Gets the normal correspodning to the face the pick collided with
  18302. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18303. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18304. * @returns The normal correspodning to the face the pick collided with
  18305. */
  18306. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18307. /**
  18308. * Gets the texture coordinates of where the pick occured
  18309. * @returns the vector containing the coordnates of the texture
  18310. */
  18311. getTextureCoordinates(): Nullable<Vector2>;
  18312. }
  18313. }
  18314. declare module BABYLON {
  18315. /**
  18316. * Gather the list of pointer event types as constants.
  18317. */
  18318. export class PointerEventTypes {
  18319. /**
  18320. * 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.
  18321. */
  18322. static readonly POINTERDOWN: number;
  18323. /**
  18324. * The pointerup event is fired when a pointer is no longer active.
  18325. */
  18326. static readonly POINTERUP: number;
  18327. /**
  18328. * The pointermove event is fired when a pointer changes coordinates.
  18329. */
  18330. static readonly POINTERMOVE: number;
  18331. /**
  18332. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18333. */
  18334. static readonly POINTERWHEEL: number;
  18335. /**
  18336. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18337. */
  18338. static readonly POINTERPICK: number;
  18339. /**
  18340. * The pointertap event is fired when a the object has been touched and released without drag.
  18341. */
  18342. static readonly POINTERTAP: number;
  18343. /**
  18344. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18345. */
  18346. static readonly POINTERDOUBLETAP: number;
  18347. }
  18348. /**
  18349. * Base class of pointer info types.
  18350. */
  18351. export class PointerInfoBase {
  18352. /**
  18353. * Defines the type of event (PointerEventTypes)
  18354. */
  18355. type: number;
  18356. /**
  18357. * Defines the related dom event
  18358. */
  18359. event: PointerEvent | MouseWheelEvent;
  18360. /**
  18361. * Instantiates the base class of pointers info.
  18362. * @param type Defines the type of event (PointerEventTypes)
  18363. * @param event Defines the related dom event
  18364. */
  18365. constructor(
  18366. /**
  18367. * Defines the type of event (PointerEventTypes)
  18368. */
  18369. type: number,
  18370. /**
  18371. * Defines the related dom event
  18372. */
  18373. event: PointerEvent | MouseWheelEvent);
  18374. }
  18375. /**
  18376. * This class is used to store pointer related info for the onPrePointerObservable event.
  18377. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18378. */
  18379. export class PointerInfoPre extends PointerInfoBase {
  18380. /**
  18381. * Ray from a pointer if availible (eg. 6dof controller)
  18382. */
  18383. ray: Nullable<Ray>;
  18384. /**
  18385. * Defines the local position of the pointer on the canvas.
  18386. */
  18387. localPosition: Vector2;
  18388. /**
  18389. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18390. */
  18391. skipOnPointerObservable: boolean;
  18392. /**
  18393. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18394. * @param type Defines the type of event (PointerEventTypes)
  18395. * @param event Defines the related dom event
  18396. * @param localX Defines the local x coordinates of the pointer when the event occured
  18397. * @param localY Defines the local y coordinates of the pointer when the event occured
  18398. */
  18399. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18400. }
  18401. /**
  18402. * This type contains all the data related to a pointer event in Babylon.js.
  18403. * 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.
  18404. */
  18405. export class PointerInfo extends PointerInfoBase {
  18406. /**
  18407. * Defines the picking info associated to the info (if any)\
  18408. */
  18409. pickInfo: Nullable<PickingInfo>;
  18410. /**
  18411. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18412. * @param type Defines the type of event (PointerEventTypes)
  18413. * @param event Defines the related dom event
  18414. * @param pickInfo Defines the picking info associated to the info (if any)\
  18415. */
  18416. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18417. /**
  18418. * Defines the picking info associated to the info (if any)\
  18419. */
  18420. pickInfo: Nullable<PickingInfo>);
  18421. }
  18422. /**
  18423. * Data relating to a touch event on the screen.
  18424. */
  18425. export interface PointerTouch {
  18426. /**
  18427. * X coordinate of touch.
  18428. */
  18429. x: number;
  18430. /**
  18431. * Y coordinate of touch.
  18432. */
  18433. y: number;
  18434. /**
  18435. * Id of touch. Unique for each finger.
  18436. */
  18437. pointerId: number;
  18438. /**
  18439. * Event type passed from DOM.
  18440. */
  18441. type: any;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Manage the mouse inputs to control the movement of a free camera.
  18447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18448. */
  18449. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18450. /**
  18451. * Define if touch is enabled in the mouse input
  18452. */
  18453. touchEnabled: boolean;
  18454. /**
  18455. * Defines the camera the input is attached to.
  18456. */
  18457. camera: FreeCamera;
  18458. /**
  18459. * Defines the buttons associated with the input to handle camera move.
  18460. */
  18461. buttons: number[];
  18462. /**
  18463. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18464. */
  18465. angularSensibility: number;
  18466. private _pointerInput;
  18467. private _onMouseMove;
  18468. private _observer;
  18469. private previousPosition;
  18470. /**
  18471. * Observable for when a pointer move event occurs containing the move offset
  18472. */
  18473. onPointerMovedObservable: Observable<{
  18474. offsetX: number;
  18475. offsetY: number;
  18476. }>;
  18477. /**
  18478. * @hidden
  18479. * If the camera should be rotated automatically based on pointer movement
  18480. */
  18481. _allowCameraRotation: boolean;
  18482. /**
  18483. * Manage the mouse inputs to control the movement of a free camera.
  18484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18485. * @param touchEnabled Defines if touch is enabled or not
  18486. */
  18487. constructor(
  18488. /**
  18489. * Define if touch is enabled in the mouse input
  18490. */
  18491. touchEnabled?: boolean);
  18492. /**
  18493. * Attach the input controls to a specific dom element to get the input from.
  18494. * @param element Defines the element the controls should be listened from
  18495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18496. */
  18497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18498. /**
  18499. * Called on JS contextmenu event.
  18500. * Override this method to provide functionality.
  18501. */
  18502. protected onContextMenu(evt: PointerEvent): void;
  18503. /**
  18504. * Detach the current controls from the specified dom element.
  18505. * @param element Defines the element to stop listening the inputs from
  18506. */
  18507. detachControl(element: Nullable<HTMLElement>): void;
  18508. /**
  18509. * Gets the class name of the current intput.
  18510. * @returns the class name
  18511. */
  18512. getClassName(): string;
  18513. /**
  18514. * Get the friendly name associated with the input class.
  18515. * @returns the input friendly name
  18516. */
  18517. getSimpleName(): string;
  18518. }
  18519. }
  18520. declare module BABYLON {
  18521. /**
  18522. * Manage the touch inputs to control the movement of a free camera.
  18523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18524. */
  18525. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18526. /**
  18527. * Defines the camera the input is attached to.
  18528. */
  18529. camera: FreeCamera;
  18530. /**
  18531. * Defines the touch sensibility for rotation.
  18532. * The higher the faster.
  18533. */
  18534. touchAngularSensibility: number;
  18535. /**
  18536. * Defines the touch sensibility for move.
  18537. * The higher the faster.
  18538. */
  18539. touchMoveSensibility: number;
  18540. private _offsetX;
  18541. private _offsetY;
  18542. private _pointerPressed;
  18543. private _pointerInput;
  18544. private _observer;
  18545. private _onLostFocus;
  18546. /**
  18547. * Attach the input controls to a specific dom element to get the input from.
  18548. * @param element Defines the element the controls should be listened from
  18549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18550. */
  18551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18552. /**
  18553. * Detach the current controls from the specified dom element.
  18554. * @param element Defines the element to stop listening the inputs from
  18555. */
  18556. detachControl(element: Nullable<HTMLElement>): void;
  18557. /**
  18558. * Update the current camera state depending on the inputs that have been used this frame.
  18559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18560. */
  18561. checkInputs(): void;
  18562. /**
  18563. * Gets the class name of the current intput.
  18564. * @returns the class name
  18565. */
  18566. getClassName(): string;
  18567. /**
  18568. * Get the friendly name associated with the input class.
  18569. * @returns the input friendly name
  18570. */
  18571. getSimpleName(): string;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Default Inputs manager for the FreeCamera.
  18577. * It groups all the default supported inputs for ease of use.
  18578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18579. */
  18580. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18581. /**
  18582. * @hidden
  18583. */
  18584. _mouseInput: Nullable<FreeCameraMouseInput>;
  18585. /**
  18586. * Instantiates a new FreeCameraInputsManager.
  18587. * @param camera Defines the camera the inputs belong to
  18588. */
  18589. constructor(camera: FreeCamera);
  18590. /**
  18591. * Add keyboard input support to the input manager.
  18592. * @returns the current input manager
  18593. */
  18594. addKeyboard(): FreeCameraInputsManager;
  18595. /**
  18596. * Add mouse input support to the input manager.
  18597. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18598. * @returns the current input manager
  18599. */
  18600. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18601. /**
  18602. * Removes the mouse input support from the manager
  18603. * @returns the current input manager
  18604. */
  18605. removeMouse(): FreeCameraInputsManager;
  18606. /**
  18607. * Add touch input support to the input manager.
  18608. * @returns the current input manager
  18609. */
  18610. addTouch(): FreeCameraInputsManager;
  18611. /**
  18612. * Remove all attached input methods from a camera
  18613. */
  18614. clear(): void;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /**
  18619. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18620. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18622. */
  18623. export class FreeCamera extends TargetCamera {
  18624. /**
  18625. * Define the collision ellipsoid of the camera.
  18626. * This is helpful to simulate a camera body like the player body around the camera
  18627. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18628. */
  18629. ellipsoid: Vector3;
  18630. /**
  18631. * Define an offset for the position of the ellipsoid around the camera.
  18632. * This can be helpful to determine the center of the body near the gravity center of the body
  18633. * instead of its head.
  18634. */
  18635. ellipsoidOffset: Vector3;
  18636. /**
  18637. * Enable or disable collisions of the camera with the rest of the scene objects.
  18638. */
  18639. checkCollisions: boolean;
  18640. /**
  18641. * Enable or disable gravity on the camera.
  18642. */
  18643. applyGravity: boolean;
  18644. /**
  18645. * Define the input manager associated to the camera.
  18646. */
  18647. inputs: FreeCameraInputsManager;
  18648. /**
  18649. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18650. * Higher values reduce sensitivity.
  18651. */
  18652. get angularSensibility(): number;
  18653. /**
  18654. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18655. * Higher values reduce sensitivity.
  18656. */
  18657. set angularSensibility(value: number);
  18658. /**
  18659. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18660. */
  18661. get keysUp(): number[];
  18662. set keysUp(value: number[]);
  18663. /**
  18664. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18665. */
  18666. get keysUpward(): number[];
  18667. set keysUpward(value: number[]);
  18668. /**
  18669. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18670. */
  18671. get keysDown(): number[];
  18672. set keysDown(value: number[]);
  18673. /**
  18674. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18675. */
  18676. get keysDownward(): number[];
  18677. set keysDownward(value: number[]);
  18678. /**
  18679. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18680. */
  18681. get keysLeft(): number[];
  18682. set keysLeft(value: number[]);
  18683. /**
  18684. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18685. */
  18686. get keysRight(): number[];
  18687. set keysRight(value: number[]);
  18688. /**
  18689. * Event raised when the camera collide with a mesh in the scene.
  18690. */
  18691. onCollide: (collidedMesh: AbstractMesh) => void;
  18692. private _collider;
  18693. private _needMoveForGravity;
  18694. private _oldPosition;
  18695. private _diffPosition;
  18696. private _newPosition;
  18697. /** @hidden */
  18698. _localDirection: Vector3;
  18699. /** @hidden */
  18700. _transformedDirection: Vector3;
  18701. /**
  18702. * Instantiates a Free Camera.
  18703. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18704. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18706. * @param name Define the name of the camera in the scene
  18707. * @param position Define the start position of the camera in the scene
  18708. * @param scene Define the scene the camera belongs to
  18709. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18710. */
  18711. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18712. /**
  18713. * Attached controls to the current camera.
  18714. * @param element Defines the element the controls should be listened from
  18715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18716. */
  18717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18718. /**
  18719. * Detach the current controls from the camera.
  18720. * The camera will stop reacting to inputs.
  18721. * @param element Defines the element to stop listening the inputs from
  18722. */
  18723. detachControl(element: HTMLElement): void;
  18724. private _collisionMask;
  18725. /**
  18726. * Define a collision mask to limit the list of object the camera can collide with
  18727. */
  18728. get collisionMask(): number;
  18729. set collisionMask(mask: number);
  18730. /** @hidden */
  18731. _collideWithWorld(displacement: Vector3): void;
  18732. private _onCollisionPositionChange;
  18733. /** @hidden */
  18734. _checkInputs(): void;
  18735. /** @hidden */
  18736. _decideIfNeedsToMove(): boolean;
  18737. /** @hidden */
  18738. _updatePosition(): void;
  18739. /**
  18740. * Destroy the camera and release the current resources hold by it.
  18741. */
  18742. dispose(): void;
  18743. /**
  18744. * Gets the current object class name.
  18745. * @return the class name
  18746. */
  18747. getClassName(): string;
  18748. }
  18749. }
  18750. declare module BABYLON {
  18751. /**
  18752. * Represents a gamepad control stick position
  18753. */
  18754. export class StickValues {
  18755. /**
  18756. * The x component of the control stick
  18757. */
  18758. x: number;
  18759. /**
  18760. * The y component of the control stick
  18761. */
  18762. y: number;
  18763. /**
  18764. * Initializes the gamepad x and y control stick values
  18765. * @param x The x component of the gamepad control stick value
  18766. * @param y The y component of the gamepad control stick value
  18767. */
  18768. constructor(
  18769. /**
  18770. * The x component of the control stick
  18771. */
  18772. x: number,
  18773. /**
  18774. * The y component of the control stick
  18775. */
  18776. y: number);
  18777. }
  18778. /**
  18779. * An interface which manages callbacks for gamepad button changes
  18780. */
  18781. export interface GamepadButtonChanges {
  18782. /**
  18783. * Called when a gamepad has been changed
  18784. */
  18785. changed: boolean;
  18786. /**
  18787. * Called when a gamepad press event has been triggered
  18788. */
  18789. pressChanged: boolean;
  18790. /**
  18791. * Called when a touch event has been triggered
  18792. */
  18793. touchChanged: boolean;
  18794. /**
  18795. * Called when a value has changed
  18796. */
  18797. valueChanged: boolean;
  18798. }
  18799. /**
  18800. * Represents a gamepad
  18801. */
  18802. export class Gamepad {
  18803. /**
  18804. * The id of the gamepad
  18805. */
  18806. id: string;
  18807. /**
  18808. * The index of the gamepad
  18809. */
  18810. index: number;
  18811. /**
  18812. * The browser gamepad
  18813. */
  18814. browserGamepad: any;
  18815. /**
  18816. * Specifies what type of gamepad this represents
  18817. */
  18818. type: number;
  18819. private _leftStick;
  18820. private _rightStick;
  18821. /** @hidden */
  18822. _isConnected: boolean;
  18823. private _leftStickAxisX;
  18824. private _leftStickAxisY;
  18825. private _rightStickAxisX;
  18826. private _rightStickAxisY;
  18827. /**
  18828. * Triggered when the left control stick has been changed
  18829. */
  18830. private _onleftstickchanged;
  18831. /**
  18832. * Triggered when the right control stick has been changed
  18833. */
  18834. private _onrightstickchanged;
  18835. /**
  18836. * Represents a gamepad controller
  18837. */
  18838. static GAMEPAD: number;
  18839. /**
  18840. * Represents a generic controller
  18841. */
  18842. static GENERIC: number;
  18843. /**
  18844. * Represents an XBox controller
  18845. */
  18846. static XBOX: number;
  18847. /**
  18848. * Represents a pose-enabled controller
  18849. */
  18850. static POSE_ENABLED: number;
  18851. /**
  18852. * Represents an Dual Shock controller
  18853. */
  18854. static DUALSHOCK: number;
  18855. /**
  18856. * Specifies whether the left control stick should be Y-inverted
  18857. */
  18858. protected _invertLeftStickY: boolean;
  18859. /**
  18860. * Specifies if the gamepad has been connected
  18861. */
  18862. get isConnected(): boolean;
  18863. /**
  18864. * Initializes the gamepad
  18865. * @param id The id of the gamepad
  18866. * @param index The index of the gamepad
  18867. * @param browserGamepad The browser gamepad
  18868. * @param leftStickX The x component of the left joystick
  18869. * @param leftStickY The y component of the left joystick
  18870. * @param rightStickX The x component of the right joystick
  18871. * @param rightStickY The y component of the right joystick
  18872. */
  18873. constructor(
  18874. /**
  18875. * The id of the gamepad
  18876. */
  18877. id: string,
  18878. /**
  18879. * The index of the gamepad
  18880. */
  18881. index: number,
  18882. /**
  18883. * The browser gamepad
  18884. */
  18885. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18886. /**
  18887. * Callback triggered when the left joystick has changed
  18888. * @param callback
  18889. */
  18890. onleftstickchanged(callback: (values: StickValues) => void): void;
  18891. /**
  18892. * Callback triggered when the right joystick has changed
  18893. * @param callback
  18894. */
  18895. onrightstickchanged(callback: (values: StickValues) => void): void;
  18896. /**
  18897. * Gets the left joystick
  18898. */
  18899. get leftStick(): StickValues;
  18900. /**
  18901. * Sets the left joystick values
  18902. */
  18903. set leftStick(newValues: StickValues);
  18904. /**
  18905. * Gets the right joystick
  18906. */
  18907. get rightStick(): StickValues;
  18908. /**
  18909. * Sets the right joystick value
  18910. */
  18911. set rightStick(newValues: StickValues);
  18912. /**
  18913. * Updates the gamepad joystick positions
  18914. */
  18915. update(): void;
  18916. /**
  18917. * Disposes the gamepad
  18918. */
  18919. dispose(): void;
  18920. }
  18921. /**
  18922. * Represents a generic gamepad
  18923. */
  18924. export class GenericPad extends Gamepad {
  18925. private _buttons;
  18926. private _onbuttondown;
  18927. private _onbuttonup;
  18928. /**
  18929. * Observable triggered when a button has been pressed
  18930. */
  18931. onButtonDownObservable: Observable<number>;
  18932. /**
  18933. * Observable triggered when a button has been released
  18934. */
  18935. onButtonUpObservable: Observable<number>;
  18936. /**
  18937. * Callback triggered when a button has been pressed
  18938. * @param callback Called when a button has been pressed
  18939. */
  18940. onbuttondown(callback: (buttonPressed: number) => void): void;
  18941. /**
  18942. * Callback triggered when a button has been released
  18943. * @param callback Called when a button has been released
  18944. */
  18945. onbuttonup(callback: (buttonReleased: number) => void): void;
  18946. /**
  18947. * Initializes the generic gamepad
  18948. * @param id The id of the generic gamepad
  18949. * @param index The index of the generic gamepad
  18950. * @param browserGamepad The browser gamepad
  18951. */
  18952. constructor(id: string, index: number, browserGamepad: any);
  18953. private _setButtonValue;
  18954. /**
  18955. * Updates the generic gamepad
  18956. */
  18957. update(): void;
  18958. /**
  18959. * Disposes the generic gamepad
  18960. */
  18961. dispose(): void;
  18962. }
  18963. }
  18964. declare module BABYLON {
  18965. /**
  18966. * Defines the types of pose enabled controllers that are supported
  18967. */
  18968. export enum PoseEnabledControllerType {
  18969. /**
  18970. * HTC Vive
  18971. */
  18972. VIVE = 0,
  18973. /**
  18974. * Oculus Rift
  18975. */
  18976. OCULUS = 1,
  18977. /**
  18978. * Windows mixed reality
  18979. */
  18980. WINDOWS = 2,
  18981. /**
  18982. * Samsung gear VR
  18983. */
  18984. GEAR_VR = 3,
  18985. /**
  18986. * Google Daydream
  18987. */
  18988. DAYDREAM = 4,
  18989. /**
  18990. * Generic
  18991. */
  18992. GENERIC = 5
  18993. }
  18994. /**
  18995. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18996. */
  18997. export interface MutableGamepadButton {
  18998. /**
  18999. * Value of the button/trigger
  19000. */
  19001. value: number;
  19002. /**
  19003. * If the button/trigger is currently touched
  19004. */
  19005. touched: boolean;
  19006. /**
  19007. * If the button/trigger is currently pressed
  19008. */
  19009. pressed: boolean;
  19010. }
  19011. /**
  19012. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19013. * @hidden
  19014. */
  19015. export interface ExtendedGamepadButton extends GamepadButton {
  19016. /**
  19017. * If the button/trigger is currently pressed
  19018. */
  19019. readonly pressed: boolean;
  19020. /**
  19021. * If the button/trigger is currently touched
  19022. */
  19023. readonly touched: boolean;
  19024. /**
  19025. * Value of the button/trigger
  19026. */
  19027. readonly value: number;
  19028. }
  19029. /** @hidden */
  19030. export interface _GamePadFactory {
  19031. /**
  19032. * Returns whether or not the current gamepad can be created for this type of controller.
  19033. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19034. * @returns true if it can be created, otherwise false
  19035. */
  19036. canCreate(gamepadInfo: any): boolean;
  19037. /**
  19038. * Creates a new instance of the Gamepad.
  19039. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19040. * @returns the new gamepad instance
  19041. */
  19042. create(gamepadInfo: any): Gamepad;
  19043. }
  19044. /**
  19045. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19046. */
  19047. export class PoseEnabledControllerHelper {
  19048. /** @hidden */
  19049. static _ControllerFactories: _GamePadFactory[];
  19050. /** @hidden */
  19051. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19052. /**
  19053. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19054. * @param vrGamepad the gamepad to initialized
  19055. * @returns a vr controller of the type the gamepad identified as
  19056. */
  19057. static InitiateController(vrGamepad: any): Gamepad;
  19058. }
  19059. /**
  19060. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19061. */
  19062. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19063. /**
  19064. * If the controller is used in a webXR session
  19065. */
  19066. isXR: boolean;
  19067. private _deviceRoomPosition;
  19068. private _deviceRoomRotationQuaternion;
  19069. /**
  19070. * The device position in babylon space
  19071. */
  19072. devicePosition: Vector3;
  19073. /**
  19074. * The device rotation in babylon space
  19075. */
  19076. deviceRotationQuaternion: Quaternion;
  19077. /**
  19078. * The scale factor of the device in babylon space
  19079. */
  19080. deviceScaleFactor: number;
  19081. /**
  19082. * (Likely devicePosition should be used instead) The device position in its room space
  19083. */
  19084. position: Vector3;
  19085. /**
  19086. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19087. */
  19088. rotationQuaternion: Quaternion;
  19089. /**
  19090. * The type of controller (Eg. Windows mixed reality)
  19091. */
  19092. controllerType: PoseEnabledControllerType;
  19093. protected _calculatedPosition: Vector3;
  19094. private _calculatedRotation;
  19095. /**
  19096. * The raw pose from the device
  19097. */
  19098. rawPose: DevicePose;
  19099. private _trackPosition;
  19100. private _maxRotationDistFromHeadset;
  19101. private _draggedRoomRotation;
  19102. /**
  19103. * @hidden
  19104. */
  19105. _disableTrackPosition(fixedPosition: Vector3): void;
  19106. /**
  19107. * Internal, the mesh attached to the controller
  19108. * @hidden
  19109. */
  19110. _mesh: Nullable<AbstractMesh>;
  19111. private _poseControlledCamera;
  19112. private _leftHandSystemQuaternion;
  19113. /**
  19114. * Internal, matrix used to convert room space to babylon space
  19115. * @hidden
  19116. */
  19117. _deviceToWorld: Matrix;
  19118. /**
  19119. * Node to be used when casting a ray from the controller
  19120. * @hidden
  19121. */
  19122. _pointingPoseNode: Nullable<TransformNode>;
  19123. /**
  19124. * Name of the child mesh that can be used to cast a ray from the controller
  19125. */
  19126. static readonly POINTING_POSE: string;
  19127. /**
  19128. * Creates a new PoseEnabledController from a gamepad
  19129. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19130. */
  19131. constructor(browserGamepad: any);
  19132. private _workingMatrix;
  19133. /**
  19134. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19135. */
  19136. update(): void;
  19137. /**
  19138. * Updates only the pose device and mesh without doing any button event checking
  19139. */
  19140. protected _updatePoseAndMesh(): void;
  19141. /**
  19142. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19143. * @param poseData raw pose fromthe device
  19144. */
  19145. updateFromDevice(poseData: DevicePose): void;
  19146. /**
  19147. * @hidden
  19148. */
  19149. _meshAttachedObservable: Observable<AbstractMesh>;
  19150. /**
  19151. * Attaches a mesh to the controller
  19152. * @param mesh the mesh to be attached
  19153. */
  19154. attachToMesh(mesh: AbstractMesh): void;
  19155. /**
  19156. * Attaches the controllers mesh to a camera
  19157. * @param camera the camera the mesh should be attached to
  19158. */
  19159. attachToPoseControlledCamera(camera: TargetCamera): void;
  19160. /**
  19161. * Disposes of the controller
  19162. */
  19163. dispose(): void;
  19164. /**
  19165. * The mesh that is attached to the controller
  19166. */
  19167. get mesh(): Nullable<AbstractMesh>;
  19168. /**
  19169. * Gets the ray of the controller in the direction the controller is pointing
  19170. * @param length the length the resulting ray should be
  19171. * @returns a ray in the direction the controller is pointing
  19172. */
  19173. getForwardRay(length?: number): Ray;
  19174. }
  19175. }
  19176. declare module BABYLON {
  19177. /**
  19178. * Defines the WebVRController object that represents controllers tracked in 3D space
  19179. */
  19180. export abstract class WebVRController extends PoseEnabledController {
  19181. /**
  19182. * Internal, the default controller model for the controller
  19183. */
  19184. protected _defaultModel: Nullable<AbstractMesh>;
  19185. /**
  19186. * Fired when the trigger state has changed
  19187. */
  19188. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19189. /**
  19190. * Fired when the main button state has changed
  19191. */
  19192. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19193. /**
  19194. * Fired when the secondary button state has changed
  19195. */
  19196. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19197. /**
  19198. * Fired when the pad state has changed
  19199. */
  19200. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19201. /**
  19202. * Fired when controllers stick values have changed
  19203. */
  19204. onPadValuesChangedObservable: Observable<StickValues>;
  19205. /**
  19206. * Array of button availible on the controller
  19207. */
  19208. protected _buttons: Array<MutableGamepadButton>;
  19209. private _onButtonStateChange;
  19210. /**
  19211. * Fired when a controller button's state has changed
  19212. * @param callback the callback containing the button that was modified
  19213. */
  19214. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19215. /**
  19216. * X and Y axis corresponding to the controllers joystick
  19217. */
  19218. pad: StickValues;
  19219. /**
  19220. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19221. */
  19222. hand: string;
  19223. /**
  19224. * The default controller model for the controller
  19225. */
  19226. get defaultModel(): Nullable<AbstractMesh>;
  19227. /**
  19228. * Creates a new WebVRController from a gamepad
  19229. * @param vrGamepad the gamepad that the WebVRController should be created from
  19230. */
  19231. constructor(vrGamepad: any);
  19232. /**
  19233. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19234. */
  19235. update(): void;
  19236. /**
  19237. * Function to be called when a button is modified
  19238. */
  19239. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19240. /**
  19241. * Loads a mesh and attaches it to the controller
  19242. * @param scene the scene the mesh should be added to
  19243. * @param meshLoaded callback for when the mesh has been loaded
  19244. */
  19245. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19246. private _setButtonValue;
  19247. private _changes;
  19248. private _checkChanges;
  19249. /**
  19250. * Disposes of th webVRCOntroller
  19251. */
  19252. dispose(): void;
  19253. }
  19254. }
  19255. declare module BABYLON {
  19256. /**
  19257. * The HemisphericLight simulates the ambient environment light,
  19258. * so the passed direction is the light reflection direction, not the incoming direction.
  19259. */
  19260. export class HemisphericLight extends Light {
  19261. /**
  19262. * The groundColor is the light in the opposite direction to the one specified during creation.
  19263. * 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.
  19264. */
  19265. groundColor: Color3;
  19266. /**
  19267. * The light reflection direction, not the incoming direction.
  19268. */
  19269. direction: Vector3;
  19270. /**
  19271. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19272. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19273. * The HemisphericLight can't cast shadows.
  19274. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19275. * @param name The friendly name of the light
  19276. * @param direction The direction of the light reflection
  19277. * @param scene The scene the light belongs to
  19278. */
  19279. constructor(name: string, direction: Vector3, scene: Scene);
  19280. protected _buildUniformLayout(): void;
  19281. /**
  19282. * Returns the string "HemisphericLight".
  19283. * @return The class name
  19284. */
  19285. getClassName(): string;
  19286. /**
  19287. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19288. * Returns the updated direction.
  19289. * @param target The target the direction should point to
  19290. * @return The computed direction
  19291. */
  19292. setDirectionToTarget(target: Vector3): Vector3;
  19293. /**
  19294. * Returns the shadow generator associated to the light.
  19295. * @returns Always null for hemispheric lights because it does not support shadows.
  19296. */
  19297. getShadowGenerator(): Nullable<IShadowGenerator>;
  19298. /**
  19299. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19300. * @param effect The effect to update
  19301. * @param lightIndex The index of the light in the effect to update
  19302. * @returns The hemispheric light
  19303. */
  19304. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19305. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19306. /**
  19307. * Computes the world matrix of the node
  19308. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19309. * @param useWasUpdatedFlag defines a reserved property
  19310. * @returns the world matrix
  19311. */
  19312. computeWorldMatrix(): Matrix;
  19313. /**
  19314. * Returns the integer 3.
  19315. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19316. */
  19317. getTypeID(): number;
  19318. /**
  19319. * Prepares the list of defines specific to the light type.
  19320. * @param defines the list of defines
  19321. * @param lightIndex defines the index of the light for the effect
  19322. */
  19323. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19324. }
  19325. }
  19326. declare module BABYLON {
  19327. /** @hidden */
  19328. export var vrMultiviewToSingleviewPixelShader: {
  19329. name: string;
  19330. shader: string;
  19331. };
  19332. }
  19333. declare module BABYLON {
  19334. /**
  19335. * Renders to multiple views with a single draw call
  19336. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19337. */
  19338. export class MultiviewRenderTarget extends RenderTargetTexture {
  19339. /**
  19340. * Creates a multiview render target
  19341. * @param scene scene used with the render target
  19342. * @param size the size of the render target (used for each view)
  19343. */
  19344. constructor(scene: Scene, size?: number | {
  19345. width: number;
  19346. height: number;
  19347. } | {
  19348. ratio: number;
  19349. });
  19350. /**
  19351. * @hidden
  19352. * @param faceIndex the face index, if its a cube texture
  19353. */
  19354. _bindFrameBuffer(faceIndex?: number): void;
  19355. /**
  19356. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19357. * @returns the view count
  19358. */
  19359. getViewCount(): number;
  19360. }
  19361. }
  19362. declare module BABYLON {
  19363. /**
  19364. * Represents a camera frustum
  19365. */
  19366. export class Frustum {
  19367. /**
  19368. * Gets the planes representing the frustum
  19369. * @param transform matrix to be applied to the returned planes
  19370. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19371. */
  19372. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19373. /**
  19374. * Gets the near frustum plane transformed by the transform matrix
  19375. * @param transform transformation matrix to be applied to the resulting frustum plane
  19376. * @param frustumPlane the resuling frustum plane
  19377. */
  19378. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19379. /**
  19380. * Gets the far frustum plane transformed by the transform matrix
  19381. * @param transform transformation matrix to be applied to the resulting frustum plane
  19382. * @param frustumPlane the resuling frustum plane
  19383. */
  19384. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19385. /**
  19386. * Gets the left frustum plane transformed by the transform matrix
  19387. * @param transform transformation matrix to be applied to the resulting frustum plane
  19388. * @param frustumPlane the resuling frustum plane
  19389. */
  19390. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19391. /**
  19392. * Gets the right frustum plane transformed by the transform matrix
  19393. * @param transform transformation matrix to be applied to the resulting frustum plane
  19394. * @param frustumPlane the resuling frustum plane
  19395. */
  19396. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19397. /**
  19398. * Gets the top frustum plane transformed by the transform matrix
  19399. * @param transform transformation matrix to be applied to the resulting frustum plane
  19400. * @param frustumPlane the resuling frustum plane
  19401. */
  19402. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19403. /**
  19404. * Gets the bottom frustum plane transformed by the transform matrix
  19405. * @param transform transformation matrix to be applied to the resulting frustum plane
  19406. * @param frustumPlane the resuling frustum plane
  19407. */
  19408. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19409. /**
  19410. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19411. * @param transform transformation matrix to be applied to the resulting frustum planes
  19412. * @param frustumPlanes the resuling frustum planes
  19413. */
  19414. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19415. }
  19416. }
  19417. declare module BABYLON {
  19418. interface Engine {
  19419. /**
  19420. * Creates a new multiview render target
  19421. * @param width defines the width of the texture
  19422. * @param height defines the height of the texture
  19423. * @returns the created multiview texture
  19424. */
  19425. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19426. /**
  19427. * Binds a multiview framebuffer to be drawn to
  19428. * @param multiviewTexture texture to bind
  19429. */
  19430. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19431. }
  19432. interface Camera {
  19433. /**
  19434. * @hidden
  19435. * 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)
  19436. */
  19437. _useMultiviewToSingleView: boolean;
  19438. /**
  19439. * @hidden
  19440. * 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)
  19441. */
  19442. _multiviewTexture: Nullable<RenderTargetTexture>;
  19443. /**
  19444. * @hidden
  19445. * ensures the multiview texture of the camera exists and has the specified width/height
  19446. * @param width height to set on the multiview texture
  19447. * @param height width to set on the multiview texture
  19448. */
  19449. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19450. }
  19451. interface Scene {
  19452. /** @hidden */
  19453. _transformMatrixR: Matrix;
  19454. /** @hidden */
  19455. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19456. /** @hidden */
  19457. _createMultiviewUbo(): void;
  19458. /** @hidden */
  19459. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19460. /** @hidden */
  19461. _renderMultiviewToSingleView(camera: Camera): void;
  19462. }
  19463. }
  19464. declare module BABYLON {
  19465. /**
  19466. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19467. * This will not be used for webXR as it supports displaying texture arrays directly
  19468. */
  19469. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19470. /**
  19471. * Initializes a VRMultiviewToSingleview
  19472. * @param name name of the post process
  19473. * @param camera camera to be applied to
  19474. * @param scaleFactor scaling factor to the size of the output texture
  19475. */
  19476. constructor(name: string, camera: Camera, scaleFactor: number);
  19477. }
  19478. }
  19479. declare module BABYLON {
  19480. /**
  19481. * Interface used to define additional presentation attributes
  19482. */
  19483. export interface IVRPresentationAttributes {
  19484. /**
  19485. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19486. */
  19487. highRefreshRate: boolean;
  19488. /**
  19489. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19490. */
  19491. foveationLevel: number;
  19492. }
  19493. interface Engine {
  19494. /** @hidden */
  19495. _vrDisplay: any;
  19496. /** @hidden */
  19497. _vrSupported: boolean;
  19498. /** @hidden */
  19499. _oldSize: Size;
  19500. /** @hidden */
  19501. _oldHardwareScaleFactor: number;
  19502. /** @hidden */
  19503. _vrExclusivePointerMode: boolean;
  19504. /** @hidden */
  19505. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19506. /** @hidden */
  19507. _onVRDisplayPointerRestricted: () => void;
  19508. /** @hidden */
  19509. _onVRDisplayPointerUnrestricted: () => void;
  19510. /** @hidden */
  19511. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19512. /** @hidden */
  19513. _onVrDisplayDisconnect: Nullable<() => void>;
  19514. /** @hidden */
  19515. _onVrDisplayPresentChange: Nullable<() => void>;
  19516. /**
  19517. * Observable signaled when VR display mode changes
  19518. */
  19519. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19520. /**
  19521. * Observable signaled when VR request present is complete
  19522. */
  19523. onVRRequestPresentComplete: Observable<boolean>;
  19524. /**
  19525. * Observable signaled when VR request present starts
  19526. */
  19527. onVRRequestPresentStart: Observable<Engine>;
  19528. /**
  19529. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19530. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19531. */
  19532. isInVRExclusivePointerMode: boolean;
  19533. /**
  19534. * Gets a boolean indicating if a webVR device was detected
  19535. * @returns true if a webVR device was detected
  19536. */
  19537. isVRDevicePresent(): boolean;
  19538. /**
  19539. * Gets the current webVR device
  19540. * @returns the current webVR device (or null)
  19541. */
  19542. getVRDevice(): any;
  19543. /**
  19544. * Initializes a webVR display and starts listening to display change events
  19545. * The onVRDisplayChangedObservable will be notified upon these changes
  19546. * @returns A promise containing a VRDisplay and if vr is supported
  19547. */
  19548. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19549. /** @hidden */
  19550. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19551. /**
  19552. * Gets or sets the presentation attributes used to configure VR rendering
  19553. */
  19554. vrPresentationAttributes?: IVRPresentationAttributes;
  19555. /**
  19556. * Call this function to switch to webVR mode
  19557. * Will do nothing if webVR is not supported or if there is no webVR device
  19558. * @param options the webvr options provided to the camera. mainly used for multiview
  19559. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19560. */
  19561. enableVR(options: WebVROptions): void;
  19562. /** @hidden */
  19563. _onVRFullScreenTriggered(): void;
  19564. }
  19565. }
  19566. declare module BABYLON {
  19567. /**
  19568. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19569. * IMPORTANT!! The data is right-hand data.
  19570. * @export
  19571. * @interface DevicePose
  19572. */
  19573. export interface DevicePose {
  19574. /**
  19575. * The position of the device, values in array are [x,y,z].
  19576. */
  19577. readonly position: Nullable<Float32Array>;
  19578. /**
  19579. * The linearVelocity of the device, values in array are [x,y,z].
  19580. */
  19581. readonly linearVelocity: Nullable<Float32Array>;
  19582. /**
  19583. * The linearAcceleration of the device, values in array are [x,y,z].
  19584. */
  19585. readonly linearAcceleration: Nullable<Float32Array>;
  19586. /**
  19587. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19588. */
  19589. readonly orientation: Nullable<Float32Array>;
  19590. /**
  19591. * The angularVelocity of the device, values in array are [x,y,z].
  19592. */
  19593. readonly angularVelocity: Nullable<Float32Array>;
  19594. /**
  19595. * The angularAcceleration of the device, values in array are [x,y,z].
  19596. */
  19597. readonly angularAcceleration: Nullable<Float32Array>;
  19598. }
  19599. /**
  19600. * Interface representing a pose controlled object in Babylon.
  19601. * A pose controlled object has both regular pose values as well as pose values
  19602. * from an external device such as a VR head mounted display
  19603. */
  19604. export interface PoseControlled {
  19605. /**
  19606. * The position of the object in babylon space.
  19607. */
  19608. position: Vector3;
  19609. /**
  19610. * The rotation quaternion of the object in babylon space.
  19611. */
  19612. rotationQuaternion: Quaternion;
  19613. /**
  19614. * The position of the device in babylon space.
  19615. */
  19616. devicePosition?: Vector3;
  19617. /**
  19618. * The rotation quaternion of the device in babylon space.
  19619. */
  19620. deviceRotationQuaternion: Quaternion;
  19621. /**
  19622. * The raw pose coming from the device.
  19623. */
  19624. rawPose: Nullable<DevicePose>;
  19625. /**
  19626. * The scale of the device to be used when translating from device space to babylon space.
  19627. */
  19628. deviceScaleFactor: number;
  19629. /**
  19630. * Updates the poseControlled values based on the input device pose.
  19631. * @param poseData the pose data to update the object with
  19632. */
  19633. updateFromDevice(poseData: DevicePose): void;
  19634. }
  19635. /**
  19636. * Set of options to customize the webVRCamera
  19637. */
  19638. export interface WebVROptions {
  19639. /**
  19640. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19641. */
  19642. trackPosition?: boolean;
  19643. /**
  19644. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19645. */
  19646. positionScale?: number;
  19647. /**
  19648. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19649. */
  19650. displayName?: string;
  19651. /**
  19652. * Should the native controller meshes be initialized. (default: true)
  19653. */
  19654. controllerMeshes?: boolean;
  19655. /**
  19656. * Creating a default HemiLight only on controllers. (default: true)
  19657. */
  19658. defaultLightingOnControllers?: boolean;
  19659. /**
  19660. * If you don't want to use the default VR button of the helper. (default: false)
  19661. */
  19662. useCustomVRButton?: boolean;
  19663. /**
  19664. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19665. */
  19666. customVRButton?: HTMLButtonElement;
  19667. /**
  19668. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19669. */
  19670. rayLength?: number;
  19671. /**
  19672. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19673. */
  19674. defaultHeight?: number;
  19675. /**
  19676. * If multiview should be used if availible (default: false)
  19677. */
  19678. useMultiview?: boolean;
  19679. }
  19680. /**
  19681. * This represents a WebVR camera.
  19682. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19683. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19684. */
  19685. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19686. private webVROptions;
  19687. /**
  19688. * @hidden
  19689. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19690. */
  19691. _vrDevice: any;
  19692. /**
  19693. * The rawPose of the vrDevice.
  19694. */
  19695. rawPose: Nullable<DevicePose>;
  19696. private _onVREnabled;
  19697. private _specsVersion;
  19698. private _attached;
  19699. private _frameData;
  19700. protected _descendants: Array<Node>;
  19701. private _deviceRoomPosition;
  19702. /** @hidden */
  19703. _deviceRoomRotationQuaternion: Quaternion;
  19704. private _standingMatrix;
  19705. /**
  19706. * Represents device position in babylon space.
  19707. */
  19708. devicePosition: Vector3;
  19709. /**
  19710. * Represents device rotation in babylon space.
  19711. */
  19712. deviceRotationQuaternion: Quaternion;
  19713. /**
  19714. * The scale of the device to be used when translating from device space to babylon space.
  19715. */
  19716. deviceScaleFactor: number;
  19717. private _deviceToWorld;
  19718. private _worldToDevice;
  19719. /**
  19720. * References to the webVR controllers for the vrDevice.
  19721. */
  19722. controllers: Array<WebVRController>;
  19723. /**
  19724. * Emits an event when a controller is attached.
  19725. */
  19726. onControllersAttachedObservable: Observable<WebVRController[]>;
  19727. /**
  19728. * Emits an event when a controller's mesh has been loaded;
  19729. */
  19730. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19731. /**
  19732. * Emits an event when the HMD's pose has been updated.
  19733. */
  19734. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19735. private _poseSet;
  19736. /**
  19737. * If the rig cameras be used as parent instead of this camera.
  19738. */
  19739. rigParenting: boolean;
  19740. private _lightOnControllers;
  19741. private _defaultHeight?;
  19742. /**
  19743. * Instantiates a WebVRFreeCamera.
  19744. * @param name The name of the WebVRFreeCamera
  19745. * @param position The starting anchor position for the camera
  19746. * @param scene The scene the camera belongs to
  19747. * @param webVROptions a set of customizable options for the webVRCamera
  19748. */
  19749. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19750. /**
  19751. * Gets the device distance from the ground in meters.
  19752. * @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.
  19753. */
  19754. deviceDistanceToRoomGround(): number;
  19755. /**
  19756. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19757. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19758. */
  19759. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19760. /**
  19761. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19762. * @returns A promise with a boolean set to if the standing matrix is supported.
  19763. */
  19764. useStandingMatrixAsync(): Promise<boolean>;
  19765. /**
  19766. * Disposes the camera
  19767. */
  19768. dispose(): void;
  19769. /**
  19770. * Gets a vrController by name.
  19771. * @param name The name of the controller to retreive
  19772. * @returns the controller matching the name specified or null if not found
  19773. */
  19774. getControllerByName(name: string): Nullable<WebVRController>;
  19775. private _leftController;
  19776. /**
  19777. * The controller corresponding to the users left hand.
  19778. */
  19779. get leftController(): Nullable<WebVRController>;
  19780. private _rightController;
  19781. /**
  19782. * The controller corresponding to the users right hand.
  19783. */
  19784. get rightController(): Nullable<WebVRController>;
  19785. /**
  19786. * Casts a ray forward from the vrCamera's gaze.
  19787. * @param length Length of the ray (default: 100)
  19788. * @returns the ray corresponding to the gaze
  19789. */
  19790. getForwardRay(length?: number): Ray;
  19791. /**
  19792. * @hidden
  19793. * Updates the camera based on device's frame data
  19794. */
  19795. _checkInputs(): void;
  19796. /**
  19797. * Updates the poseControlled values based on the input device pose.
  19798. * @param poseData Pose coming from the device
  19799. */
  19800. updateFromDevice(poseData: DevicePose): void;
  19801. private _htmlElementAttached;
  19802. private _detachIfAttached;
  19803. /**
  19804. * WebVR's attach control will start broadcasting frames to the device.
  19805. * Note that in certain browsers (chrome for example) this function must be called
  19806. * within a user-interaction callback. Example:
  19807. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19808. *
  19809. * @param element html element to attach the vrDevice to
  19810. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19811. */
  19812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19813. /**
  19814. * Detaches the camera from the html element and disables VR
  19815. *
  19816. * @param element html element to detach from
  19817. */
  19818. detachControl(element: HTMLElement): void;
  19819. /**
  19820. * @returns the name of this class
  19821. */
  19822. getClassName(): string;
  19823. /**
  19824. * Calls resetPose on the vrDisplay
  19825. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19826. */
  19827. resetToCurrentRotation(): void;
  19828. /**
  19829. * @hidden
  19830. * Updates the rig cameras (left and right eye)
  19831. */
  19832. _updateRigCameras(): void;
  19833. private _workingVector;
  19834. private _oneVector;
  19835. private _workingMatrix;
  19836. private updateCacheCalled;
  19837. private _correctPositionIfNotTrackPosition;
  19838. /**
  19839. * @hidden
  19840. * Updates the cached values of the camera
  19841. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19842. */
  19843. _updateCache(ignoreParentClass?: boolean): void;
  19844. /**
  19845. * @hidden
  19846. * Get current device position in babylon world
  19847. */
  19848. _computeDevicePosition(): void;
  19849. /**
  19850. * Updates the current device position and rotation in the babylon world
  19851. */
  19852. update(): void;
  19853. /**
  19854. * @hidden
  19855. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19856. * @returns an identity matrix
  19857. */
  19858. _getViewMatrix(): Matrix;
  19859. private _tmpMatrix;
  19860. /**
  19861. * This function is called by the two RIG cameras.
  19862. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19863. * @hidden
  19864. */
  19865. _getWebVRViewMatrix(): Matrix;
  19866. /** @hidden */
  19867. _getWebVRProjectionMatrix(): Matrix;
  19868. private _onGamepadConnectedObserver;
  19869. private _onGamepadDisconnectedObserver;
  19870. private _updateCacheWhenTrackingDisabledObserver;
  19871. /**
  19872. * Initializes the controllers and their meshes
  19873. */
  19874. initControllers(): void;
  19875. }
  19876. }
  19877. declare module BABYLON {
  19878. /**
  19879. * Size options for a post process
  19880. */
  19881. export type PostProcessOptions = {
  19882. width: number;
  19883. height: number;
  19884. };
  19885. /**
  19886. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19887. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19888. */
  19889. export class PostProcess {
  19890. /** Name of the PostProcess. */
  19891. name: string;
  19892. /**
  19893. * Gets or sets the unique id of the post process
  19894. */
  19895. uniqueId: number;
  19896. /**
  19897. * Width of the texture to apply the post process on
  19898. */
  19899. width: number;
  19900. /**
  19901. * Height of the texture to apply the post process on
  19902. */
  19903. height: number;
  19904. /**
  19905. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19906. * @hidden
  19907. */
  19908. _outputTexture: Nullable<InternalTexture>;
  19909. /**
  19910. * Sampling mode used by the shader
  19911. * See https://doc.babylonjs.com/classes/3.1/texture
  19912. */
  19913. renderTargetSamplingMode: number;
  19914. /**
  19915. * Clear color to use when screen clearing
  19916. */
  19917. clearColor: Color4;
  19918. /**
  19919. * If the buffer needs to be cleared before applying the post process. (default: true)
  19920. * Should be set to false if shader will overwrite all previous pixels.
  19921. */
  19922. autoClear: boolean;
  19923. /**
  19924. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19925. */
  19926. alphaMode: number;
  19927. /**
  19928. * Sets the setAlphaBlendConstants of the babylon engine
  19929. */
  19930. alphaConstants: Color4;
  19931. /**
  19932. * Animations to be used for the post processing
  19933. */
  19934. animations: Animation[];
  19935. /**
  19936. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19937. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19938. */
  19939. enablePixelPerfectMode: boolean;
  19940. /**
  19941. * Force the postprocess to be applied without taking in account viewport
  19942. */
  19943. forceFullscreenViewport: boolean;
  19944. /**
  19945. * List of inspectable custom properties (used by the Inspector)
  19946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19947. */
  19948. inspectableCustomProperties: IInspectable[];
  19949. /**
  19950. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19951. *
  19952. * | Value | Type | Description |
  19953. * | ----- | ----------------------------------- | ----------- |
  19954. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19955. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19956. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19957. *
  19958. */
  19959. scaleMode: number;
  19960. /**
  19961. * Force textures to be a power of two (default: false)
  19962. */
  19963. alwaysForcePOT: boolean;
  19964. private _samples;
  19965. /**
  19966. * Number of sample textures (default: 1)
  19967. */
  19968. get samples(): number;
  19969. set samples(n: number);
  19970. /**
  19971. * Modify the scale of the post process to be the same as the viewport (default: false)
  19972. */
  19973. adaptScaleToCurrentViewport: boolean;
  19974. private _camera;
  19975. private _scene;
  19976. private _engine;
  19977. private _options;
  19978. private _reusable;
  19979. private _textureType;
  19980. private _textureFormat;
  19981. /**
  19982. * Smart array of input and output textures for the post process.
  19983. * @hidden
  19984. */
  19985. _textures: SmartArray<InternalTexture>;
  19986. /**
  19987. * The index in _textures that corresponds to the output texture.
  19988. * @hidden
  19989. */
  19990. _currentRenderTextureInd: number;
  19991. private _effect;
  19992. private _samplers;
  19993. private _fragmentUrl;
  19994. private _vertexUrl;
  19995. private _parameters;
  19996. private _scaleRatio;
  19997. protected _indexParameters: any;
  19998. private _shareOutputWithPostProcess;
  19999. private _texelSize;
  20000. private _forcedOutputTexture;
  20001. /**
  20002. * Returns the fragment url or shader name used in the post process.
  20003. * @returns the fragment url or name in the shader store.
  20004. */
  20005. getEffectName(): string;
  20006. /**
  20007. * An event triggered when the postprocess is activated.
  20008. */
  20009. onActivateObservable: Observable<Camera>;
  20010. private _onActivateObserver;
  20011. /**
  20012. * A function that is added to the onActivateObservable
  20013. */
  20014. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20015. /**
  20016. * An event triggered when the postprocess changes its size.
  20017. */
  20018. onSizeChangedObservable: Observable<PostProcess>;
  20019. private _onSizeChangedObserver;
  20020. /**
  20021. * A function that is added to the onSizeChangedObservable
  20022. */
  20023. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20024. /**
  20025. * An event triggered when the postprocess applies its effect.
  20026. */
  20027. onApplyObservable: Observable<Effect>;
  20028. private _onApplyObserver;
  20029. /**
  20030. * A function that is added to the onApplyObservable
  20031. */
  20032. set onApply(callback: (effect: Effect) => void);
  20033. /**
  20034. * An event triggered before rendering the postprocess
  20035. */
  20036. onBeforeRenderObservable: Observable<Effect>;
  20037. private _onBeforeRenderObserver;
  20038. /**
  20039. * A function that is added to the onBeforeRenderObservable
  20040. */
  20041. set onBeforeRender(callback: (effect: Effect) => void);
  20042. /**
  20043. * An event triggered after rendering the postprocess
  20044. */
  20045. onAfterRenderObservable: Observable<Effect>;
  20046. private _onAfterRenderObserver;
  20047. /**
  20048. * A function that is added to the onAfterRenderObservable
  20049. */
  20050. set onAfterRender(callback: (efect: Effect) => void);
  20051. /**
  20052. * 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
  20053. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20054. */
  20055. get inputTexture(): InternalTexture;
  20056. set inputTexture(value: InternalTexture);
  20057. /**
  20058. * Gets the camera which post process is applied to.
  20059. * @returns The camera the post process is applied to.
  20060. */
  20061. getCamera(): Camera;
  20062. /**
  20063. * Gets the texel size of the postprocess.
  20064. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20065. */
  20066. get texelSize(): Vector2;
  20067. /**
  20068. * Creates a new instance PostProcess
  20069. * @param name The name of the PostProcess.
  20070. * @param fragmentUrl The url of the fragment shader to be used.
  20071. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20072. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20073. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20074. * @param camera The camera to apply the render pass to.
  20075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20076. * @param engine The engine which the post process will be applied. (default: current engine)
  20077. * @param reusable If the post process can be reused on the same frame. (default: false)
  20078. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20079. * @param textureType Type of textures used when performing the post process. (default: 0)
  20080. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20081. * @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
  20082. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20083. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20084. */
  20085. constructor(
  20086. /** Name of the PostProcess. */
  20087. 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);
  20088. /**
  20089. * Gets a string idenfifying the name of the class
  20090. * @returns "PostProcess" string
  20091. */
  20092. getClassName(): string;
  20093. /**
  20094. * Gets the engine which this post process belongs to.
  20095. * @returns The engine the post process was enabled with.
  20096. */
  20097. getEngine(): Engine;
  20098. /**
  20099. * The effect that is created when initializing the post process.
  20100. * @returns The created effect corresponding the the postprocess.
  20101. */
  20102. getEffect(): Effect;
  20103. /**
  20104. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20105. * @param postProcess The post process to share the output with.
  20106. * @returns This post process.
  20107. */
  20108. shareOutputWith(postProcess: PostProcess): PostProcess;
  20109. /**
  20110. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20111. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20112. */
  20113. useOwnOutput(): void;
  20114. /**
  20115. * Updates the effect with the current post process compile time values and recompiles the shader.
  20116. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20117. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20118. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20119. * @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
  20120. * @param onCompiled Called when the shader has been compiled.
  20121. * @param onError Called if there is an error when compiling a shader.
  20122. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20123. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20124. */
  20125. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  20126. /**
  20127. * The post process is reusable if it can be used multiple times within one frame.
  20128. * @returns If the post process is reusable
  20129. */
  20130. isReusable(): boolean;
  20131. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20132. markTextureDirty(): void;
  20133. /**
  20134. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20135. * 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.
  20136. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20137. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20138. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20139. * @returns The target texture that was bound to be written to.
  20140. */
  20141. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20142. /**
  20143. * If the post process is supported.
  20144. */
  20145. get isSupported(): boolean;
  20146. /**
  20147. * The aspect ratio of the output texture.
  20148. */
  20149. get aspectRatio(): number;
  20150. /**
  20151. * Get a value indicating if the post-process is ready to be used
  20152. * @returns true if the post-process is ready (shader is compiled)
  20153. */
  20154. isReady(): boolean;
  20155. /**
  20156. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20157. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20158. */
  20159. apply(): Nullable<Effect>;
  20160. private _disposeTextures;
  20161. /**
  20162. * Disposes the post process.
  20163. * @param camera The camera to dispose the post process on.
  20164. */
  20165. dispose(camera?: Camera): void;
  20166. }
  20167. }
  20168. declare module BABYLON {
  20169. /** @hidden */
  20170. export var kernelBlurVaryingDeclaration: {
  20171. name: string;
  20172. shader: string;
  20173. };
  20174. }
  20175. declare module BABYLON {
  20176. /** @hidden */
  20177. export var kernelBlurFragment: {
  20178. name: string;
  20179. shader: string;
  20180. };
  20181. }
  20182. declare module BABYLON {
  20183. /** @hidden */
  20184. export var kernelBlurFragment2: {
  20185. name: string;
  20186. shader: string;
  20187. };
  20188. }
  20189. declare module BABYLON {
  20190. /** @hidden */
  20191. export var kernelBlurPixelShader: {
  20192. name: string;
  20193. shader: string;
  20194. };
  20195. }
  20196. declare module BABYLON {
  20197. /** @hidden */
  20198. export var kernelBlurVertex: {
  20199. name: string;
  20200. shader: string;
  20201. };
  20202. }
  20203. declare module BABYLON {
  20204. /** @hidden */
  20205. export var kernelBlurVertexShader: {
  20206. name: string;
  20207. shader: string;
  20208. };
  20209. }
  20210. declare module BABYLON {
  20211. /**
  20212. * The Blur Post Process which blurs an image based on a kernel and direction.
  20213. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20214. */
  20215. export class BlurPostProcess extends PostProcess {
  20216. /** The direction in which to blur the image. */
  20217. direction: Vector2;
  20218. private blockCompilation;
  20219. protected _kernel: number;
  20220. protected _idealKernel: number;
  20221. protected _packedFloat: boolean;
  20222. private _staticDefines;
  20223. /**
  20224. * Sets the length in pixels of the blur sample region
  20225. */
  20226. set kernel(v: number);
  20227. /**
  20228. * Gets the length in pixels of the blur sample region
  20229. */
  20230. get kernel(): number;
  20231. /**
  20232. * Sets wether or not the blur needs to unpack/repack floats
  20233. */
  20234. set packedFloat(v: boolean);
  20235. /**
  20236. * Gets wether or not the blur is unpacking/repacking floats
  20237. */
  20238. get packedFloat(): boolean;
  20239. /**
  20240. * Creates a new instance BlurPostProcess
  20241. * @param name The name of the effect.
  20242. * @param direction The direction in which to blur the image.
  20243. * @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.
  20244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20245. * @param camera The camera to apply the render pass to.
  20246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20247. * @param engine The engine which the post process will be applied. (default: current engine)
  20248. * @param reusable If the post process can be reused on the same frame. (default: false)
  20249. * @param textureType Type of textures used when performing the post process. (default: 0)
  20250. * @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)
  20251. */
  20252. constructor(name: string,
  20253. /** The direction in which to blur the image. */
  20254. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20255. /**
  20256. * Updates the effect with the current post process compile time values and recompiles the shader.
  20257. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20258. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20259. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20260. * @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
  20261. * @param onCompiled Called when the shader has been compiled.
  20262. * @param onError Called if there is an error when compiling a shader.
  20263. */
  20264. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20265. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20266. /**
  20267. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20268. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20269. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20270. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20271. * The gaps between physical kernels are compensated for in the weighting of the samples
  20272. * @param idealKernel Ideal blur kernel.
  20273. * @return Nearest best kernel.
  20274. */
  20275. protected _nearestBestKernel(idealKernel: number): number;
  20276. /**
  20277. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20278. * @param x The point on the Gaussian distribution to sample.
  20279. * @return the value of the Gaussian function at x.
  20280. */
  20281. protected _gaussianWeight(x: number): number;
  20282. /**
  20283. * Generates a string that can be used as a floating point number in GLSL.
  20284. * @param x Value to print.
  20285. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20286. * @return GLSL float string.
  20287. */
  20288. protected _glslFloat(x: number, decimalFigures?: number): string;
  20289. }
  20290. }
  20291. declare module BABYLON {
  20292. /**
  20293. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20294. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20295. * You can then easily use it as a reflectionTexture on a flat surface.
  20296. * In case the surface is not a plane, please consider relying on reflection probes.
  20297. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20298. */
  20299. export class MirrorTexture extends RenderTargetTexture {
  20300. private scene;
  20301. /**
  20302. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20303. * 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.
  20304. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20305. */
  20306. mirrorPlane: Plane;
  20307. /**
  20308. * Define the blur ratio used to blur the reflection if needed.
  20309. */
  20310. set blurRatio(value: number);
  20311. get blurRatio(): number;
  20312. /**
  20313. * Define the adaptive blur kernel used to blur the reflection if needed.
  20314. * This will autocompute the closest best match for the `blurKernel`
  20315. */
  20316. set adaptiveBlurKernel(value: number);
  20317. /**
  20318. * Define the blur kernel used to blur the reflection if needed.
  20319. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20320. */
  20321. set blurKernel(value: number);
  20322. /**
  20323. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20324. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20325. */
  20326. set blurKernelX(value: number);
  20327. get blurKernelX(): number;
  20328. /**
  20329. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20330. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20331. */
  20332. set blurKernelY(value: number);
  20333. get blurKernelY(): number;
  20334. private _autoComputeBlurKernel;
  20335. protected _onRatioRescale(): void;
  20336. private _updateGammaSpace;
  20337. private _imageProcessingConfigChangeObserver;
  20338. private _transformMatrix;
  20339. private _mirrorMatrix;
  20340. private _savedViewMatrix;
  20341. private _blurX;
  20342. private _blurY;
  20343. private _adaptiveBlurKernel;
  20344. private _blurKernelX;
  20345. private _blurKernelY;
  20346. private _blurRatio;
  20347. /**
  20348. * Instantiates a Mirror Texture.
  20349. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20350. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20351. * You can then easily use it as a reflectionTexture on a flat surface.
  20352. * In case the surface is not a plane, please consider relying on reflection probes.
  20353. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20354. * @param name
  20355. * @param size
  20356. * @param scene
  20357. * @param generateMipMaps
  20358. * @param type
  20359. * @param samplingMode
  20360. * @param generateDepthBuffer
  20361. */
  20362. constructor(name: string, size: number | {
  20363. width: number;
  20364. height: number;
  20365. } | {
  20366. ratio: number;
  20367. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20368. private _preparePostProcesses;
  20369. /**
  20370. * Clone the mirror texture.
  20371. * @returns the cloned texture
  20372. */
  20373. clone(): MirrorTexture;
  20374. /**
  20375. * Serialize the texture to a JSON representation you could use in Parse later on
  20376. * @returns the serialized JSON representation
  20377. */
  20378. serialize(): any;
  20379. /**
  20380. * Dispose the texture and release its associated resources.
  20381. */
  20382. dispose(): void;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20388. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20389. */
  20390. export class Texture extends BaseTexture {
  20391. /**
  20392. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20393. */
  20394. static SerializeBuffers: boolean;
  20395. /** @hidden */
  20396. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20397. /** @hidden */
  20398. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20399. /** @hidden */
  20400. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20401. /** nearest is mag = nearest and min = nearest and mip = linear */
  20402. static readonly NEAREST_SAMPLINGMODE: number;
  20403. /** nearest is mag = nearest and min = nearest and mip = linear */
  20404. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20405. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20406. static readonly BILINEAR_SAMPLINGMODE: number;
  20407. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20408. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20409. /** Trilinear is mag = linear and min = linear and mip = linear */
  20410. static readonly TRILINEAR_SAMPLINGMODE: number;
  20411. /** Trilinear is mag = linear and min = linear and mip = linear */
  20412. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20413. /** mag = nearest and min = nearest and mip = nearest */
  20414. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20415. /** mag = nearest and min = linear and mip = nearest */
  20416. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20417. /** mag = nearest and min = linear and mip = linear */
  20418. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20419. /** mag = nearest and min = linear and mip = none */
  20420. static readonly NEAREST_LINEAR: number;
  20421. /** mag = nearest and min = nearest and mip = none */
  20422. static readonly NEAREST_NEAREST: number;
  20423. /** mag = linear and min = nearest and mip = nearest */
  20424. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20425. /** mag = linear and min = nearest and mip = linear */
  20426. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20427. /** mag = linear and min = linear and mip = none */
  20428. static readonly LINEAR_LINEAR: number;
  20429. /** mag = linear and min = nearest and mip = none */
  20430. static readonly LINEAR_NEAREST: number;
  20431. /** Explicit coordinates mode */
  20432. static readonly EXPLICIT_MODE: number;
  20433. /** Spherical coordinates mode */
  20434. static readonly SPHERICAL_MODE: number;
  20435. /** Planar coordinates mode */
  20436. static readonly PLANAR_MODE: number;
  20437. /** Cubic coordinates mode */
  20438. static readonly CUBIC_MODE: number;
  20439. /** Projection coordinates mode */
  20440. static readonly PROJECTION_MODE: number;
  20441. /** Inverse Cubic coordinates mode */
  20442. static readonly SKYBOX_MODE: number;
  20443. /** Inverse Cubic coordinates mode */
  20444. static readonly INVCUBIC_MODE: number;
  20445. /** Equirectangular coordinates mode */
  20446. static readonly EQUIRECTANGULAR_MODE: number;
  20447. /** Equirectangular Fixed coordinates mode */
  20448. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20449. /** Equirectangular Fixed Mirrored coordinates mode */
  20450. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20451. /** Texture is not repeating outside of 0..1 UVs */
  20452. static readonly CLAMP_ADDRESSMODE: number;
  20453. /** Texture is repeating outside of 0..1 UVs */
  20454. static readonly WRAP_ADDRESSMODE: number;
  20455. /** Texture is repeating and mirrored */
  20456. static readonly MIRROR_ADDRESSMODE: number;
  20457. /**
  20458. * 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
  20459. */
  20460. static UseSerializedUrlIfAny: boolean;
  20461. /**
  20462. * Define the url of the texture.
  20463. */
  20464. url: Nullable<string>;
  20465. /**
  20466. * Define an offset on the texture to offset the u coordinates of the UVs
  20467. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20468. */
  20469. uOffset: number;
  20470. /**
  20471. * Define an offset on the texture to offset the v coordinates of the UVs
  20472. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20473. */
  20474. vOffset: number;
  20475. /**
  20476. * Define an offset on the texture to scale the u coordinates of the UVs
  20477. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20478. */
  20479. uScale: number;
  20480. /**
  20481. * Define an offset on the texture to scale the v coordinates of the UVs
  20482. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20483. */
  20484. vScale: number;
  20485. /**
  20486. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20487. * @see http://doc.babylonjs.com/how_to/more_materials
  20488. */
  20489. uAng: number;
  20490. /**
  20491. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20492. * @see http://doc.babylonjs.com/how_to/more_materials
  20493. */
  20494. vAng: number;
  20495. /**
  20496. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20497. * @see http://doc.babylonjs.com/how_to/more_materials
  20498. */
  20499. wAng: number;
  20500. /**
  20501. * Defines the center of rotation (U)
  20502. */
  20503. uRotationCenter: number;
  20504. /**
  20505. * Defines the center of rotation (V)
  20506. */
  20507. vRotationCenter: number;
  20508. /**
  20509. * Defines the center of rotation (W)
  20510. */
  20511. wRotationCenter: number;
  20512. /**
  20513. * Are mip maps generated for this texture or not.
  20514. */
  20515. get noMipmap(): boolean;
  20516. /**
  20517. * List of inspectable custom properties (used by the Inspector)
  20518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20519. */
  20520. inspectableCustomProperties: Nullable<IInspectable[]>;
  20521. private _noMipmap;
  20522. /** @hidden */
  20523. _invertY: boolean;
  20524. private _rowGenerationMatrix;
  20525. private _cachedTextureMatrix;
  20526. private _projectionModeMatrix;
  20527. private _t0;
  20528. private _t1;
  20529. private _t2;
  20530. private _cachedUOffset;
  20531. private _cachedVOffset;
  20532. private _cachedUScale;
  20533. private _cachedVScale;
  20534. private _cachedUAng;
  20535. private _cachedVAng;
  20536. private _cachedWAng;
  20537. private _cachedProjectionMatrixId;
  20538. private _cachedCoordinatesMode;
  20539. /** @hidden */
  20540. protected _initialSamplingMode: number;
  20541. /** @hidden */
  20542. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20543. private _deleteBuffer;
  20544. protected _format: Nullable<number>;
  20545. private _delayedOnLoad;
  20546. private _delayedOnError;
  20547. private _mimeType?;
  20548. /**
  20549. * Observable triggered once the texture has been loaded.
  20550. */
  20551. onLoadObservable: Observable<Texture>;
  20552. protected _isBlocking: boolean;
  20553. /**
  20554. * Is the texture preventing material to render while loading.
  20555. * If false, a default texture will be used instead of the loading one during the preparation step.
  20556. */
  20557. set isBlocking(value: boolean);
  20558. get isBlocking(): boolean;
  20559. /**
  20560. * Get the current sampling mode associated with the texture.
  20561. */
  20562. get samplingMode(): number;
  20563. /**
  20564. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20565. */
  20566. get invertY(): boolean;
  20567. /**
  20568. * Instantiates a new texture.
  20569. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20570. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20571. * @param url defines the url of the picture to load as a texture
  20572. * @param sceneOrEngine defines the scene or engine the texture will belong to
  20573. * @param noMipmap defines if the texture will require mip maps or not
  20574. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20575. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20576. * @param onLoad defines a callback triggered when the texture has been loaded
  20577. * @param onError defines a callback triggered when an error occurred during the loading session
  20578. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20579. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20580. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20581. * @param mimeType defines an optional mime type information
  20582. */
  20583. 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);
  20584. /**
  20585. * Update the url (and optional buffer) of this texture if url was null during construction.
  20586. * @param url the url of the texture
  20587. * @param buffer the buffer of the texture (defaults to null)
  20588. * @param onLoad callback called when the texture is loaded (defaults to null)
  20589. */
  20590. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20591. /**
  20592. * Finish the loading sequence of a texture flagged as delayed load.
  20593. * @hidden
  20594. */
  20595. delayLoad(): void;
  20596. private _prepareRowForTextureGeneration;
  20597. /**
  20598. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20599. * @returns the transform matrix of the texture.
  20600. */
  20601. getTextureMatrix(uBase?: number): Matrix;
  20602. /**
  20603. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20604. * @returns The reflection texture transform
  20605. */
  20606. getReflectionTextureMatrix(): Matrix;
  20607. /**
  20608. * Clones the texture.
  20609. * @returns the cloned texture
  20610. */
  20611. clone(): Texture;
  20612. /**
  20613. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20614. * @returns The JSON representation of the texture
  20615. */
  20616. serialize(): any;
  20617. /**
  20618. * Get the current class name of the texture useful for serialization or dynamic coding.
  20619. * @returns "Texture"
  20620. */
  20621. getClassName(): string;
  20622. /**
  20623. * Dispose the texture and release its associated resources.
  20624. */
  20625. dispose(): void;
  20626. /**
  20627. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20628. * @param parsedTexture Define the JSON representation of the texture
  20629. * @param scene Define the scene the parsed texture should be instantiated in
  20630. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20631. * @returns The parsed texture if successful
  20632. */
  20633. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20634. /**
  20635. * Creates a texture from its base 64 representation.
  20636. * @param data Define the base64 payload without the data: prefix
  20637. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20638. * @param scene Define the scene the texture should belong to
  20639. * @param noMipmap Forces the texture to not create mip map information if true
  20640. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20641. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20642. * @param onLoad define a callback triggered when the texture has been loaded
  20643. * @param onError define a callback triggered when an error occurred during the loading session
  20644. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20645. * @returns the created texture
  20646. */
  20647. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20648. /**
  20649. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20650. * @param data Define the base64 payload without the data: prefix
  20651. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20652. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20653. * @param scene Define the scene the texture should belong to
  20654. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20655. * @param noMipmap Forces the texture to not create mip map information if true
  20656. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20657. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20658. * @param onLoad define a callback triggered when the texture has been loaded
  20659. * @param onError define a callback triggered when an error occurred during the loading session
  20660. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20661. * @returns the created texture
  20662. */
  20663. 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;
  20664. }
  20665. }
  20666. declare module BABYLON {
  20667. /**
  20668. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20669. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20670. */
  20671. export class PostProcessManager {
  20672. private _scene;
  20673. private _indexBuffer;
  20674. private _vertexBuffers;
  20675. /**
  20676. * Creates a new instance PostProcess
  20677. * @param scene The scene that the post process is associated with.
  20678. */
  20679. constructor(scene: Scene);
  20680. private _prepareBuffers;
  20681. private _buildIndexBuffer;
  20682. /**
  20683. * Rebuilds the vertex buffers of the manager.
  20684. * @hidden
  20685. */
  20686. _rebuild(): void;
  20687. /**
  20688. * Prepares a frame to be run through a post process.
  20689. * @param sourceTexture The input texture to the post procesess. (default: null)
  20690. * @param postProcesses An array of post processes to be run. (default: null)
  20691. * @returns True if the post processes were able to be run.
  20692. * @hidden
  20693. */
  20694. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20695. /**
  20696. * Manually render a set of post processes to a texture.
  20697. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20698. * @param postProcesses An array of post processes to be run.
  20699. * @param targetTexture The target texture to render to.
  20700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20701. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20702. * @param lodLevel defines which lod of the texture to render to
  20703. */
  20704. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20705. /**
  20706. * Finalize the result of the output of the postprocesses.
  20707. * @param doNotPresent If true the result will not be displayed to the screen.
  20708. * @param targetTexture The target texture to render to.
  20709. * @param faceIndex The index of the face to bind the target texture to.
  20710. * @param postProcesses The array of post processes to render.
  20711. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20712. * @hidden
  20713. */
  20714. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20715. /**
  20716. * Disposes of the post process manager.
  20717. */
  20718. dispose(): void;
  20719. }
  20720. }
  20721. declare module BABYLON {
  20722. /**
  20723. * This Helps creating a texture that will be created from a camera in your scene.
  20724. * It is basically a dynamic texture that could be used to create special effects for instance.
  20725. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20726. */
  20727. export class RenderTargetTexture extends Texture {
  20728. isCube: boolean;
  20729. /**
  20730. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20731. */
  20732. static readonly REFRESHRATE_RENDER_ONCE: number;
  20733. /**
  20734. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20735. */
  20736. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20737. /**
  20738. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20739. * the central point of your effect and can save a lot of performances.
  20740. */
  20741. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20742. /**
  20743. * Use this predicate to dynamically define the list of mesh you want to render.
  20744. * If set, the renderList property will be overwritten.
  20745. */
  20746. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20747. private _renderList;
  20748. /**
  20749. * Use this list to define the list of mesh you want to render.
  20750. */
  20751. get renderList(): Nullable<Array<AbstractMesh>>;
  20752. set renderList(value: Nullable<Array<AbstractMesh>>);
  20753. /**
  20754. * Use this function to overload the renderList array at rendering time.
  20755. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20756. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20757. * the cube (if the RTT is a cube, else layerOrFace=0).
  20758. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20759. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20760. * hold dummy elements!
  20761. */
  20762. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20763. private _hookArray;
  20764. /**
  20765. * Define if particles should be rendered in your texture.
  20766. */
  20767. renderParticles: boolean;
  20768. /**
  20769. * Define if sprites should be rendered in your texture.
  20770. */
  20771. renderSprites: boolean;
  20772. /**
  20773. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20774. */
  20775. coordinatesMode: number;
  20776. /**
  20777. * Define the camera used to render the texture.
  20778. */
  20779. activeCamera: Nullable<Camera>;
  20780. /**
  20781. * Override the mesh isReady function with your own one.
  20782. */
  20783. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20784. /**
  20785. * Override the render function of the texture with your own one.
  20786. */
  20787. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20788. /**
  20789. * Define if camera post processes should be use while rendering the texture.
  20790. */
  20791. useCameraPostProcesses: boolean;
  20792. /**
  20793. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20794. */
  20795. ignoreCameraViewport: boolean;
  20796. private _postProcessManager;
  20797. private _postProcesses;
  20798. private _resizeObserver;
  20799. /**
  20800. * An event triggered when the texture is unbind.
  20801. */
  20802. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20803. /**
  20804. * An event triggered when the texture is unbind.
  20805. */
  20806. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20807. private _onAfterUnbindObserver;
  20808. /**
  20809. * Set a after unbind callback in the texture.
  20810. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20811. */
  20812. set onAfterUnbind(callback: () => void);
  20813. /**
  20814. * An event triggered before rendering the texture
  20815. */
  20816. onBeforeRenderObservable: Observable<number>;
  20817. private _onBeforeRenderObserver;
  20818. /**
  20819. * Set a before render callback in the texture.
  20820. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20821. */
  20822. set onBeforeRender(callback: (faceIndex: number) => void);
  20823. /**
  20824. * An event triggered after rendering the texture
  20825. */
  20826. onAfterRenderObservable: Observable<number>;
  20827. private _onAfterRenderObserver;
  20828. /**
  20829. * Set a after render callback in the texture.
  20830. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20831. */
  20832. set onAfterRender(callback: (faceIndex: number) => void);
  20833. /**
  20834. * An event triggered after the texture clear
  20835. */
  20836. onClearObservable: Observable<Engine>;
  20837. private _onClearObserver;
  20838. /**
  20839. * Set a clear callback in the texture.
  20840. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20841. */
  20842. set onClear(callback: (Engine: Engine) => void);
  20843. /**
  20844. * An event triggered when the texture is resized.
  20845. */
  20846. onResizeObservable: Observable<RenderTargetTexture>;
  20847. /**
  20848. * Define the clear color of the Render Target if it should be different from the scene.
  20849. */
  20850. clearColor: Color4;
  20851. protected _size: number | {
  20852. width: number;
  20853. height: number;
  20854. layers?: number;
  20855. };
  20856. protected _initialSizeParameter: number | {
  20857. width: number;
  20858. height: number;
  20859. } | {
  20860. ratio: number;
  20861. };
  20862. protected _sizeRatio: Nullable<number>;
  20863. /** @hidden */
  20864. _generateMipMaps: boolean;
  20865. protected _renderingManager: RenderingManager;
  20866. /** @hidden */
  20867. _waitingRenderList: string[];
  20868. protected _doNotChangeAspectRatio: boolean;
  20869. protected _currentRefreshId: number;
  20870. protected _refreshRate: number;
  20871. protected _textureMatrix: Matrix;
  20872. protected _samples: number;
  20873. protected _renderTargetOptions: RenderTargetCreationOptions;
  20874. /**
  20875. * Gets render target creation options that were used.
  20876. */
  20877. get renderTargetOptions(): RenderTargetCreationOptions;
  20878. protected _onRatioRescale(): void;
  20879. /**
  20880. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20881. * It must define where the camera used to render the texture is set
  20882. */
  20883. boundingBoxPosition: Vector3;
  20884. private _boundingBoxSize;
  20885. /**
  20886. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20887. * When defined, the cubemap will switch to local mode
  20888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20889. * @example https://www.babylonjs-playground.com/#RNASML
  20890. */
  20891. set boundingBoxSize(value: Vector3);
  20892. get boundingBoxSize(): Vector3;
  20893. /**
  20894. * In case the RTT has been created with a depth texture, get the associated
  20895. * depth texture.
  20896. * Otherwise, return null.
  20897. */
  20898. get depthStencilTexture(): Nullable<InternalTexture>;
  20899. /**
  20900. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20901. * or used a shadow, depth texture...
  20902. * @param name The friendly name of the texture
  20903. * @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)
  20904. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20905. * @param generateMipMaps True if mip maps need to be generated after render.
  20906. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20907. * @param type The type of the buffer in the RTT (int, half float, float...)
  20908. * @param isCube True if a cube texture needs to be created
  20909. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20910. * @param generateDepthBuffer True to generate a depth buffer
  20911. * @param generateStencilBuffer True to generate a stencil buffer
  20912. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20913. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20914. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20915. */
  20916. constructor(name: string, size: number | {
  20917. width: number;
  20918. height: number;
  20919. layers?: number;
  20920. } | {
  20921. ratio: number;
  20922. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20923. /**
  20924. * Creates a depth stencil texture.
  20925. * This is only available in WebGL 2 or with the depth texture extension available.
  20926. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20927. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20928. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20929. */
  20930. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20931. private _processSizeParameter;
  20932. /**
  20933. * Define the number of samples to use in case of MSAA.
  20934. * It defaults to one meaning no MSAA has been enabled.
  20935. */
  20936. get samples(): number;
  20937. set samples(value: number);
  20938. /**
  20939. * Resets the refresh counter of the texture and start bak from scratch.
  20940. * Could be useful to regenerate the texture if it is setup to render only once.
  20941. */
  20942. resetRefreshCounter(): void;
  20943. /**
  20944. * Define the refresh rate of the texture or the rendering frequency.
  20945. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20946. */
  20947. get refreshRate(): number;
  20948. set refreshRate(value: number);
  20949. /**
  20950. * Adds a post process to the render target rendering passes.
  20951. * @param postProcess define the post process to add
  20952. */
  20953. addPostProcess(postProcess: PostProcess): void;
  20954. /**
  20955. * Clear all the post processes attached to the render target
  20956. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20957. */
  20958. clearPostProcesses(dispose?: boolean): void;
  20959. /**
  20960. * Remove one of the post process from the list of attached post processes to the texture
  20961. * @param postProcess define the post process to remove from the list
  20962. */
  20963. removePostProcess(postProcess: PostProcess): void;
  20964. /** @hidden */
  20965. _shouldRender(): boolean;
  20966. /**
  20967. * Gets the actual render size of the texture.
  20968. * @returns the width of the render size
  20969. */
  20970. getRenderSize(): number;
  20971. /**
  20972. * Gets the actual render width of the texture.
  20973. * @returns the width of the render size
  20974. */
  20975. getRenderWidth(): number;
  20976. /**
  20977. * Gets the actual render height of the texture.
  20978. * @returns the height of the render size
  20979. */
  20980. getRenderHeight(): number;
  20981. /**
  20982. * Gets the actual number of layers of the texture.
  20983. * @returns the number of layers
  20984. */
  20985. getRenderLayers(): number;
  20986. /**
  20987. * Get if the texture can be rescaled or not.
  20988. */
  20989. get canRescale(): boolean;
  20990. /**
  20991. * Resize the texture using a ratio.
  20992. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20993. */
  20994. scale(ratio: number): void;
  20995. /**
  20996. * Get the texture reflection matrix used to rotate/transform the reflection.
  20997. * @returns the reflection matrix
  20998. */
  20999. getReflectionTextureMatrix(): Matrix;
  21000. /**
  21001. * Resize the texture to a new desired size.
  21002. * Be carrefull as it will recreate all the data in the new texture.
  21003. * @param size Define the new size. It can be:
  21004. * - a number for squared texture,
  21005. * - an object containing { width: number, height: number }
  21006. * - or an object containing a ratio { ratio: number }
  21007. */
  21008. resize(size: number | {
  21009. width: number;
  21010. height: number;
  21011. } | {
  21012. ratio: number;
  21013. }): void;
  21014. private _defaultRenderListPrepared;
  21015. /**
  21016. * Renders all the objects from the render list into the texture.
  21017. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21018. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21019. */
  21020. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21021. private _bestReflectionRenderTargetDimension;
  21022. private _prepareRenderingManager;
  21023. /**
  21024. * @hidden
  21025. * @param faceIndex face index to bind to if this is a cubetexture
  21026. * @param layer defines the index of the texture to bind in the array
  21027. */
  21028. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21029. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21030. private renderToTarget;
  21031. /**
  21032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21033. * This allowed control for front to back rendering or reversly depending of the special needs.
  21034. *
  21035. * @param renderingGroupId The rendering group id corresponding to its index
  21036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21039. */
  21040. 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;
  21041. /**
  21042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21043. *
  21044. * @param renderingGroupId The rendering group id corresponding to its index
  21045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21046. */
  21047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21048. /**
  21049. * Clones the texture.
  21050. * @returns the cloned texture
  21051. */
  21052. clone(): RenderTargetTexture;
  21053. /**
  21054. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21055. * @returns The JSON representation of the texture
  21056. */
  21057. serialize(): any;
  21058. /**
  21059. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21060. */
  21061. disposeFramebufferObjects(): void;
  21062. /**
  21063. * Dispose the texture and release its associated resources.
  21064. */
  21065. dispose(): void;
  21066. /** @hidden */
  21067. _rebuild(): void;
  21068. /**
  21069. * Clear the info related to rendering groups preventing retention point in material dispose.
  21070. */
  21071. freeRenderingGroups(): void;
  21072. /**
  21073. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21074. * @returns the view count
  21075. */
  21076. getViewCount(): number;
  21077. }
  21078. }
  21079. declare module BABYLON {
  21080. /**
  21081. * Class used to manipulate GUIDs
  21082. */
  21083. export class GUID {
  21084. /**
  21085. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21086. * Be aware Math.random() could cause collisions, but:
  21087. * "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"
  21088. * @returns a pseudo random id
  21089. */
  21090. static RandomId(): string;
  21091. }
  21092. }
  21093. declare module BABYLON {
  21094. /**
  21095. * Options to be used when creating a shadow depth material
  21096. */
  21097. export interface IIOptionShadowDepthMaterial {
  21098. /** Variables in the vertex shader code that need to have their names remapped.
  21099. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21100. * "var_name" should be either: worldPos or vNormalW
  21101. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21102. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21103. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21104. */
  21105. remappedVariables?: string[];
  21106. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21107. standalone?: boolean;
  21108. }
  21109. /**
  21110. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21111. */
  21112. export class ShadowDepthWrapper {
  21113. private _scene;
  21114. private _options?;
  21115. private _baseMaterial;
  21116. private _onEffectCreatedObserver;
  21117. private _subMeshToEffect;
  21118. private _subMeshToDepthEffect;
  21119. private _meshes;
  21120. /** @hidden */
  21121. _matriceNames: any;
  21122. /** Gets the standalone status of the wrapper */
  21123. get standalone(): boolean;
  21124. /** Gets the base material the wrapper is built upon */
  21125. get baseMaterial(): Material;
  21126. /**
  21127. * Instantiate a new shadow depth wrapper.
  21128. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21129. * generate the shadow depth map. For more information, please refer to the documentation:
  21130. * https://doc.babylonjs.com/babylon101/shadows
  21131. * @param baseMaterial Material to wrap
  21132. * @param scene Define the scene the material belongs to
  21133. * @param options Options used to create the wrapper
  21134. */
  21135. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21136. /**
  21137. * Gets the effect to use to generate the depth map
  21138. * @param subMesh subMesh to get the effect for
  21139. * @param shadowGenerator shadow generator to get the effect for
  21140. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21141. */
  21142. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21143. /**
  21144. * Specifies that the submesh is ready to be used for depth rendering
  21145. * @param subMesh submesh to check
  21146. * @param defines the list of defines to take into account when checking the effect
  21147. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21148. * @param useInstances specifies that instances should be used
  21149. * @returns a boolean indicating that the submesh is ready or not
  21150. */
  21151. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21152. /**
  21153. * Disposes the resources
  21154. */
  21155. dispose(): void;
  21156. private _makeEffect;
  21157. }
  21158. }
  21159. declare module BABYLON {
  21160. /**
  21161. * Options for compiling materials.
  21162. */
  21163. export interface IMaterialCompilationOptions {
  21164. /**
  21165. * Defines whether clip planes are enabled.
  21166. */
  21167. clipPlane: boolean;
  21168. /**
  21169. * Defines whether instances are enabled.
  21170. */
  21171. useInstances: boolean;
  21172. }
  21173. /**
  21174. * Base class for the main features of a material in Babylon.js
  21175. */
  21176. export class Material implements IAnimatable {
  21177. /**
  21178. * Returns the triangle fill mode
  21179. */
  21180. static readonly TriangleFillMode: number;
  21181. /**
  21182. * Returns the wireframe mode
  21183. */
  21184. static readonly WireFrameFillMode: number;
  21185. /**
  21186. * Returns the point fill mode
  21187. */
  21188. static readonly PointFillMode: number;
  21189. /**
  21190. * Returns the point list draw mode
  21191. */
  21192. static readonly PointListDrawMode: number;
  21193. /**
  21194. * Returns the line list draw mode
  21195. */
  21196. static readonly LineListDrawMode: number;
  21197. /**
  21198. * Returns the line loop draw mode
  21199. */
  21200. static readonly LineLoopDrawMode: number;
  21201. /**
  21202. * Returns the line strip draw mode
  21203. */
  21204. static readonly LineStripDrawMode: number;
  21205. /**
  21206. * Returns the triangle strip draw mode
  21207. */
  21208. static readonly TriangleStripDrawMode: number;
  21209. /**
  21210. * Returns the triangle fan draw mode
  21211. */
  21212. static readonly TriangleFanDrawMode: number;
  21213. /**
  21214. * Stores the clock-wise side orientation
  21215. */
  21216. static readonly ClockWiseSideOrientation: number;
  21217. /**
  21218. * Stores the counter clock-wise side orientation
  21219. */
  21220. static readonly CounterClockWiseSideOrientation: number;
  21221. /**
  21222. * The dirty texture flag value
  21223. */
  21224. static readonly TextureDirtyFlag: number;
  21225. /**
  21226. * The dirty light flag value
  21227. */
  21228. static readonly LightDirtyFlag: number;
  21229. /**
  21230. * The dirty fresnel flag value
  21231. */
  21232. static readonly FresnelDirtyFlag: number;
  21233. /**
  21234. * The dirty attribute flag value
  21235. */
  21236. static readonly AttributesDirtyFlag: number;
  21237. /**
  21238. * The dirty misc flag value
  21239. */
  21240. static readonly MiscDirtyFlag: number;
  21241. /**
  21242. * The all dirty flag value
  21243. */
  21244. static readonly AllDirtyFlag: number;
  21245. /**
  21246. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21247. */
  21248. static readonly MATERIAL_OPAQUE: number;
  21249. /**
  21250. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21251. */
  21252. static readonly MATERIAL_ALPHATEST: number;
  21253. /**
  21254. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21255. */
  21256. static readonly MATERIAL_ALPHABLEND: number;
  21257. /**
  21258. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21259. * They are also discarded below the alpha cutoff threshold to improve performances.
  21260. */
  21261. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21262. /**
  21263. * Custom callback helping to override the default shader used in the material.
  21264. */
  21265. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21266. /**
  21267. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21268. */
  21269. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21270. /**
  21271. * The ID of the material
  21272. */
  21273. id: string;
  21274. /**
  21275. * Gets or sets the unique id of the material
  21276. */
  21277. uniqueId: number;
  21278. /**
  21279. * The name of the material
  21280. */
  21281. name: string;
  21282. /**
  21283. * Gets or sets user defined metadata
  21284. */
  21285. metadata: any;
  21286. /**
  21287. * For internal use only. Please do not use.
  21288. */
  21289. reservedDataStore: any;
  21290. /**
  21291. * Specifies if the ready state should be checked on each call
  21292. */
  21293. checkReadyOnEveryCall: boolean;
  21294. /**
  21295. * Specifies if the ready state should be checked once
  21296. */
  21297. checkReadyOnlyOnce: boolean;
  21298. /**
  21299. * The state of the material
  21300. */
  21301. state: string;
  21302. /**
  21303. * The alpha value of the material
  21304. */
  21305. protected _alpha: number;
  21306. /**
  21307. * List of inspectable custom properties (used by the Inspector)
  21308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21309. */
  21310. inspectableCustomProperties: IInspectable[];
  21311. /**
  21312. * Sets the alpha value of the material
  21313. */
  21314. set alpha(value: number);
  21315. /**
  21316. * Gets the alpha value of the material
  21317. */
  21318. get alpha(): number;
  21319. /**
  21320. * Specifies if back face culling is enabled
  21321. */
  21322. protected _backFaceCulling: boolean;
  21323. /**
  21324. * Sets the back-face culling state
  21325. */
  21326. set backFaceCulling(value: boolean);
  21327. /**
  21328. * Gets the back-face culling state
  21329. */
  21330. get backFaceCulling(): boolean;
  21331. /**
  21332. * Stores the value for side orientation
  21333. */
  21334. sideOrientation: number;
  21335. /**
  21336. * Callback triggered when the material is compiled
  21337. */
  21338. onCompiled: Nullable<(effect: Effect) => void>;
  21339. /**
  21340. * Callback triggered when an error occurs
  21341. */
  21342. onError: Nullable<(effect: Effect, errors: string) => void>;
  21343. /**
  21344. * Callback triggered to get the render target textures
  21345. */
  21346. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21347. /**
  21348. * Gets a boolean indicating that current material needs to register RTT
  21349. */
  21350. get hasRenderTargetTextures(): boolean;
  21351. /**
  21352. * Specifies if the material should be serialized
  21353. */
  21354. doNotSerialize: boolean;
  21355. /**
  21356. * @hidden
  21357. */
  21358. _storeEffectOnSubMeshes: boolean;
  21359. /**
  21360. * Stores the animations for the material
  21361. */
  21362. animations: Nullable<Array<Animation>>;
  21363. /**
  21364. * An event triggered when the material is disposed
  21365. */
  21366. onDisposeObservable: Observable<Material>;
  21367. /**
  21368. * An observer which watches for dispose events
  21369. */
  21370. private _onDisposeObserver;
  21371. private _onUnBindObservable;
  21372. /**
  21373. * Called during a dispose event
  21374. */
  21375. set onDispose(callback: () => void);
  21376. private _onBindObservable;
  21377. /**
  21378. * An event triggered when the material is bound
  21379. */
  21380. get onBindObservable(): Observable<AbstractMesh>;
  21381. /**
  21382. * An observer which watches for bind events
  21383. */
  21384. private _onBindObserver;
  21385. /**
  21386. * Called during a bind event
  21387. */
  21388. set onBind(callback: (Mesh: AbstractMesh) => void);
  21389. /**
  21390. * An event triggered when the material is unbound
  21391. */
  21392. get onUnBindObservable(): Observable<Material>;
  21393. protected _onEffectCreatedObservable: Nullable<Observable<{
  21394. effect: Effect;
  21395. subMesh: Nullable<SubMesh>;
  21396. }>>;
  21397. /**
  21398. * An event triggered when the effect is (re)created
  21399. */
  21400. get onEffectCreatedObservable(): Observable<{
  21401. effect: Effect;
  21402. subMesh: Nullable<SubMesh>;
  21403. }>;
  21404. /**
  21405. * Stores the value of the alpha mode
  21406. */
  21407. private _alphaMode;
  21408. /**
  21409. * Sets the value of the alpha mode.
  21410. *
  21411. * | Value | Type | Description |
  21412. * | --- | --- | --- |
  21413. * | 0 | ALPHA_DISABLE | |
  21414. * | 1 | ALPHA_ADD | |
  21415. * | 2 | ALPHA_COMBINE | |
  21416. * | 3 | ALPHA_SUBTRACT | |
  21417. * | 4 | ALPHA_MULTIPLY | |
  21418. * | 5 | ALPHA_MAXIMIZED | |
  21419. * | 6 | ALPHA_ONEONE | |
  21420. * | 7 | ALPHA_PREMULTIPLIED | |
  21421. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21422. * | 9 | ALPHA_INTERPOLATE | |
  21423. * | 10 | ALPHA_SCREENMODE | |
  21424. *
  21425. */
  21426. set alphaMode(value: number);
  21427. /**
  21428. * Gets the value of the alpha mode
  21429. */
  21430. get alphaMode(): number;
  21431. /**
  21432. * Stores the state of the need depth pre-pass value
  21433. */
  21434. private _needDepthPrePass;
  21435. /**
  21436. * Sets the need depth pre-pass value
  21437. */
  21438. set needDepthPrePass(value: boolean);
  21439. /**
  21440. * Gets the depth pre-pass value
  21441. */
  21442. get needDepthPrePass(): boolean;
  21443. /**
  21444. * Specifies if depth writing should be disabled
  21445. */
  21446. disableDepthWrite: boolean;
  21447. /**
  21448. * Specifies if color writing should be disabled
  21449. */
  21450. disableColorWrite: boolean;
  21451. /**
  21452. * Specifies if depth writing should be forced
  21453. */
  21454. forceDepthWrite: boolean;
  21455. /**
  21456. * Specifies the depth function that should be used. 0 means the default engine function
  21457. */
  21458. depthFunction: number;
  21459. /**
  21460. * Specifies if there should be a separate pass for culling
  21461. */
  21462. separateCullingPass: boolean;
  21463. /**
  21464. * Stores the state specifing if fog should be enabled
  21465. */
  21466. private _fogEnabled;
  21467. /**
  21468. * Sets the state for enabling fog
  21469. */
  21470. set fogEnabled(value: boolean);
  21471. /**
  21472. * Gets the value of the fog enabled state
  21473. */
  21474. get fogEnabled(): boolean;
  21475. /**
  21476. * Stores the size of points
  21477. */
  21478. pointSize: number;
  21479. /**
  21480. * Stores the z offset value
  21481. */
  21482. zOffset: number;
  21483. get wireframe(): boolean;
  21484. /**
  21485. * Sets the state of wireframe mode
  21486. */
  21487. set wireframe(value: boolean);
  21488. /**
  21489. * Gets the value specifying if point clouds are enabled
  21490. */
  21491. get pointsCloud(): boolean;
  21492. /**
  21493. * Sets the state of point cloud mode
  21494. */
  21495. set pointsCloud(value: boolean);
  21496. /**
  21497. * Gets the material fill mode
  21498. */
  21499. get fillMode(): number;
  21500. /**
  21501. * Sets the material fill mode
  21502. */
  21503. set fillMode(value: number);
  21504. /**
  21505. * @hidden
  21506. * Stores the effects for the material
  21507. */
  21508. _effect: Nullable<Effect>;
  21509. /**
  21510. * Specifies if uniform buffers should be used
  21511. */
  21512. private _useUBO;
  21513. /**
  21514. * Stores a reference to the scene
  21515. */
  21516. private _scene;
  21517. /**
  21518. * Stores the fill mode state
  21519. */
  21520. private _fillMode;
  21521. /**
  21522. * Specifies if the depth write state should be cached
  21523. */
  21524. private _cachedDepthWriteState;
  21525. /**
  21526. * Specifies if the color write state should be cached
  21527. */
  21528. private _cachedColorWriteState;
  21529. /**
  21530. * Specifies if the depth function state should be cached
  21531. */
  21532. private _cachedDepthFunctionState;
  21533. /**
  21534. * Stores the uniform buffer
  21535. */
  21536. protected _uniformBuffer: UniformBuffer;
  21537. /** @hidden */
  21538. _indexInSceneMaterialArray: number;
  21539. /** @hidden */
  21540. meshMap: Nullable<{
  21541. [id: string]: AbstractMesh | undefined;
  21542. }>;
  21543. /**
  21544. * Creates a material instance
  21545. * @param name defines the name of the material
  21546. * @param scene defines the scene to reference
  21547. * @param doNotAdd specifies if the material should be added to the scene
  21548. */
  21549. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21550. /**
  21551. * Returns a string representation of the current material
  21552. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21553. * @returns a string with material information
  21554. */
  21555. toString(fullDetails?: boolean): string;
  21556. /**
  21557. * Gets the class name of the material
  21558. * @returns a string with the class name of the material
  21559. */
  21560. getClassName(): string;
  21561. /**
  21562. * Specifies if updates for the material been locked
  21563. */
  21564. get isFrozen(): boolean;
  21565. /**
  21566. * Locks updates for the material
  21567. */
  21568. freeze(): void;
  21569. /**
  21570. * Unlocks updates for the material
  21571. */
  21572. unfreeze(): void;
  21573. /**
  21574. * Specifies if the material is ready to be used
  21575. * @param mesh defines the mesh to check
  21576. * @param useInstances specifies if instances should be used
  21577. * @returns a boolean indicating if the material is ready to be used
  21578. */
  21579. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21580. /**
  21581. * Specifies that the submesh is ready to be used
  21582. * @param mesh defines the mesh to check
  21583. * @param subMesh defines which submesh to check
  21584. * @param useInstances specifies that instances should be used
  21585. * @returns a boolean indicating that the submesh is ready or not
  21586. */
  21587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21588. /**
  21589. * Returns the material effect
  21590. * @returns the effect associated with the material
  21591. */
  21592. getEffect(): Nullable<Effect>;
  21593. /**
  21594. * Returns the current scene
  21595. * @returns a Scene
  21596. */
  21597. getScene(): Scene;
  21598. /**
  21599. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21600. */
  21601. protected _forceAlphaTest: boolean;
  21602. /**
  21603. * The transparency mode of the material.
  21604. */
  21605. protected _transparencyMode: Nullable<number>;
  21606. /**
  21607. * Gets the current transparency mode.
  21608. */
  21609. get transparencyMode(): Nullable<number>;
  21610. /**
  21611. * Sets the transparency mode of the material.
  21612. *
  21613. * | Value | Type | Description |
  21614. * | ----- | ----------------------------------- | ----------- |
  21615. * | 0 | OPAQUE | |
  21616. * | 1 | ALPHATEST | |
  21617. * | 2 | ALPHABLEND | |
  21618. * | 3 | ALPHATESTANDBLEND | |
  21619. *
  21620. */
  21621. set transparencyMode(value: Nullable<number>);
  21622. /**
  21623. * Returns true if alpha blending should be disabled.
  21624. */
  21625. protected get _disableAlphaBlending(): boolean;
  21626. /**
  21627. * Specifies whether or not this material should be rendered in alpha blend mode.
  21628. * @returns a boolean specifying if alpha blending is needed
  21629. */
  21630. needAlphaBlending(): boolean;
  21631. /**
  21632. * Specifies if the mesh will require alpha blending
  21633. * @param mesh defines the mesh to check
  21634. * @returns a boolean specifying if alpha blending is needed for the mesh
  21635. */
  21636. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21637. /**
  21638. * Specifies whether or not this material should be rendered in alpha test mode.
  21639. * @returns a boolean specifying if an alpha test is needed.
  21640. */
  21641. needAlphaTesting(): boolean;
  21642. /**
  21643. * Specifies if material alpha testing should be turned on for the mesh
  21644. * @param mesh defines the mesh to check
  21645. */
  21646. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21647. /**
  21648. * Gets the texture used for the alpha test
  21649. * @returns the texture to use for alpha testing
  21650. */
  21651. getAlphaTestTexture(): Nullable<BaseTexture>;
  21652. /**
  21653. * Marks the material to indicate that it needs to be re-calculated
  21654. */
  21655. markDirty(): void;
  21656. /** @hidden */
  21657. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21658. /**
  21659. * Binds the material to the mesh
  21660. * @param world defines the world transformation matrix
  21661. * @param mesh defines the mesh to bind the material to
  21662. */
  21663. bind(world: Matrix, mesh?: Mesh): void;
  21664. /**
  21665. * Binds the submesh to the material
  21666. * @param world defines the world transformation matrix
  21667. * @param mesh defines the mesh containing the submesh
  21668. * @param subMesh defines the submesh to bind the material to
  21669. */
  21670. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21671. /**
  21672. * Binds the world matrix to the material
  21673. * @param world defines the world transformation matrix
  21674. */
  21675. bindOnlyWorldMatrix(world: Matrix): void;
  21676. /**
  21677. * Binds the scene's uniform buffer to the effect.
  21678. * @param effect defines the effect to bind to the scene uniform buffer
  21679. * @param sceneUbo defines the uniform buffer storing scene data
  21680. */
  21681. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21682. /**
  21683. * Binds the view matrix to the effect
  21684. * @param effect defines the effect to bind the view matrix to
  21685. */
  21686. bindView(effect: Effect): void;
  21687. /**
  21688. * Binds the view projection matrix to the effect
  21689. * @param effect defines the effect to bind the view projection matrix to
  21690. */
  21691. bindViewProjection(effect: Effect): void;
  21692. /**
  21693. * Processes to execute after binding the material to a mesh
  21694. * @param mesh defines the rendered mesh
  21695. */
  21696. protected _afterBind(mesh?: Mesh): void;
  21697. /**
  21698. * Unbinds the material from the mesh
  21699. */
  21700. unbind(): void;
  21701. /**
  21702. * Gets the active textures from the material
  21703. * @returns an array of textures
  21704. */
  21705. getActiveTextures(): BaseTexture[];
  21706. /**
  21707. * Specifies if the material uses a texture
  21708. * @param texture defines the texture to check against the material
  21709. * @returns a boolean specifying if the material uses the texture
  21710. */
  21711. hasTexture(texture: BaseTexture): boolean;
  21712. /**
  21713. * Makes a duplicate of the material, and gives it a new name
  21714. * @param name defines the new name for the duplicated material
  21715. * @returns the cloned material
  21716. */
  21717. clone(name: string): Nullable<Material>;
  21718. /**
  21719. * Gets the meshes bound to the material
  21720. * @returns an array of meshes bound to the material
  21721. */
  21722. getBindedMeshes(): AbstractMesh[];
  21723. /**
  21724. * Force shader compilation
  21725. * @param mesh defines the mesh associated with this material
  21726. * @param onCompiled defines a function to execute once the material is compiled
  21727. * @param options defines the options to configure the compilation
  21728. * @param onError defines a function to execute if the material fails compiling
  21729. */
  21730. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21731. /**
  21732. * Force shader compilation
  21733. * @param mesh defines the mesh that will use this material
  21734. * @param options defines additional options for compiling the shaders
  21735. * @returns a promise that resolves when the compilation completes
  21736. */
  21737. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21738. private static readonly _AllDirtyCallBack;
  21739. private static readonly _ImageProcessingDirtyCallBack;
  21740. private static readonly _TextureDirtyCallBack;
  21741. private static readonly _FresnelDirtyCallBack;
  21742. private static readonly _MiscDirtyCallBack;
  21743. private static readonly _LightsDirtyCallBack;
  21744. private static readonly _AttributeDirtyCallBack;
  21745. private static _FresnelAndMiscDirtyCallBack;
  21746. private static _TextureAndMiscDirtyCallBack;
  21747. private static readonly _DirtyCallbackArray;
  21748. private static readonly _RunDirtyCallBacks;
  21749. /**
  21750. * Marks a define in the material to indicate that it needs to be re-computed
  21751. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21752. */
  21753. markAsDirty(flag: number): void;
  21754. /**
  21755. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21756. * @param func defines a function which checks material defines against the submeshes
  21757. */
  21758. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21759. /**
  21760. * Indicates that we need to re-calculated for all submeshes
  21761. */
  21762. protected _markAllSubMeshesAsAllDirty(): void;
  21763. /**
  21764. * Indicates that image processing needs to be re-calculated for all submeshes
  21765. */
  21766. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21767. /**
  21768. * Indicates that textures need to be re-calculated for all submeshes
  21769. */
  21770. protected _markAllSubMeshesAsTexturesDirty(): void;
  21771. /**
  21772. * Indicates that fresnel needs to be re-calculated for all submeshes
  21773. */
  21774. protected _markAllSubMeshesAsFresnelDirty(): void;
  21775. /**
  21776. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21777. */
  21778. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21779. /**
  21780. * Indicates that lights need to be re-calculated for all submeshes
  21781. */
  21782. protected _markAllSubMeshesAsLightsDirty(): void;
  21783. /**
  21784. * Indicates that attributes need to be re-calculated for all submeshes
  21785. */
  21786. protected _markAllSubMeshesAsAttributesDirty(): void;
  21787. /**
  21788. * Indicates that misc needs to be re-calculated for all submeshes
  21789. */
  21790. protected _markAllSubMeshesAsMiscDirty(): void;
  21791. /**
  21792. * Indicates that textures and misc need to be re-calculated for all submeshes
  21793. */
  21794. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21795. /**
  21796. * Disposes the material
  21797. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21798. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21799. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21800. */
  21801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21802. /** @hidden */
  21803. private releaseVertexArrayObject;
  21804. /**
  21805. * Serializes this material
  21806. * @returns the serialized material object
  21807. */
  21808. serialize(): any;
  21809. /**
  21810. * Creates a material from parsed material data
  21811. * @param parsedMaterial defines parsed material data
  21812. * @param scene defines the hosting scene
  21813. * @param rootUrl defines the root URL to use to load textures
  21814. * @returns a new material
  21815. */
  21816. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21817. }
  21818. }
  21819. declare module BABYLON {
  21820. /**
  21821. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21822. * separate meshes. This can be use to improve performances.
  21823. * @see http://doc.babylonjs.com/how_to/multi_materials
  21824. */
  21825. export class MultiMaterial extends Material {
  21826. private _subMaterials;
  21827. /**
  21828. * Gets or Sets the list of Materials used within the multi material.
  21829. * They need to be ordered according to the submeshes order in the associated mesh
  21830. */
  21831. get subMaterials(): Nullable<Material>[];
  21832. set subMaterials(value: Nullable<Material>[]);
  21833. /**
  21834. * Function used to align with Node.getChildren()
  21835. * @returns the list of Materials used within the multi material
  21836. */
  21837. getChildren(): Nullable<Material>[];
  21838. /**
  21839. * Instantiates a new Multi Material
  21840. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21841. * separate meshes. This can be use to improve performances.
  21842. * @see http://doc.babylonjs.com/how_to/multi_materials
  21843. * @param name Define the name in the scene
  21844. * @param scene Define the scene the material belongs to
  21845. */
  21846. constructor(name: string, scene: Scene);
  21847. private _hookArray;
  21848. /**
  21849. * Get one of the submaterial by its index in the submaterials array
  21850. * @param index The index to look the sub material at
  21851. * @returns The Material if the index has been defined
  21852. */
  21853. getSubMaterial(index: number): Nullable<Material>;
  21854. /**
  21855. * Get the list of active textures for the whole sub materials list.
  21856. * @returns All the textures that will be used during the rendering
  21857. */
  21858. getActiveTextures(): BaseTexture[];
  21859. /**
  21860. * Gets the current class name of the material e.g. "MultiMaterial"
  21861. * Mainly use in serialization.
  21862. * @returns the class name
  21863. */
  21864. getClassName(): string;
  21865. /**
  21866. * Checks if the material is ready to render the requested sub mesh
  21867. * @param mesh Define the mesh the submesh belongs to
  21868. * @param subMesh Define the sub mesh to look readyness for
  21869. * @param useInstances Define whether or not the material is used with instances
  21870. * @returns true if ready, otherwise false
  21871. */
  21872. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21873. /**
  21874. * Clones the current material and its related sub materials
  21875. * @param name Define the name of the newly cloned material
  21876. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21877. * @returns the cloned material
  21878. */
  21879. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21880. /**
  21881. * Serializes the materials into a JSON representation.
  21882. * @returns the JSON representation
  21883. */
  21884. serialize(): any;
  21885. /**
  21886. * Dispose the material and release its associated resources
  21887. * @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)
  21888. * @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)
  21889. * @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)
  21890. */
  21891. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21892. /**
  21893. * Creates a MultiMaterial from parsed MultiMaterial data.
  21894. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21895. * @param scene defines the hosting scene
  21896. * @returns a new MultiMaterial
  21897. */
  21898. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21899. }
  21900. }
  21901. declare module BABYLON {
  21902. /**
  21903. * Base class for submeshes
  21904. */
  21905. export class BaseSubMesh {
  21906. /** @hidden */
  21907. _materialDefines: Nullable<MaterialDefines>;
  21908. /** @hidden */
  21909. _materialEffect: Nullable<Effect>;
  21910. /** @hidden */
  21911. _effectOverride: Nullable<Effect>;
  21912. /**
  21913. * Gets material defines used by the effect associated to the sub mesh
  21914. */
  21915. get materialDefines(): Nullable<MaterialDefines>;
  21916. /**
  21917. * Sets material defines used by the effect associated to the sub mesh
  21918. */
  21919. set materialDefines(defines: Nullable<MaterialDefines>);
  21920. /**
  21921. * Gets associated effect
  21922. */
  21923. get effect(): Nullable<Effect>;
  21924. /**
  21925. * Sets associated effect (effect used to render this submesh)
  21926. * @param effect defines the effect to associate with
  21927. * @param defines defines the set of defines used to compile this effect
  21928. */
  21929. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21930. }
  21931. /**
  21932. * Defines a subdivision inside a mesh
  21933. */
  21934. export class SubMesh extends BaseSubMesh implements ICullable {
  21935. /** the material index to use */
  21936. materialIndex: number;
  21937. /** vertex index start */
  21938. verticesStart: number;
  21939. /** vertices count */
  21940. verticesCount: number;
  21941. /** index start */
  21942. indexStart: number;
  21943. /** indices count */
  21944. indexCount: number;
  21945. /** @hidden */
  21946. _linesIndexCount: number;
  21947. private _mesh;
  21948. private _renderingMesh;
  21949. private _boundingInfo;
  21950. private _linesIndexBuffer;
  21951. /** @hidden */
  21952. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21953. /** @hidden */
  21954. _trianglePlanes: Plane[];
  21955. /** @hidden */
  21956. _lastColliderTransformMatrix: Nullable<Matrix>;
  21957. /** @hidden */
  21958. _renderId: number;
  21959. /** @hidden */
  21960. _alphaIndex: number;
  21961. /** @hidden */
  21962. _distanceToCamera: number;
  21963. /** @hidden */
  21964. _id: number;
  21965. private _currentMaterial;
  21966. /**
  21967. * Add a new submesh to a mesh
  21968. * @param materialIndex defines the material index to use
  21969. * @param verticesStart defines vertex index start
  21970. * @param verticesCount defines vertices count
  21971. * @param indexStart defines index start
  21972. * @param indexCount defines indices count
  21973. * @param mesh defines the parent mesh
  21974. * @param renderingMesh defines an optional rendering mesh
  21975. * @param createBoundingBox defines if bounding box should be created for this submesh
  21976. * @returns the new submesh
  21977. */
  21978. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21979. /**
  21980. * Creates a new submesh
  21981. * @param materialIndex defines the material index to use
  21982. * @param verticesStart defines vertex index start
  21983. * @param verticesCount defines vertices count
  21984. * @param indexStart defines index start
  21985. * @param indexCount defines indices count
  21986. * @param mesh defines the parent mesh
  21987. * @param renderingMesh defines an optional rendering mesh
  21988. * @param createBoundingBox defines if bounding box should be created for this submesh
  21989. */
  21990. constructor(
  21991. /** the material index to use */
  21992. materialIndex: number,
  21993. /** vertex index start */
  21994. verticesStart: number,
  21995. /** vertices count */
  21996. verticesCount: number,
  21997. /** index start */
  21998. indexStart: number,
  21999. /** indices count */
  22000. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22001. /**
  22002. * Returns true if this submesh covers the entire parent mesh
  22003. * @ignorenaming
  22004. */
  22005. get IsGlobal(): boolean;
  22006. /**
  22007. * Returns the submesh BoudingInfo object
  22008. * @returns current bounding info (or mesh's one if the submesh is global)
  22009. */
  22010. getBoundingInfo(): BoundingInfo;
  22011. /**
  22012. * Sets the submesh BoundingInfo
  22013. * @param boundingInfo defines the new bounding info to use
  22014. * @returns the SubMesh
  22015. */
  22016. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22017. /**
  22018. * Returns the mesh of the current submesh
  22019. * @return the parent mesh
  22020. */
  22021. getMesh(): AbstractMesh;
  22022. /**
  22023. * Returns the rendering mesh of the submesh
  22024. * @returns the rendering mesh (could be different from parent mesh)
  22025. */
  22026. getRenderingMesh(): Mesh;
  22027. /**
  22028. * Returns the submesh material
  22029. * @returns null or the current material
  22030. */
  22031. getMaterial(): Nullable<Material>;
  22032. /**
  22033. * Sets a new updated BoundingInfo object to the submesh
  22034. * @param data defines an optional position array to use to determine the bounding info
  22035. * @returns the SubMesh
  22036. */
  22037. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22038. /** @hidden */
  22039. _checkCollision(collider: Collider): boolean;
  22040. /**
  22041. * Updates the submesh BoundingInfo
  22042. * @param world defines the world matrix to use to update the bounding info
  22043. * @returns the submesh
  22044. */
  22045. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22046. /**
  22047. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22048. * @param frustumPlanes defines the frustum planes
  22049. * @returns true if the submesh is intersecting with the frustum
  22050. */
  22051. isInFrustum(frustumPlanes: Plane[]): boolean;
  22052. /**
  22053. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22054. * @param frustumPlanes defines the frustum planes
  22055. * @returns true if the submesh is inside the frustum
  22056. */
  22057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22058. /**
  22059. * Renders the submesh
  22060. * @param enableAlphaMode defines if alpha needs to be used
  22061. * @returns the submesh
  22062. */
  22063. render(enableAlphaMode: boolean): SubMesh;
  22064. /**
  22065. * @hidden
  22066. */
  22067. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22068. /**
  22069. * Checks if the submesh intersects with a ray
  22070. * @param ray defines the ray to test
  22071. * @returns true is the passed ray intersects the submesh bounding box
  22072. */
  22073. canIntersects(ray: Ray): boolean;
  22074. /**
  22075. * Intersects current submesh with a ray
  22076. * @param ray defines the ray to test
  22077. * @param positions defines mesh's positions array
  22078. * @param indices defines mesh's indices array
  22079. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22081. * @returns intersection info or null if no intersection
  22082. */
  22083. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22084. /** @hidden */
  22085. private _intersectLines;
  22086. /** @hidden */
  22087. private _intersectUnIndexedLines;
  22088. /** @hidden */
  22089. private _intersectTriangles;
  22090. /** @hidden */
  22091. private _intersectUnIndexedTriangles;
  22092. /** @hidden */
  22093. _rebuild(): void;
  22094. /**
  22095. * Creates a new submesh from the passed mesh
  22096. * @param newMesh defines the new hosting mesh
  22097. * @param newRenderingMesh defines an optional rendering mesh
  22098. * @returns the new submesh
  22099. */
  22100. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22101. /**
  22102. * Release associated resources
  22103. */
  22104. dispose(): void;
  22105. /**
  22106. * Gets the class name
  22107. * @returns the string "SubMesh".
  22108. */
  22109. getClassName(): string;
  22110. /**
  22111. * Creates a new submesh from indices data
  22112. * @param materialIndex the index of the main mesh material
  22113. * @param startIndex the index where to start the copy in the mesh indices array
  22114. * @param indexCount the number of indices to copy then from the startIndex
  22115. * @param mesh the main mesh to create the submesh from
  22116. * @param renderingMesh the optional rendering mesh
  22117. * @returns a new submesh
  22118. */
  22119. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22120. }
  22121. }
  22122. declare module BABYLON {
  22123. /**
  22124. * Class used to represent data loading progression
  22125. */
  22126. export class SceneLoaderFlags {
  22127. private static _ForceFullSceneLoadingForIncremental;
  22128. private static _ShowLoadingScreen;
  22129. private static _CleanBoneMatrixWeights;
  22130. private static _loggingLevel;
  22131. /**
  22132. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22133. */
  22134. static get ForceFullSceneLoadingForIncremental(): boolean;
  22135. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22136. /**
  22137. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22138. */
  22139. static get ShowLoadingScreen(): boolean;
  22140. static set ShowLoadingScreen(value: boolean);
  22141. /**
  22142. * Defines the current logging level (while loading the scene)
  22143. * @ignorenaming
  22144. */
  22145. static get loggingLevel(): number;
  22146. static set loggingLevel(value: number);
  22147. /**
  22148. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22149. */
  22150. static get CleanBoneMatrixWeights(): boolean;
  22151. static set CleanBoneMatrixWeights(value: boolean);
  22152. }
  22153. }
  22154. declare module BABYLON {
  22155. /**
  22156. * Class used to store geometry data (vertex buffers + index buffer)
  22157. */
  22158. export class Geometry implements IGetSetVerticesData {
  22159. /**
  22160. * Gets or sets the ID of the geometry
  22161. */
  22162. id: string;
  22163. /**
  22164. * Gets or sets the unique ID of the geometry
  22165. */
  22166. uniqueId: number;
  22167. /**
  22168. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22169. */
  22170. delayLoadState: number;
  22171. /**
  22172. * Gets the file containing the data to load when running in delay load state
  22173. */
  22174. delayLoadingFile: Nullable<string>;
  22175. /**
  22176. * Callback called when the geometry is updated
  22177. */
  22178. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22179. private _scene;
  22180. private _engine;
  22181. private _meshes;
  22182. private _totalVertices;
  22183. /** @hidden */
  22184. _indices: IndicesArray;
  22185. /** @hidden */
  22186. _vertexBuffers: {
  22187. [key: string]: VertexBuffer;
  22188. };
  22189. private _isDisposed;
  22190. private _extend;
  22191. private _boundingBias;
  22192. /** @hidden */
  22193. _delayInfo: Array<string>;
  22194. private _indexBuffer;
  22195. private _indexBufferIsUpdatable;
  22196. /** @hidden */
  22197. _boundingInfo: Nullable<BoundingInfo>;
  22198. /** @hidden */
  22199. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22200. /** @hidden */
  22201. _softwareSkinningFrameId: number;
  22202. private _vertexArrayObjects;
  22203. private _updatable;
  22204. /** @hidden */
  22205. _positions: Nullable<Vector3[]>;
  22206. /**
  22207. * 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
  22208. */
  22209. get boundingBias(): Vector2;
  22210. /**
  22211. * 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
  22212. */
  22213. set boundingBias(value: Vector2);
  22214. /**
  22215. * Static function used to attach a new empty geometry to a mesh
  22216. * @param mesh defines the mesh to attach the geometry to
  22217. * @returns the new Geometry
  22218. */
  22219. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22220. /** Get the list of meshes using this geometry */
  22221. get meshes(): Mesh[];
  22222. /**
  22223. * Creates a new geometry
  22224. * @param id defines the unique ID
  22225. * @param scene defines the hosting scene
  22226. * @param vertexData defines the VertexData used to get geometry data
  22227. * @param updatable defines if geometry must be updatable (false by default)
  22228. * @param mesh defines the mesh that will be associated with the geometry
  22229. */
  22230. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22231. /**
  22232. * Gets the current extend of the geometry
  22233. */
  22234. get extend(): {
  22235. minimum: Vector3;
  22236. maximum: Vector3;
  22237. };
  22238. /**
  22239. * Gets the hosting scene
  22240. * @returns the hosting Scene
  22241. */
  22242. getScene(): Scene;
  22243. /**
  22244. * Gets the hosting engine
  22245. * @returns the hosting Engine
  22246. */
  22247. getEngine(): Engine;
  22248. /**
  22249. * Defines if the geometry is ready to use
  22250. * @returns true if the geometry is ready to be used
  22251. */
  22252. isReady(): boolean;
  22253. /**
  22254. * Gets a value indicating that the geometry should not be serialized
  22255. */
  22256. get doNotSerialize(): boolean;
  22257. /** @hidden */
  22258. _rebuild(): void;
  22259. /**
  22260. * Affects all geometry data in one call
  22261. * @param vertexData defines the geometry data
  22262. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22263. */
  22264. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22265. /**
  22266. * Set specific vertex data
  22267. * @param kind defines the data kind (Position, normal, etc...)
  22268. * @param data defines the vertex data to use
  22269. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22270. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22271. */
  22272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22273. /**
  22274. * Removes a specific vertex data
  22275. * @param kind defines the data kind (Position, normal, etc...)
  22276. */
  22277. removeVerticesData(kind: string): void;
  22278. /**
  22279. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22280. * @param buffer defines the vertex buffer to use
  22281. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22282. */
  22283. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22284. /**
  22285. * Update a specific vertex buffer
  22286. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22287. * It will do nothing if the buffer is not updatable
  22288. * @param kind defines the data kind (Position, normal, etc...)
  22289. * @param data defines the data to use
  22290. * @param offset defines the offset in the target buffer where to store the data
  22291. * @param useBytes set to true if the offset is in bytes
  22292. */
  22293. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22294. /**
  22295. * Update a specific vertex buffer
  22296. * This function will create a new buffer if the current one is not updatable
  22297. * @param kind defines the data kind (Position, normal, etc...)
  22298. * @param data defines the data to use
  22299. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22300. */
  22301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22302. private _updateBoundingInfo;
  22303. /** @hidden */
  22304. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22305. /**
  22306. * Gets total number of vertices
  22307. * @returns the total number of vertices
  22308. */
  22309. getTotalVertices(): number;
  22310. /**
  22311. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22312. * @param kind defines the data kind (Position, normal, etc...)
  22313. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22314. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22315. * @returns a float array containing vertex data
  22316. */
  22317. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22318. /**
  22319. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22320. * @param kind defines the data kind (Position, normal, etc...)
  22321. * @returns true if the vertex buffer with the specified kind is updatable
  22322. */
  22323. isVertexBufferUpdatable(kind: string): boolean;
  22324. /**
  22325. * Gets a specific vertex buffer
  22326. * @param kind defines the data kind (Position, normal, etc...)
  22327. * @returns a VertexBuffer
  22328. */
  22329. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22330. /**
  22331. * Returns all vertex buffers
  22332. * @return an object holding all vertex buffers indexed by kind
  22333. */
  22334. getVertexBuffers(): Nullable<{
  22335. [key: string]: VertexBuffer;
  22336. }>;
  22337. /**
  22338. * Gets a boolean indicating if specific vertex buffer is present
  22339. * @param kind defines the data kind (Position, normal, etc...)
  22340. * @returns true if data is present
  22341. */
  22342. isVerticesDataPresent(kind: string): boolean;
  22343. /**
  22344. * Gets a list of all attached data kinds (Position, normal, etc...)
  22345. * @returns a list of string containing all kinds
  22346. */
  22347. getVerticesDataKinds(): string[];
  22348. /**
  22349. * Update index buffer
  22350. * @param indices defines the indices to store in the index buffer
  22351. * @param offset defines the offset in the target buffer where to store the data
  22352. * @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)
  22353. */
  22354. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22355. /**
  22356. * Creates a new index buffer
  22357. * @param indices defines the indices to store in the index buffer
  22358. * @param totalVertices defines the total number of vertices (could be null)
  22359. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22360. */
  22361. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22362. /**
  22363. * Return the total number of indices
  22364. * @returns the total number of indices
  22365. */
  22366. getTotalIndices(): number;
  22367. /**
  22368. * Gets the index buffer array
  22369. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22371. * @returns the index buffer array
  22372. */
  22373. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22374. /**
  22375. * Gets the index buffer
  22376. * @return the index buffer
  22377. */
  22378. getIndexBuffer(): Nullable<DataBuffer>;
  22379. /** @hidden */
  22380. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22381. /**
  22382. * Release the associated resources for a specific mesh
  22383. * @param mesh defines the source mesh
  22384. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22385. */
  22386. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22387. /**
  22388. * Apply current geometry to a given mesh
  22389. * @param mesh defines the mesh to apply geometry to
  22390. */
  22391. applyToMesh(mesh: Mesh): void;
  22392. private _updateExtend;
  22393. private _applyToMesh;
  22394. private notifyUpdate;
  22395. /**
  22396. * Load the geometry if it was flagged as delay loaded
  22397. * @param scene defines the hosting scene
  22398. * @param onLoaded defines a callback called when the geometry is loaded
  22399. */
  22400. load(scene: Scene, onLoaded?: () => void): void;
  22401. private _queueLoad;
  22402. /**
  22403. * Invert the geometry to move from a right handed system to a left handed one.
  22404. */
  22405. toLeftHanded(): void;
  22406. /** @hidden */
  22407. _resetPointsArrayCache(): void;
  22408. /** @hidden */
  22409. _generatePointsArray(): boolean;
  22410. /**
  22411. * Gets a value indicating if the geometry is disposed
  22412. * @returns true if the geometry was disposed
  22413. */
  22414. isDisposed(): boolean;
  22415. private _disposeVertexArrayObjects;
  22416. /**
  22417. * Free all associated resources
  22418. */
  22419. dispose(): void;
  22420. /**
  22421. * Clone the current geometry into a new geometry
  22422. * @param id defines the unique ID of the new geometry
  22423. * @returns a new geometry object
  22424. */
  22425. copy(id: string): Geometry;
  22426. /**
  22427. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22428. * @return a JSON representation of the current geometry data (without the vertices data)
  22429. */
  22430. serialize(): any;
  22431. private toNumberArray;
  22432. /**
  22433. * Serialize all vertices data into a JSON oject
  22434. * @returns a JSON representation of the current geometry data
  22435. */
  22436. serializeVerticeData(): any;
  22437. /**
  22438. * Extracts a clone of a mesh geometry
  22439. * @param mesh defines the source mesh
  22440. * @param id defines the unique ID of the new geometry object
  22441. * @returns the new geometry object
  22442. */
  22443. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22444. /**
  22445. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22446. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22447. * Be aware Math.random() could cause collisions, but:
  22448. * "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"
  22449. * @returns a string containing a new GUID
  22450. */
  22451. static RandomId(): string;
  22452. /** @hidden */
  22453. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22454. private static _CleanMatricesWeights;
  22455. /**
  22456. * Create a new geometry from persisted data (Using .babylon file format)
  22457. * @param parsedVertexData defines the persisted data
  22458. * @param scene defines the hosting scene
  22459. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22460. * @returns the new geometry object
  22461. */
  22462. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22463. }
  22464. }
  22465. declare module BABYLON {
  22466. /**
  22467. * Define an interface for all classes that will get and set the data on vertices
  22468. */
  22469. export interface IGetSetVerticesData {
  22470. /**
  22471. * Gets a boolean indicating if specific vertex data is present
  22472. * @param kind defines the vertex data kind to use
  22473. * @returns true is data kind is present
  22474. */
  22475. isVerticesDataPresent(kind: string): boolean;
  22476. /**
  22477. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22478. * @param kind defines the data kind (Position, normal, etc...)
  22479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22481. * @returns a float array containing vertex data
  22482. */
  22483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22484. /**
  22485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22486. * @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.
  22487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22488. * @returns the indices array or an empty array if the mesh has no geometry
  22489. */
  22490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22491. /**
  22492. * Set specific vertex data
  22493. * @param kind defines the data kind (Position, normal, etc...)
  22494. * @param data defines the vertex data to use
  22495. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22496. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22497. */
  22498. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22499. /**
  22500. * Update a specific associated vertex buffer
  22501. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22502. * - VertexBuffer.PositionKind
  22503. * - VertexBuffer.UVKind
  22504. * - VertexBuffer.UV2Kind
  22505. * - VertexBuffer.UV3Kind
  22506. * - VertexBuffer.UV4Kind
  22507. * - VertexBuffer.UV5Kind
  22508. * - VertexBuffer.UV6Kind
  22509. * - VertexBuffer.ColorKind
  22510. * - VertexBuffer.MatricesIndicesKind
  22511. * - VertexBuffer.MatricesIndicesExtraKind
  22512. * - VertexBuffer.MatricesWeightsKind
  22513. * - VertexBuffer.MatricesWeightsExtraKind
  22514. * @param data defines the data source
  22515. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22516. * @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)
  22517. */
  22518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22519. /**
  22520. * Creates a new index buffer
  22521. * @param indices defines the indices to store in the index buffer
  22522. * @param totalVertices defines the total number of vertices (could be null)
  22523. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22524. */
  22525. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22526. }
  22527. /**
  22528. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22529. */
  22530. export class VertexData {
  22531. /**
  22532. * Mesh side orientation : usually the external or front surface
  22533. */
  22534. static readonly FRONTSIDE: number;
  22535. /**
  22536. * Mesh side orientation : usually the internal or back surface
  22537. */
  22538. static readonly BACKSIDE: number;
  22539. /**
  22540. * Mesh side orientation : both internal and external or front and back surfaces
  22541. */
  22542. static readonly DOUBLESIDE: number;
  22543. /**
  22544. * Mesh side orientation : by default, `FRONTSIDE`
  22545. */
  22546. static readonly DEFAULTSIDE: number;
  22547. /**
  22548. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22549. */
  22550. positions: Nullable<FloatArray>;
  22551. /**
  22552. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22553. */
  22554. normals: Nullable<FloatArray>;
  22555. /**
  22556. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22557. */
  22558. tangents: Nullable<FloatArray>;
  22559. /**
  22560. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22561. */
  22562. uvs: Nullable<FloatArray>;
  22563. /**
  22564. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22565. */
  22566. uvs2: Nullable<FloatArray>;
  22567. /**
  22568. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22569. */
  22570. uvs3: Nullable<FloatArray>;
  22571. /**
  22572. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22573. */
  22574. uvs4: Nullable<FloatArray>;
  22575. /**
  22576. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22577. */
  22578. uvs5: Nullable<FloatArray>;
  22579. /**
  22580. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22581. */
  22582. uvs6: Nullable<FloatArray>;
  22583. /**
  22584. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22585. */
  22586. colors: Nullable<FloatArray>;
  22587. /**
  22588. * 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).
  22589. */
  22590. matricesIndices: Nullable<FloatArray>;
  22591. /**
  22592. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22593. */
  22594. matricesWeights: Nullable<FloatArray>;
  22595. /**
  22596. * An array extending the number of possible indices
  22597. */
  22598. matricesIndicesExtra: Nullable<FloatArray>;
  22599. /**
  22600. * An array extending the number of possible weights when the number of indices is extended
  22601. */
  22602. matricesWeightsExtra: Nullable<FloatArray>;
  22603. /**
  22604. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22605. */
  22606. indices: Nullable<IndicesArray>;
  22607. /**
  22608. * Uses the passed data array to set the set the values for the specified kind of data
  22609. * @param data a linear array of floating numbers
  22610. * @param kind the type of data that is being set, eg positions, colors etc
  22611. */
  22612. set(data: FloatArray, kind: string): void;
  22613. /**
  22614. * Associates the vertexData to the passed Mesh.
  22615. * Sets it as updatable or not (default `false`)
  22616. * @param mesh the mesh the vertexData is applied to
  22617. * @param updatable when used and having the value true allows new data to update the vertexData
  22618. * @returns the VertexData
  22619. */
  22620. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22621. /**
  22622. * Associates the vertexData to the passed Geometry.
  22623. * Sets it as updatable or not (default `false`)
  22624. * @param geometry the geometry the vertexData is applied to
  22625. * @param updatable when used and having the value true allows new data to update the vertexData
  22626. * @returns VertexData
  22627. */
  22628. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22629. /**
  22630. * Updates the associated mesh
  22631. * @param mesh the mesh to be updated
  22632. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22633. * @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
  22634. * @returns VertexData
  22635. */
  22636. updateMesh(mesh: Mesh): VertexData;
  22637. /**
  22638. * Updates the associated geometry
  22639. * @param geometry the geometry to be updated
  22640. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22641. * @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
  22642. * @returns VertexData.
  22643. */
  22644. updateGeometry(geometry: Geometry): VertexData;
  22645. private _applyTo;
  22646. private _update;
  22647. /**
  22648. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22649. * @param matrix the transforming matrix
  22650. * @returns the VertexData
  22651. */
  22652. transform(matrix: Matrix): VertexData;
  22653. /**
  22654. * Merges the passed VertexData into the current one
  22655. * @param other the VertexData to be merged into the current one
  22656. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22657. * @returns the modified VertexData
  22658. */
  22659. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22660. private _mergeElement;
  22661. private _validate;
  22662. /**
  22663. * Serializes the VertexData
  22664. * @returns a serialized object
  22665. */
  22666. serialize(): any;
  22667. /**
  22668. * Extracts the vertexData from a mesh
  22669. * @param mesh the mesh from which to extract the VertexData
  22670. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22671. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22672. * @returns the object VertexData associated to the passed mesh
  22673. */
  22674. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22675. /**
  22676. * Extracts the vertexData from the geometry
  22677. * @param geometry the geometry from which to extract the VertexData
  22678. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22679. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22680. * @returns the object VertexData associated to the passed mesh
  22681. */
  22682. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22683. private static _ExtractFrom;
  22684. /**
  22685. * Creates the VertexData for a Ribbon
  22686. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22687. * * pathArray array of paths, each of which an array of successive Vector3
  22688. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22689. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22690. * * 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
  22691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22692. * * 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)
  22693. * * 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)
  22694. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22695. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22696. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22697. * @returns the VertexData of the ribbon
  22698. */
  22699. static CreateRibbon(options: {
  22700. pathArray: Vector3[][];
  22701. closeArray?: boolean;
  22702. closePath?: boolean;
  22703. offset?: number;
  22704. sideOrientation?: number;
  22705. frontUVs?: Vector4;
  22706. backUVs?: Vector4;
  22707. invertUV?: boolean;
  22708. uvs?: Vector2[];
  22709. colors?: Color4[];
  22710. }): VertexData;
  22711. /**
  22712. * Creates the VertexData for a box
  22713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22714. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22715. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22716. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22717. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22718. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22719. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22721. * * 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)
  22722. * * 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)
  22723. * @returns the VertexData of the box
  22724. */
  22725. static CreateBox(options: {
  22726. size?: number;
  22727. width?: number;
  22728. height?: number;
  22729. depth?: number;
  22730. faceUV?: Vector4[];
  22731. faceColors?: Color4[];
  22732. sideOrientation?: number;
  22733. frontUVs?: Vector4;
  22734. backUVs?: Vector4;
  22735. }): VertexData;
  22736. /**
  22737. * Creates the VertexData for a tiled box
  22738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22740. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22741. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22743. * @returns the VertexData of the box
  22744. */
  22745. static CreateTiledBox(options: {
  22746. pattern?: number;
  22747. width?: number;
  22748. height?: number;
  22749. depth?: number;
  22750. tileSize?: number;
  22751. tileWidth?: number;
  22752. tileHeight?: number;
  22753. alignHorizontal?: number;
  22754. alignVertical?: number;
  22755. faceUV?: Vector4[];
  22756. faceColors?: Color4[];
  22757. sideOrientation?: number;
  22758. }): VertexData;
  22759. /**
  22760. * Creates the VertexData for a tiled plane
  22761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22762. * * pattern a limited pattern arrangement depending on the number
  22763. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22764. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22765. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22767. * * 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)
  22768. * * 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)
  22769. * @returns the VertexData of the tiled plane
  22770. */
  22771. static CreateTiledPlane(options: {
  22772. pattern?: number;
  22773. tileSize?: number;
  22774. tileWidth?: number;
  22775. tileHeight?: number;
  22776. size?: number;
  22777. width?: number;
  22778. height?: number;
  22779. alignHorizontal?: number;
  22780. alignVertical?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22788. * * segments sets the number of horizontal strips optional, default 32
  22789. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22790. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22791. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22792. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22793. * * 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
  22794. * * 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
  22795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22796. * * 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)
  22797. * * 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)
  22798. * @returns the VertexData of the ellipsoid
  22799. */
  22800. static CreateSphere(options: {
  22801. segments?: number;
  22802. diameter?: number;
  22803. diameterX?: number;
  22804. diameterY?: number;
  22805. diameterZ?: number;
  22806. arc?: number;
  22807. slice?: number;
  22808. sideOrientation?: number;
  22809. frontUVs?: Vector4;
  22810. backUVs?: Vector4;
  22811. }): VertexData;
  22812. /**
  22813. * Creates the VertexData for a cylinder, cone or prism
  22814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22815. * * height sets the height (y direction) of the cylinder, optional, default 2
  22816. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22817. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22818. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22819. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22820. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22821. * * 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
  22822. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22824. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22825. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22827. * * 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)
  22828. * * 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)
  22829. * @returns the VertexData of the cylinder, cone or prism
  22830. */
  22831. static CreateCylinder(options: {
  22832. height?: number;
  22833. diameterTop?: number;
  22834. diameterBottom?: number;
  22835. diameter?: number;
  22836. tessellation?: number;
  22837. subdivisions?: number;
  22838. arc?: number;
  22839. faceColors?: Color4[];
  22840. faceUV?: Vector4[];
  22841. hasRings?: boolean;
  22842. enclose?: boolean;
  22843. sideOrientation?: number;
  22844. frontUVs?: Vector4;
  22845. backUVs?: Vector4;
  22846. }): VertexData;
  22847. /**
  22848. * Creates the VertexData for a torus
  22849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22850. * * diameter the diameter of the torus, optional default 1
  22851. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22852. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22854. * * 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)
  22855. * * 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)
  22856. * @returns the VertexData of the torus
  22857. */
  22858. static CreateTorus(options: {
  22859. diameter?: number;
  22860. thickness?: number;
  22861. tessellation?: number;
  22862. sideOrientation?: number;
  22863. frontUVs?: Vector4;
  22864. backUVs?: Vector4;
  22865. }): VertexData;
  22866. /**
  22867. * Creates the VertexData of the LineSystem
  22868. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22869. * - lines an array of lines, each line being an array of successive Vector3
  22870. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22871. * @returns the VertexData of the LineSystem
  22872. */
  22873. static CreateLineSystem(options: {
  22874. lines: Vector3[][];
  22875. colors?: Nullable<Color4[][]>;
  22876. }): VertexData;
  22877. /**
  22878. * Create the VertexData for a DashedLines
  22879. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22880. * - points an array successive Vector3
  22881. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22882. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22883. * - dashNb the intended total number of dashes, optional, default 200
  22884. * @returns the VertexData for the DashedLines
  22885. */
  22886. static CreateDashedLines(options: {
  22887. points: Vector3[];
  22888. dashSize?: number;
  22889. gapSize?: number;
  22890. dashNb?: number;
  22891. }): VertexData;
  22892. /**
  22893. * Creates the VertexData for a Ground
  22894. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22895. * - width the width (x direction) of the ground, optional, default 1
  22896. * - height the height (z direction) of the ground, optional, default 1
  22897. * - subdivisions the number of subdivisions per side, optional, default 1
  22898. * @returns the VertexData of the Ground
  22899. */
  22900. static CreateGround(options: {
  22901. width?: number;
  22902. height?: number;
  22903. subdivisions?: number;
  22904. subdivisionsX?: number;
  22905. subdivisionsY?: number;
  22906. }): VertexData;
  22907. /**
  22908. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22909. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22910. * * xmin the ground minimum X coordinate, optional, default -1
  22911. * * zmin the ground minimum Z coordinate, optional, default -1
  22912. * * xmax the ground maximum X coordinate, optional, default 1
  22913. * * zmax the ground maximum Z coordinate, optional, default 1
  22914. * * 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}
  22915. * * 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}
  22916. * @returns the VertexData of the TiledGround
  22917. */
  22918. static CreateTiledGround(options: {
  22919. xmin: number;
  22920. zmin: number;
  22921. xmax: number;
  22922. zmax: number;
  22923. subdivisions?: {
  22924. w: number;
  22925. h: number;
  22926. };
  22927. precision?: {
  22928. w: number;
  22929. h: number;
  22930. };
  22931. }): VertexData;
  22932. /**
  22933. * Creates the VertexData of the Ground designed from a heightmap
  22934. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22935. * * width the width (x direction) of the ground
  22936. * * height the height (z direction) of the ground
  22937. * * subdivisions the number of subdivisions per side
  22938. * * minHeight the minimum altitude on the ground, optional, default 0
  22939. * * maxHeight the maximum altitude on the ground, optional default 1
  22940. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22941. * * buffer the array holding the image color data
  22942. * * bufferWidth the width of image
  22943. * * bufferHeight the height of image
  22944. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22945. * @returns the VertexData of the Ground designed from a heightmap
  22946. */
  22947. static CreateGroundFromHeightMap(options: {
  22948. width: number;
  22949. height: number;
  22950. subdivisions: number;
  22951. minHeight: number;
  22952. maxHeight: number;
  22953. colorFilter: Color3;
  22954. buffer: Uint8Array;
  22955. bufferWidth: number;
  22956. bufferHeight: number;
  22957. alphaFilter: number;
  22958. }): VertexData;
  22959. /**
  22960. * Creates the VertexData for a Plane
  22961. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22962. * * size sets the width and height of the plane to the value of size, optional default 1
  22963. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22964. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22966. * * 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)
  22967. * * 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)
  22968. * @returns the VertexData of the box
  22969. */
  22970. static CreatePlane(options: {
  22971. size?: number;
  22972. width?: number;
  22973. height?: number;
  22974. sideOrientation?: number;
  22975. frontUVs?: Vector4;
  22976. backUVs?: Vector4;
  22977. }): VertexData;
  22978. /**
  22979. * Creates the VertexData of the Disc or regular Polygon
  22980. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22981. * * radius the radius of the disc, optional default 0.5
  22982. * * tessellation the number of polygon sides, optional, default 64
  22983. * * 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
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * 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)
  22986. * * 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)
  22987. * @returns the VertexData of the box
  22988. */
  22989. static CreateDisc(options: {
  22990. radius?: number;
  22991. tessellation?: number;
  22992. arc?: number;
  22993. sideOrientation?: number;
  22994. frontUVs?: Vector4;
  22995. backUVs?: Vector4;
  22996. }): VertexData;
  22997. /**
  22998. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22999. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23000. * @param polygon a mesh built from polygonTriangulation.build()
  23001. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23002. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23003. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23004. * @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)
  23005. * @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)
  23006. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23007. * @returns the VertexData of the Polygon
  23008. */
  23009. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23010. /**
  23011. * Creates the VertexData of the IcoSphere
  23012. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23013. * * radius the radius of the IcoSphere, optional default 1
  23014. * * radiusX allows stretching in the x direction, optional, default radius
  23015. * * radiusY allows stretching in the y direction, optional, default radius
  23016. * * radiusZ allows stretching in the z direction, optional, default radius
  23017. * * flat when true creates a flat shaded mesh, optional, default true
  23018. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23020. * * 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)
  23021. * * 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)
  23022. * @returns the VertexData of the IcoSphere
  23023. */
  23024. static CreateIcoSphere(options: {
  23025. radius?: number;
  23026. radiusX?: number;
  23027. radiusY?: number;
  23028. radiusZ?: number;
  23029. flat?: boolean;
  23030. subdivisions?: number;
  23031. sideOrientation?: number;
  23032. frontUVs?: Vector4;
  23033. backUVs?: Vector4;
  23034. }): VertexData;
  23035. /**
  23036. * Creates the VertexData for a Polyhedron
  23037. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23038. * * type provided types are:
  23039. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23040. * * 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)
  23041. * * size the size of the IcoSphere, optional default 1
  23042. * * sizeX allows stretching in the x direction, optional, default size
  23043. * * sizeY allows stretching in the y direction, optional, default size
  23044. * * sizeZ allows stretching in the z direction, optional, default size
  23045. * * 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
  23046. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23048. * * flat when true creates a flat shaded mesh, optional, default true
  23049. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23051. * * 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)
  23052. * * 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)
  23053. * @returns the VertexData of the Polyhedron
  23054. */
  23055. static CreatePolyhedron(options: {
  23056. type?: number;
  23057. size?: number;
  23058. sizeX?: number;
  23059. sizeY?: number;
  23060. sizeZ?: number;
  23061. custom?: any;
  23062. faceUV?: Vector4[];
  23063. faceColors?: Color4[];
  23064. flat?: boolean;
  23065. sideOrientation?: number;
  23066. frontUVs?: Vector4;
  23067. backUVs?: Vector4;
  23068. }): VertexData;
  23069. /**
  23070. * Creates the VertexData for a TorusKnot
  23071. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23072. * * radius the radius of the torus knot, optional, default 2
  23073. * * tube the thickness of the tube, optional, default 0.5
  23074. * * radialSegments the number of sides on each tube segments, optional, default 32
  23075. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23076. * * p the number of windings around the z axis, optional, default 2
  23077. * * q the number of windings around the x axis, optional, default 3
  23078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * * 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)
  23080. * * 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)
  23081. * @returns the VertexData of the Torus Knot
  23082. */
  23083. static CreateTorusKnot(options: {
  23084. radius?: number;
  23085. tube?: number;
  23086. radialSegments?: number;
  23087. tubularSegments?: number;
  23088. p?: number;
  23089. q?: number;
  23090. sideOrientation?: number;
  23091. frontUVs?: Vector4;
  23092. backUVs?: Vector4;
  23093. }): VertexData;
  23094. /**
  23095. * Compute normals for given positions and indices
  23096. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23097. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23098. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23099. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23100. * * facetNormals : optional array of facet normals (vector3)
  23101. * * facetPositions : optional array of facet positions (vector3)
  23102. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23103. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23104. * * bInfo : optional bounding info, required for facetPartitioning computation
  23105. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23106. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23107. * * useRightHandedSystem: optional boolean to for right handed system computation
  23108. * * depthSort : optional boolean to enable the facet depth sort computation
  23109. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23110. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23111. */
  23112. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23113. facetNormals?: any;
  23114. facetPositions?: any;
  23115. facetPartitioning?: any;
  23116. ratio?: number;
  23117. bInfo?: any;
  23118. bbSize?: Vector3;
  23119. subDiv?: any;
  23120. useRightHandedSystem?: boolean;
  23121. depthSort?: boolean;
  23122. distanceTo?: Vector3;
  23123. depthSortedFacets?: any;
  23124. }): void;
  23125. /** @hidden */
  23126. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23127. /**
  23128. * Applies VertexData created from the imported parameters to the geometry
  23129. * @param parsedVertexData the parsed data from an imported file
  23130. * @param geometry the geometry to apply the VertexData to
  23131. */
  23132. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23133. }
  23134. }
  23135. declare module BABYLON {
  23136. /**
  23137. * Defines a target to use with MorphTargetManager
  23138. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23139. */
  23140. export class MorphTarget implements IAnimatable {
  23141. /** defines the name of the target */
  23142. name: string;
  23143. /**
  23144. * Gets or sets the list of animations
  23145. */
  23146. animations: Animation[];
  23147. private _scene;
  23148. private _positions;
  23149. private _normals;
  23150. private _tangents;
  23151. private _uvs;
  23152. private _influence;
  23153. private _uniqueId;
  23154. /**
  23155. * Observable raised when the influence changes
  23156. */
  23157. onInfluenceChanged: Observable<boolean>;
  23158. /** @hidden */
  23159. _onDataLayoutChanged: Observable<void>;
  23160. /**
  23161. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23162. */
  23163. get influence(): number;
  23164. set influence(influence: number);
  23165. /**
  23166. * Gets or sets the id of the morph Target
  23167. */
  23168. id: string;
  23169. private _animationPropertiesOverride;
  23170. /**
  23171. * Gets or sets the animation properties override
  23172. */
  23173. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23174. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23175. /**
  23176. * Creates a new MorphTarget
  23177. * @param name defines the name of the target
  23178. * @param influence defines the influence to use
  23179. * @param scene defines the scene the morphtarget belongs to
  23180. */
  23181. constructor(
  23182. /** defines the name of the target */
  23183. name: string, influence?: number, scene?: Nullable<Scene>);
  23184. /**
  23185. * Gets the unique ID of this manager
  23186. */
  23187. get uniqueId(): number;
  23188. /**
  23189. * Gets a boolean defining if the target contains position data
  23190. */
  23191. get hasPositions(): boolean;
  23192. /**
  23193. * Gets a boolean defining if the target contains normal data
  23194. */
  23195. get hasNormals(): boolean;
  23196. /**
  23197. * Gets a boolean defining if the target contains tangent data
  23198. */
  23199. get hasTangents(): boolean;
  23200. /**
  23201. * Gets a boolean defining if the target contains texture coordinates data
  23202. */
  23203. get hasUVs(): boolean;
  23204. /**
  23205. * Affects position data to this target
  23206. * @param data defines the position data to use
  23207. */
  23208. setPositions(data: Nullable<FloatArray>): void;
  23209. /**
  23210. * Gets the position data stored in this target
  23211. * @returns a FloatArray containing the position data (or null if not present)
  23212. */
  23213. getPositions(): Nullable<FloatArray>;
  23214. /**
  23215. * Affects normal data to this target
  23216. * @param data defines the normal data to use
  23217. */
  23218. setNormals(data: Nullable<FloatArray>): void;
  23219. /**
  23220. * Gets the normal data stored in this target
  23221. * @returns a FloatArray containing the normal data (or null if not present)
  23222. */
  23223. getNormals(): Nullable<FloatArray>;
  23224. /**
  23225. * Affects tangent data to this target
  23226. * @param data defines the tangent data to use
  23227. */
  23228. setTangents(data: Nullable<FloatArray>): void;
  23229. /**
  23230. * Gets the tangent data stored in this target
  23231. * @returns a FloatArray containing the tangent data (or null if not present)
  23232. */
  23233. getTangents(): Nullable<FloatArray>;
  23234. /**
  23235. * Affects texture coordinates data to this target
  23236. * @param data defines the texture coordinates data to use
  23237. */
  23238. setUVs(data: Nullable<FloatArray>): void;
  23239. /**
  23240. * Gets the texture coordinates data stored in this target
  23241. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23242. */
  23243. getUVs(): Nullable<FloatArray>;
  23244. /**
  23245. * Clone the current target
  23246. * @returns a new MorphTarget
  23247. */
  23248. clone(): MorphTarget;
  23249. /**
  23250. * Serializes the current target into a Serialization object
  23251. * @returns the serialized object
  23252. */
  23253. serialize(): any;
  23254. /**
  23255. * Returns the string "MorphTarget"
  23256. * @returns "MorphTarget"
  23257. */
  23258. getClassName(): string;
  23259. /**
  23260. * Creates a new target from serialized data
  23261. * @param serializationObject defines the serialized data to use
  23262. * @returns a new MorphTarget
  23263. */
  23264. static Parse(serializationObject: any): MorphTarget;
  23265. /**
  23266. * Creates a MorphTarget from mesh data
  23267. * @param mesh defines the source mesh
  23268. * @param name defines the name to use for the new target
  23269. * @param influence defines the influence to attach to the target
  23270. * @returns a new MorphTarget
  23271. */
  23272. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23273. }
  23274. }
  23275. declare module BABYLON {
  23276. /**
  23277. * This class is used to deform meshes using morphing between different targets
  23278. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23279. */
  23280. export class MorphTargetManager {
  23281. private _targets;
  23282. private _targetInfluenceChangedObservers;
  23283. private _targetDataLayoutChangedObservers;
  23284. private _activeTargets;
  23285. private _scene;
  23286. private _influences;
  23287. private _supportsNormals;
  23288. private _supportsTangents;
  23289. private _supportsUVs;
  23290. private _vertexCount;
  23291. private _uniqueId;
  23292. private _tempInfluences;
  23293. /**
  23294. * Gets or sets a boolean indicating if normals must be morphed
  23295. */
  23296. enableNormalMorphing: boolean;
  23297. /**
  23298. * Gets or sets a boolean indicating if tangents must be morphed
  23299. */
  23300. enableTangentMorphing: boolean;
  23301. /**
  23302. * Gets or sets a boolean indicating if UV must be morphed
  23303. */
  23304. enableUVMorphing: boolean;
  23305. /**
  23306. * Creates a new MorphTargetManager
  23307. * @param scene defines the current scene
  23308. */
  23309. constructor(scene?: Nullable<Scene>);
  23310. /**
  23311. * Gets the unique ID of this manager
  23312. */
  23313. get uniqueId(): number;
  23314. /**
  23315. * Gets the number of vertices handled by this manager
  23316. */
  23317. get vertexCount(): number;
  23318. /**
  23319. * Gets a boolean indicating if this manager supports morphing of normals
  23320. */
  23321. get supportsNormals(): boolean;
  23322. /**
  23323. * Gets a boolean indicating if this manager supports morphing of tangents
  23324. */
  23325. get supportsTangents(): boolean;
  23326. /**
  23327. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23328. */
  23329. get supportsUVs(): boolean;
  23330. /**
  23331. * Gets the number of targets stored in this manager
  23332. */
  23333. get numTargets(): number;
  23334. /**
  23335. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23336. */
  23337. get numInfluencers(): number;
  23338. /**
  23339. * Gets the list of influences (one per target)
  23340. */
  23341. get influences(): Float32Array;
  23342. /**
  23343. * Gets the active target at specified index. An active target is a target with an influence > 0
  23344. * @param index defines the index to check
  23345. * @returns the requested target
  23346. */
  23347. getActiveTarget(index: number): MorphTarget;
  23348. /**
  23349. * Gets the target at specified index
  23350. * @param index defines the index to check
  23351. * @returns the requested target
  23352. */
  23353. getTarget(index: number): MorphTarget;
  23354. /**
  23355. * Add a new target to this manager
  23356. * @param target defines the target to add
  23357. */
  23358. addTarget(target: MorphTarget): void;
  23359. /**
  23360. * Removes a target from the manager
  23361. * @param target defines the target to remove
  23362. */
  23363. removeTarget(target: MorphTarget): void;
  23364. /**
  23365. * Clone the current manager
  23366. * @returns a new MorphTargetManager
  23367. */
  23368. clone(): MorphTargetManager;
  23369. /**
  23370. * Serializes the current manager into a Serialization object
  23371. * @returns the serialized object
  23372. */
  23373. serialize(): any;
  23374. private _syncActiveTargets;
  23375. /**
  23376. * Syncrhonize the targets with all the meshes using this morph target manager
  23377. */
  23378. synchronize(): void;
  23379. /**
  23380. * Creates a new MorphTargetManager from serialized data
  23381. * @param serializationObject defines the serialized data
  23382. * @param scene defines the hosting scene
  23383. * @returns the new MorphTargetManager
  23384. */
  23385. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23386. }
  23387. }
  23388. declare module BABYLON {
  23389. /**
  23390. * Class used to represent a specific level of detail of a mesh
  23391. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23392. */
  23393. export class MeshLODLevel {
  23394. /** Defines the distance where this level should start being displayed */
  23395. distance: number;
  23396. /** Defines the mesh to use to render this level */
  23397. mesh: Nullable<Mesh>;
  23398. /**
  23399. * Creates a new LOD level
  23400. * @param distance defines the distance where this level should star being displayed
  23401. * @param mesh defines the mesh to use to render this level
  23402. */
  23403. constructor(
  23404. /** Defines the distance where this level should start being displayed */
  23405. distance: number,
  23406. /** Defines the mesh to use to render this level */
  23407. mesh: Nullable<Mesh>);
  23408. }
  23409. }
  23410. declare module BABYLON {
  23411. /**
  23412. * Mesh representing the gorund
  23413. */
  23414. export class GroundMesh extends Mesh {
  23415. /** If octree should be generated */
  23416. generateOctree: boolean;
  23417. private _heightQuads;
  23418. /** @hidden */
  23419. _subdivisionsX: number;
  23420. /** @hidden */
  23421. _subdivisionsY: number;
  23422. /** @hidden */
  23423. _width: number;
  23424. /** @hidden */
  23425. _height: number;
  23426. /** @hidden */
  23427. _minX: number;
  23428. /** @hidden */
  23429. _maxX: number;
  23430. /** @hidden */
  23431. _minZ: number;
  23432. /** @hidden */
  23433. _maxZ: number;
  23434. constructor(name: string, scene: Scene);
  23435. /**
  23436. * "GroundMesh"
  23437. * @returns "GroundMesh"
  23438. */
  23439. getClassName(): string;
  23440. /**
  23441. * The minimum of x and y subdivisions
  23442. */
  23443. get subdivisions(): number;
  23444. /**
  23445. * X subdivisions
  23446. */
  23447. get subdivisionsX(): number;
  23448. /**
  23449. * Y subdivisions
  23450. */
  23451. get subdivisionsY(): number;
  23452. /**
  23453. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23454. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23455. * @param chunksCount the number of subdivisions for x and y
  23456. * @param octreeBlocksSize (Default: 32)
  23457. */
  23458. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23459. /**
  23460. * Returns a height (y) value in the Worl system :
  23461. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23462. * @param x x coordinate
  23463. * @param z z coordinate
  23464. * @returns the ground y position if (x, z) are outside the ground surface.
  23465. */
  23466. getHeightAtCoordinates(x: number, z: number): number;
  23467. /**
  23468. * Returns a normalized vector (Vector3) orthogonal to the ground
  23469. * at the ground coordinates (x, z) expressed in the World system.
  23470. * @param x x coordinate
  23471. * @param z z coordinate
  23472. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23473. */
  23474. getNormalAtCoordinates(x: number, z: number): Vector3;
  23475. /**
  23476. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23477. * at the ground coordinates (x, z) expressed in the World system.
  23478. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23479. * @param x x coordinate
  23480. * @param z z coordinate
  23481. * @param ref vector to store the result
  23482. * @returns the GroundMesh.
  23483. */
  23484. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23485. /**
  23486. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23487. * if the ground has been updated.
  23488. * This can be used in the render loop.
  23489. * @returns the GroundMesh.
  23490. */
  23491. updateCoordinateHeights(): GroundMesh;
  23492. private _getFacetAt;
  23493. private _initHeightQuads;
  23494. private _computeHeightQuads;
  23495. /**
  23496. * Serializes this ground mesh
  23497. * @param serializationObject object to write serialization to
  23498. */
  23499. serialize(serializationObject: any): void;
  23500. /**
  23501. * Parses a serialized ground mesh
  23502. * @param parsedMesh the serialized mesh
  23503. * @param scene the scene to create the ground mesh in
  23504. * @returns the created ground mesh
  23505. */
  23506. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23507. }
  23508. }
  23509. declare module BABYLON {
  23510. /**
  23511. * Interface for Physics-Joint data
  23512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23513. */
  23514. export interface PhysicsJointData {
  23515. /**
  23516. * The main pivot of the joint
  23517. */
  23518. mainPivot?: Vector3;
  23519. /**
  23520. * The connected pivot of the joint
  23521. */
  23522. connectedPivot?: Vector3;
  23523. /**
  23524. * The main axis of the joint
  23525. */
  23526. mainAxis?: Vector3;
  23527. /**
  23528. * The connected axis of the joint
  23529. */
  23530. connectedAxis?: Vector3;
  23531. /**
  23532. * The collision of the joint
  23533. */
  23534. collision?: boolean;
  23535. /**
  23536. * Native Oimo/Cannon/Energy data
  23537. */
  23538. nativeParams?: any;
  23539. }
  23540. /**
  23541. * This is a holder class for the physics joint created by the physics plugin
  23542. * It holds a set of functions to control the underlying joint
  23543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23544. */
  23545. export class PhysicsJoint {
  23546. /**
  23547. * The type of the physics joint
  23548. */
  23549. type: number;
  23550. /**
  23551. * The data for the physics joint
  23552. */
  23553. jointData: PhysicsJointData;
  23554. private _physicsJoint;
  23555. protected _physicsPlugin: IPhysicsEnginePlugin;
  23556. /**
  23557. * Initializes the physics joint
  23558. * @param type The type of the physics joint
  23559. * @param jointData The data for the physics joint
  23560. */
  23561. constructor(
  23562. /**
  23563. * The type of the physics joint
  23564. */
  23565. type: number,
  23566. /**
  23567. * The data for the physics joint
  23568. */
  23569. jointData: PhysicsJointData);
  23570. /**
  23571. * Gets the physics joint
  23572. */
  23573. get physicsJoint(): any;
  23574. /**
  23575. * Sets the physics joint
  23576. */
  23577. set physicsJoint(newJoint: any);
  23578. /**
  23579. * Sets the physics plugin
  23580. */
  23581. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23582. /**
  23583. * Execute a function that is physics-plugin specific.
  23584. * @param {Function} func the function that will be executed.
  23585. * It accepts two parameters: the physics world and the physics joint
  23586. */
  23587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23588. /**
  23589. * Distance-Joint type
  23590. */
  23591. static DistanceJoint: number;
  23592. /**
  23593. * Hinge-Joint type
  23594. */
  23595. static HingeJoint: number;
  23596. /**
  23597. * Ball-and-Socket joint type
  23598. */
  23599. static BallAndSocketJoint: number;
  23600. /**
  23601. * Wheel-Joint type
  23602. */
  23603. static WheelJoint: number;
  23604. /**
  23605. * Slider-Joint type
  23606. */
  23607. static SliderJoint: number;
  23608. /**
  23609. * Prismatic-Joint type
  23610. */
  23611. static PrismaticJoint: number;
  23612. /**
  23613. * Universal-Joint type
  23614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23615. */
  23616. static UniversalJoint: number;
  23617. /**
  23618. * Hinge-Joint 2 type
  23619. */
  23620. static Hinge2Joint: number;
  23621. /**
  23622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23623. */
  23624. static PointToPointJoint: number;
  23625. /**
  23626. * Spring-Joint type
  23627. */
  23628. static SpringJoint: number;
  23629. /**
  23630. * Lock-Joint type
  23631. */
  23632. static LockJoint: number;
  23633. }
  23634. /**
  23635. * A class representing a physics distance joint
  23636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23637. */
  23638. export class DistanceJoint extends PhysicsJoint {
  23639. /**
  23640. *
  23641. * @param jointData The data for the Distance-Joint
  23642. */
  23643. constructor(jointData: DistanceJointData);
  23644. /**
  23645. * Update the predefined distance.
  23646. * @param maxDistance The maximum preferred distance
  23647. * @param minDistance The minimum preferred distance
  23648. */
  23649. updateDistance(maxDistance: number, minDistance?: number): void;
  23650. }
  23651. /**
  23652. * Represents a Motor-Enabled Joint
  23653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23654. */
  23655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23656. /**
  23657. * Initializes the Motor-Enabled Joint
  23658. * @param type The type of the joint
  23659. * @param jointData The physica joint data for the joint
  23660. */
  23661. constructor(type: number, jointData: PhysicsJointData);
  23662. /**
  23663. * Set the motor values.
  23664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23665. * @param force the force to apply
  23666. * @param maxForce max force for this motor.
  23667. */
  23668. setMotor(force?: number, maxForce?: number): void;
  23669. /**
  23670. * Set the motor's limits.
  23671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23672. * @param upperLimit The upper limit of the motor
  23673. * @param lowerLimit The lower limit of the motor
  23674. */
  23675. setLimit(upperLimit: number, lowerLimit?: number): void;
  23676. }
  23677. /**
  23678. * This class represents a single physics Hinge-Joint
  23679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23680. */
  23681. export class HingeJoint extends MotorEnabledJoint {
  23682. /**
  23683. * Initializes the Hinge-Joint
  23684. * @param jointData The joint data for the Hinge-Joint
  23685. */
  23686. constructor(jointData: PhysicsJointData);
  23687. /**
  23688. * Set the motor values.
  23689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23690. * @param {number} force the force to apply
  23691. * @param {number} maxForce max force for this motor.
  23692. */
  23693. setMotor(force?: number, maxForce?: number): void;
  23694. /**
  23695. * Set the motor's limits.
  23696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23697. * @param upperLimit The upper limit of the motor
  23698. * @param lowerLimit The lower limit of the motor
  23699. */
  23700. setLimit(upperLimit: number, lowerLimit?: number): void;
  23701. }
  23702. /**
  23703. * This class represents a dual hinge physics joint (same as wheel joint)
  23704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23705. */
  23706. export class Hinge2Joint extends MotorEnabledJoint {
  23707. /**
  23708. * Initializes the Hinge2-Joint
  23709. * @param jointData The joint data for the Hinge2-Joint
  23710. */
  23711. constructor(jointData: PhysicsJointData);
  23712. /**
  23713. * Set the motor values.
  23714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23715. * @param {number} targetSpeed the speed the motor is to reach
  23716. * @param {number} maxForce max force for this motor.
  23717. * @param {motorIndex} the motor's index, 0 or 1.
  23718. */
  23719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23720. /**
  23721. * Set the motor limits.
  23722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23723. * @param {number} upperLimit the upper limit
  23724. * @param {number} lowerLimit lower limit
  23725. * @param {motorIndex} the motor's index, 0 or 1.
  23726. */
  23727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23728. }
  23729. /**
  23730. * Interface for a motor enabled joint
  23731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23732. */
  23733. export interface IMotorEnabledJoint {
  23734. /**
  23735. * Physics joint
  23736. */
  23737. physicsJoint: any;
  23738. /**
  23739. * Sets the motor of the motor-enabled joint
  23740. * @param force The force of the motor
  23741. * @param maxForce The maximum force of the motor
  23742. * @param motorIndex The index of the motor
  23743. */
  23744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23745. /**
  23746. * Sets the limit of the motor
  23747. * @param upperLimit The upper limit of the motor
  23748. * @param lowerLimit The lower limit of the motor
  23749. * @param motorIndex The index of the motor
  23750. */
  23751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23752. }
  23753. /**
  23754. * Joint data for a Distance-Joint
  23755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23756. */
  23757. export interface DistanceJointData extends PhysicsJointData {
  23758. /**
  23759. * Max distance the 2 joint objects can be apart
  23760. */
  23761. maxDistance: number;
  23762. }
  23763. /**
  23764. * Joint data from a spring joint
  23765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23766. */
  23767. export interface SpringJointData extends PhysicsJointData {
  23768. /**
  23769. * Length of the spring
  23770. */
  23771. length: number;
  23772. /**
  23773. * Stiffness of the spring
  23774. */
  23775. stiffness: number;
  23776. /**
  23777. * Damping of the spring
  23778. */
  23779. damping: number;
  23780. /** this callback will be called when applying the force to the impostors. */
  23781. forceApplicationCallback: () => void;
  23782. }
  23783. }
  23784. declare module BABYLON {
  23785. /**
  23786. * Holds the data for the raycast result
  23787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23788. */
  23789. export class PhysicsRaycastResult {
  23790. private _hasHit;
  23791. private _hitDistance;
  23792. private _hitNormalWorld;
  23793. private _hitPointWorld;
  23794. private _rayFromWorld;
  23795. private _rayToWorld;
  23796. /**
  23797. * Gets if there was a hit
  23798. */
  23799. get hasHit(): boolean;
  23800. /**
  23801. * Gets the distance from the hit
  23802. */
  23803. get hitDistance(): number;
  23804. /**
  23805. * Gets the hit normal/direction in the world
  23806. */
  23807. get hitNormalWorld(): Vector3;
  23808. /**
  23809. * Gets the hit point in the world
  23810. */
  23811. get hitPointWorld(): Vector3;
  23812. /**
  23813. * Gets the ray "start point" of the ray in the world
  23814. */
  23815. get rayFromWorld(): Vector3;
  23816. /**
  23817. * Gets the ray "end point" of the ray in the world
  23818. */
  23819. get rayToWorld(): Vector3;
  23820. /**
  23821. * Sets the hit data (normal & point in world space)
  23822. * @param hitNormalWorld defines the normal in world space
  23823. * @param hitPointWorld defines the point in world space
  23824. */
  23825. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23826. /**
  23827. * Sets the distance from the start point to the hit point
  23828. * @param distance
  23829. */
  23830. setHitDistance(distance: number): void;
  23831. /**
  23832. * Calculates the distance manually
  23833. */
  23834. calculateHitDistance(): void;
  23835. /**
  23836. * Resets all the values to default
  23837. * @param from The from point on world space
  23838. * @param to The to point on world space
  23839. */
  23840. reset(from?: Vector3, to?: Vector3): void;
  23841. }
  23842. /**
  23843. * Interface for the size containing width and height
  23844. */
  23845. interface IXYZ {
  23846. /**
  23847. * X
  23848. */
  23849. x: number;
  23850. /**
  23851. * Y
  23852. */
  23853. y: number;
  23854. /**
  23855. * Z
  23856. */
  23857. z: number;
  23858. }
  23859. }
  23860. declare module BABYLON {
  23861. /**
  23862. * Interface used to describe a physics joint
  23863. */
  23864. export interface PhysicsImpostorJoint {
  23865. /** Defines the main impostor to which the joint is linked */
  23866. mainImpostor: PhysicsImpostor;
  23867. /** Defines the impostor that is connected to the main impostor using this joint */
  23868. connectedImpostor: PhysicsImpostor;
  23869. /** Defines the joint itself */
  23870. joint: PhysicsJoint;
  23871. }
  23872. /** @hidden */
  23873. export interface IPhysicsEnginePlugin {
  23874. world: any;
  23875. name: string;
  23876. setGravity(gravity: Vector3): void;
  23877. setTimeStep(timeStep: number): void;
  23878. getTimeStep(): number;
  23879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23880. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23881. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23882. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23883. removePhysicsBody(impostor: PhysicsImpostor): void;
  23884. generateJoint(joint: PhysicsImpostorJoint): void;
  23885. removeJoint(joint: PhysicsImpostorJoint): void;
  23886. isSupported(): boolean;
  23887. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23888. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23889. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23890. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23892. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23893. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23894. getBodyMass(impostor: PhysicsImpostor): number;
  23895. getBodyFriction(impostor: PhysicsImpostor): number;
  23896. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23897. getBodyRestitution(impostor: PhysicsImpostor): number;
  23898. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23899. getBodyPressure?(impostor: PhysicsImpostor): number;
  23900. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23901. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23902. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23903. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23904. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23905. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23906. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23907. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23908. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23909. sleepBody(impostor: PhysicsImpostor): void;
  23910. wakeUpBody(impostor: PhysicsImpostor): void;
  23911. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23912. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23913. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23914. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23915. getRadius(impostor: PhysicsImpostor): number;
  23916. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23918. dispose(): void;
  23919. }
  23920. /**
  23921. * Interface used to define a physics engine
  23922. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23923. */
  23924. export interface IPhysicsEngine {
  23925. /**
  23926. * Gets the gravity vector used by the simulation
  23927. */
  23928. gravity: Vector3;
  23929. /**
  23930. * Sets the gravity vector used by the simulation
  23931. * @param gravity defines the gravity vector to use
  23932. */
  23933. setGravity(gravity: Vector3): void;
  23934. /**
  23935. * Set the time step of the physics engine.
  23936. * Default is 1/60.
  23937. * To slow it down, enter 1/600 for example.
  23938. * To speed it up, 1/30
  23939. * @param newTimeStep the new timestep to apply to this world.
  23940. */
  23941. setTimeStep(newTimeStep: number): void;
  23942. /**
  23943. * Get the time step of the physics engine.
  23944. * @returns the current time step
  23945. */
  23946. getTimeStep(): number;
  23947. /**
  23948. * Set the sub time step of the physics engine.
  23949. * Default is 0 meaning there is no sub steps
  23950. * To increase physics resolution precision, set a small value (like 1 ms)
  23951. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23952. */
  23953. setSubTimeStep(subTimeStep: number): void;
  23954. /**
  23955. * Get the sub time step of the physics engine.
  23956. * @returns the current sub time step
  23957. */
  23958. getSubTimeStep(): number;
  23959. /**
  23960. * Release all resources
  23961. */
  23962. dispose(): void;
  23963. /**
  23964. * Gets the name of the current physics plugin
  23965. * @returns the name of the plugin
  23966. */
  23967. getPhysicsPluginName(): string;
  23968. /**
  23969. * Adding a new impostor for the impostor tracking.
  23970. * This will be done by the impostor itself.
  23971. * @param impostor the impostor to add
  23972. */
  23973. addImpostor(impostor: PhysicsImpostor): void;
  23974. /**
  23975. * Remove an impostor from the engine.
  23976. * This impostor and its mesh will not longer be updated by the physics engine.
  23977. * @param impostor the impostor to remove
  23978. */
  23979. removeImpostor(impostor: PhysicsImpostor): void;
  23980. /**
  23981. * Add a joint to the physics engine
  23982. * @param mainImpostor defines the main impostor to which the joint is added.
  23983. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23984. * @param joint defines the joint that will connect both impostors.
  23985. */
  23986. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23987. /**
  23988. * Removes a joint from the simulation
  23989. * @param mainImpostor defines the impostor used with the joint
  23990. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23991. * @param joint defines the joint to remove
  23992. */
  23993. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23994. /**
  23995. * Gets the current plugin used to run the simulation
  23996. * @returns current plugin
  23997. */
  23998. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23999. /**
  24000. * Gets the list of physic impostors
  24001. * @returns an array of PhysicsImpostor
  24002. */
  24003. getImpostors(): Array<PhysicsImpostor>;
  24004. /**
  24005. * Gets the impostor for a physics enabled object
  24006. * @param object defines the object impersonated by the impostor
  24007. * @returns the PhysicsImpostor or null if not found
  24008. */
  24009. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24010. /**
  24011. * Gets the impostor for a physics body object
  24012. * @param body defines physics body used by the impostor
  24013. * @returns the PhysicsImpostor or null if not found
  24014. */
  24015. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24016. /**
  24017. * Does a raycast in the physics world
  24018. * @param from when should the ray start?
  24019. * @param to when should the ray end?
  24020. * @returns PhysicsRaycastResult
  24021. */
  24022. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24023. /**
  24024. * Called by the scene. No need to call it.
  24025. * @param delta defines the timespam between frames
  24026. */
  24027. _step(delta: number): void;
  24028. }
  24029. }
  24030. declare module BABYLON {
  24031. /**
  24032. * The interface for the physics imposter parameters
  24033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24034. */
  24035. export interface PhysicsImpostorParameters {
  24036. /**
  24037. * The mass of the physics imposter
  24038. */
  24039. mass: number;
  24040. /**
  24041. * The friction of the physics imposter
  24042. */
  24043. friction?: number;
  24044. /**
  24045. * The coefficient of restitution of the physics imposter
  24046. */
  24047. restitution?: number;
  24048. /**
  24049. * The native options of the physics imposter
  24050. */
  24051. nativeOptions?: any;
  24052. /**
  24053. * Specifies if the parent should be ignored
  24054. */
  24055. ignoreParent?: boolean;
  24056. /**
  24057. * Specifies if bi-directional transformations should be disabled
  24058. */
  24059. disableBidirectionalTransformation?: boolean;
  24060. /**
  24061. * The pressure inside the physics imposter, soft object only
  24062. */
  24063. pressure?: number;
  24064. /**
  24065. * The stiffness the physics imposter, soft object only
  24066. */
  24067. stiffness?: number;
  24068. /**
  24069. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24070. */
  24071. velocityIterations?: number;
  24072. /**
  24073. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24074. */
  24075. positionIterations?: number;
  24076. /**
  24077. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24078. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24079. * Add to fix multiple points
  24080. */
  24081. fixedPoints?: number;
  24082. /**
  24083. * The collision margin around a soft object
  24084. */
  24085. margin?: number;
  24086. /**
  24087. * The collision margin around a soft object
  24088. */
  24089. damping?: number;
  24090. /**
  24091. * The path for a rope based on an extrusion
  24092. */
  24093. path?: any;
  24094. /**
  24095. * The shape of an extrusion used for a rope based on an extrusion
  24096. */
  24097. shape?: any;
  24098. }
  24099. /**
  24100. * Interface for a physics-enabled object
  24101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24102. */
  24103. export interface IPhysicsEnabledObject {
  24104. /**
  24105. * The position of the physics-enabled object
  24106. */
  24107. position: Vector3;
  24108. /**
  24109. * The rotation of the physics-enabled object
  24110. */
  24111. rotationQuaternion: Nullable<Quaternion>;
  24112. /**
  24113. * The scale of the physics-enabled object
  24114. */
  24115. scaling: Vector3;
  24116. /**
  24117. * The rotation of the physics-enabled object
  24118. */
  24119. rotation?: Vector3;
  24120. /**
  24121. * The parent of the physics-enabled object
  24122. */
  24123. parent?: any;
  24124. /**
  24125. * The bounding info of the physics-enabled object
  24126. * @returns The bounding info of the physics-enabled object
  24127. */
  24128. getBoundingInfo(): BoundingInfo;
  24129. /**
  24130. * Computes the world matrix
  24131. * @param force Specifies if the world matrix should be computed by force
  24132. * @returns A world matrix
  24133. */
  24134. computeWorldMatrix(force: boolean): Matrix;
  24135. /**
  24136. * Gets the world matrix
  24137. * @returns A world matrix
  24138. */
  24139. getWorldMatrix?(): Matrix;
  24140. /**
  24141. * Gets the child meshes
  24142. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24143. * @returns An array of abstract meshes
  24144. */
  24145. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24146. /**
  24147. * Gets the vertex data
  24148. * @param kind The type of vertex data
  24149. * @returns A nullable array of numbers, or a float32 array
  24150. */
  24151. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24152. /**
  24153. * Gets the indices from the mesh
  24154. * @returns A nullable array of index arrays
  24155. */
  24156. getIndices?(): Nullable<IndicesArray>;
  24157. /**
  24158. * Gets the scene from the mesh
  24159. * @returns the indices array or null
  24160. */
  24161. getScene?(): Scene;
  24162. /**
  24163. * Gets the absolute position from the mesh
  24164. * @returns the absolute position
  24165. */
  24166. getAbsolutePosition(): Vector3;
  24167. /**
  24168. * Gets the absolute pivot point from the mesh
  24169. * @returns the absolute pivot point
  24170. */
  24171. getAbsolutePivotPoint(): Vector3;
  24172. /**
  24173. * Rotates the mesh
  24174. * @param axis The axis of rotation
  24175. * @param amount The amount of rotation
  24176. * @param space The space of the rotation
  24177. * @returns The rotation transform node
  24178. */
  24179. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24180. /**
  24181. * Translates the mesh
  24182. * @param axis The axis of translation
  24183. * @param distance The distance of translation
  24184. * @param space The space of the translation
  24185. * @returns The transform node
  24186. */
  24187. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24188. /**
  24189. * Sets the absolute position of the mesh
  24190. * @param absolutePosition The absolute position of the mesh
  24191. * @returns The transform node
  24192. */
  24193. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24194. /**
  24195. * Gets the class name of the mesh
  24196. * @returns The class name
  24197. */
  24198. getClassName(): string;
  24199. }
  24200. /**
  24201. * Represents a physics imposter
  24202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24203. */
  24204. export class PhysicsImpostor {
  24205. /**
  24206. * The physics-enabled object used as the physics imposter
  24207. */
  24208. object: IPhysicsEnabledObject;
  24209. /**
  24210. * The type of the physics imposter
  24211. */
  24212. type: number;
  24213. private _options;
  24214. private _scene?;
  24215. /**
  24216. * The default object size of the imposter
  24217. */
  24218. static DEFAULT_OBJECT_SIZE: Vector3;
  24219. /**
  24220. * The identity quaternion of the imposter
  24221. */
  24222. static IDENTITY_QUATERNION: Quaternion;
  24223. /** @hidden */
  24224. _pluginData: any;
  24225. private _physicsEngine;
  24226. private _physicsBody;
  24227. private _bodyUpdateRequired;
  24228. private _onBeforePhysicsStepCallbacks;
  24229. private _onAfterPhysicsStepCallbacks;
  24230. /** @hidden */
  24231. _onPhysicsCollideCallbacks: Array<{
  24232. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24233. otherImpostors: Array<PhysicsImpostor>;
  24234. }>;
  24235. private _deltaPosition;
  24236. private _deltaRotation;
  24237. private _deltaRotationConjugated;
  24238. /** @hidden */
  24239. _isFromLine: boolean;
  24240. private _parent;
  24241. private _isDisposed;
  24242. private static _tmpVecs;
  24243. private static _tmpQuat;
  24244. /**
  24245. * Specifies if the physics imposter is disposed
  24246. */
  24247. get isDisposed(): boolean;
  24248. /**
  24249. * Gets the mass of the physics imposter
  24250. */
  24251. get mass(): number;
  24252. set mass(value: number);
  24253. /**
  24254. * Gets the coefficient of friction
  24255. */
  24256. get friction(): number;
  24257. /**
  24258. * Sets the coefficient of friction
  24259. */
  24260. set friction(value: number);
  24261. /**
  24262. * Gets the coefficient of restitution
  24263. */
  24264. get restitution(): number;
  24265. /**
  24266. * Sets the coefficient of restitution
  24267. */
  24268. set restitution(value: number);
  24269. /**
  24270. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24271. */
  24272. get pressure(): number;
  24273. /**
  24274. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24275. */
  24276. set pressure(value: number);
  24277. /**
  24278. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24279. */
  24280. get stiffness(): number;
  24281. /**
  24282. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24283. */
  24284. set stiffness(value: number);
  24285. /**
  24286. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24287. */
  24288. get velocityIterations(): number;
  24289. /**
  24290. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24291. */
  24292. set velocityIterations(value: number);
  24293. /**
  24294. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24295. */
  24296. get positionIterations(): number;
  24297. /**
  24298. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24299. */
  24300. set positionIterations(value: number);
  24301. /**
  24302. * The unique id of the physics imposter
  24303. * set by the physics engine when adding this impostor to the array
  24304. */
  24305. uniqueId: number;
  24306. /**
  24307. * @hidden
  24308. */
  24309. soft: boolean;
  24310. /**
  24311. * @hidden
  24312. */
  24313. segments: number;
  24314. private _joints;
  24315. /**
  24316. * Initializes the physics imposter
  24317. * @param object The physics-enabled object used as the physics imposter
  24318. * @param type The type of the physics imposter
  24319. * @param _options The options for the physics imposter
  24320. * @param _scene The Babylon scene
  24321. */
  24322. constructor(
  24323. /**
  24324. * The physics-enabled object used as the physics imposter
  24325. */
  24326. object: IPhysicsEnabledObject,
  24327. /**
  24328. * The type of the physics imposter
  24329. */
  24330. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24331. /**
  24332. * This function will completly initialize this impostor.
  24333. * It will create a new body - but only if this mesh has no parent.
  24334. * If it has, this impostor will not be used other than to define the impostor
  24335. * of the child mesh.
  24336. * @hidden
  24337. */
  24338. _init(): void;
  24339. private _getPhysicsParent;
  24340. /**
  24341. * Should a new body be generated.
  24342. * @returns boolean specifying if body initialization is required
  24343. */
  24344. isBodyInitRequired(): boolean;
  24345. /**
  24346. * Sets the updated scaling
  24347. * @param updated Specifies if the scaling is updated
  24348. */
  24349. setScalingUpdated(): void;
  24350. /**
  24351. * Force a regeneration of this or the parent's impostor's body.
  24352. * Use under cautious - This will remove all joints already implemented.
  24353. */
  24354. forceUpdate(): void;
  24355. /**
  24356. * Gets the body that holds this impostor. Either its own, or its parent.
  24357. */
  24358. get physicsBody(): any;
  24359. /**
  24360. * Get the parent of the physics imposter
  24361. * @returns Physics imposter or null
  24362. */
  24363. get parent(): Nullable<PhysicsImpostor>;
  24364. /**
  24365. * Sets the parent of the physics imposter
  24366. */
  24367. set parent(value: Nullable<PhysicsImpostor>);
  24368. /**
  24369. * Set the physics body. Used mainly by the physics engine/plugin
  24370. */
  24371. set physicsBody(physicsBody: any);
  24372. /**
  24373. * Resets the update flags
  24374. */
  24375. resetUpdateFlags(): void;
  24376. /**
  24377. * Gets the object extend size
  24378. * @returns the object extend size
  24379. */
  24380. getObjectExtendSize(): Vector3;
  24381. /**
  24382. * Gets the object center
  24383. * @returns The object center
  24384. */
  24385. getObjectCenter(): Vector3;
  24386. /**
  24387. * Get a specific parameter from the options parameters
  24388. * @param paramName The object parameter name
  24389. * @returns The object parameter
  24390. */
  24391. getParam(paramName: string): any;
  24392. /**
  24393. * Sets a specific parameter in the options given to the physics plugin
  24394. * @param paramName The parameter name
  24395. * @param value The value of the parameter
  24396. */
  24397. setParam(paramName: string, value: number): void;
  24398. /**
  24399. * Specifically change the body's mass option. Won't recreate the physics body object
  24400. * @param mass The mass of the physics imposter
  24401. */
  24402. setMass(mass: number): void;
  24403. /**
  24404. * Gets the linear velocity
  24405. * @returns linear velocity or null
  24406. */
  24407. getLinearVelocity(): Nullable<Vector3>;
  24408. /**
  24409. * Sets the linear velocity
  24410. * @param velocity linear velocity or null
  24411. */
  24412. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24413. /**
  24414. * Gets the angular velocity
  24415. * @returns angular velocity or null
  24416. */
  24417. getAngularVelocity(): Nullable<Vector3>;
  24418. /**
  24419. * Sets the angular velocity
  24420. * @param velocity The velocity or null
  24421. */
  24422. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24423. /**
  24424. * Execute a function with the physics plugin native code
  24425. * Provide a function the will have two variables - the world object and the physics body object
  24426. * @param func The function to execute with the physics plugin native code
  24427. */
  24428. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24429. /**
  24430. * Register a function that will be executed before the physics world is stepping forward
  24431. * @param func The function to execute before the physics world is stepped forward
  24432. */
  24433. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24434. /**
  24435. * Unregister a function that will be executed before the physics world is stepping forward
  24436. * @param func The function to execute before the physics world is stepped forward
  24437. */
  24438. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Register a function that will be executed after the physics step
  24441. * @param func The function to execute after physics step
  24442. */
  24443. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24444. /**
  24445. * Unregisters a function that will be executed after the physics step
  24446. * @param func The function to execute after physics step
  24447. */
  24448. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24449. /**
  24450. * register a function that will be executed when this impostor collides against a different body
  24451. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24452. * @param func Callback that is executed on collision
  24453. */
  24454. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24455. /**
  24456. * Unregisters the physics imposter on contact
  24457. * @param collideAgainst The physics object to collide against
  24458. * @param func Callback to execute on collision
  24459. */
  24460. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24461. private _tmpQuat;
  24462. private _tmpQuat2;
  24463. /**
  24464. * Get the parent rotation
  24465. * @returns The parent rotation
  24466. */
  24467. getParentsRotation(): Quaternion;
  24468. /**
  24469. * this function is executed by the physics engine.
  24470. */
  24471. beforeStep: () => void;
  24472. /**
  24473. * this function is executed by the physics engine
  24474. */
  24475. afterStep: () => void;
  24476. /**
  24477. * Legacy collision detection event support
  24478. */
  24479. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24480. /**
  24481. * event and body object due to cannon's event-based architecture.
  24482. */
  24483. onCollide: (e: {
  24484. body: any;
  24485. }) => void;
  24486. /**
  24487. * Apply a force
  24488. * @param force The force to apply
  24489. * @param contactPoint The contact point for the force
  24490. * @returns The physics imposter
  24491. */
  24492. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24493. /**
  24494. * Apply an impulse
  24495. * @param force The impulse force
  24496. * @param contactPoint The contact point for the impulse force
  24497. * @returns The physics imposter
  24498. */
  24499. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24500. /**
  24501. * A help function to create a joint
  24502. * @param otherImpostor A physics imposter used to create a joint
  24503. * @param jointType The type of joint
  24504. * @param jointData The data for the joint
  24505. * @returns The physics imposter
  24506. */
  24507. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24508. /**
  24509. * Add a joint to this impostor with a different impostor
  24510. * @param otherImpostor A physics imposter used to add a joint
  24511. * @param joint The joint to add
  24512. * @returns The physics imposter
  24513. */
  24514. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24515. /**
  24516. * Add an anchor to a cloth impostor
  24517. * @param otherImpostor rigid impostor to anchor to
  24518. * @param width ratio across width from 0 to 1
  24519. * @param height ratio up height from 0 to 1
  24520. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24521. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24522. * @returns impostor the soft imposter
  24523. */
  24524. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24525. /**
  24526. * Add a hook to a rope impostor
  24527. * @param otherImpostor rigid impostor to anchor to
  24528. * @param length ratio across rope from 0 to 1
  24529. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24530. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24531. * @returns impostor the rope imposter
  24532. */
  24533. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24534. /**
  24535. * Will keep this body still, in a sleep mode.
  24536. * @returns the physics imposter
  24537. */
  24538. sleep(): PhysicsImpostor;
  24539. /**
  24540. * Wake the body up.
  24541. * @returns The physics imposter
  24542. */
  24543. wakeUp(): PhysicsImpostor;
  24544. /**
  24545. * Clones the physics imposter
  24546. * @param newObject The physics imposter clones to this physics-enabled object
  24547. * @returns A nullable physics imposter
  24548. */
  24549. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24550. /**
  24551. * Disposes the physics imposter
  24552. */
  24553. dispose(): void;
  24554. /**
  24555. * Sets the delta position
  24556. * @param position The delta position amount
  24557. */
  24558. setDeltaPosition(position: Vector3): void;
  24559. /**
  24560. * Sets the delta rotation
  24561. * @param rotation The delta rotation amount
  24562. */
  24563. setDeltaRotation(rotation: Quaternion): void;
  24564. /**
  24565. * Gets the box size of the physics imposter and stores the result in the input parameter
  24566. * @param result Stores the box size
  24567. * @returns The physics imposter
  24568. */
  24569. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24570. /**
  24571. * Gets the radius of the physics imposter
  24572. * @returns Radius of the physics imposter
  24573. */
  24574. getRadius(): number;
  24575. /**
  24576. * Sync a bone with this impostor
  24577. * @param bone The bone to sync to the impostor.
  24578. * @param boneMesh The mesh that the bone is influencing.
  24579. * @param jointPivot The pivot of the joint / bone in local space.
  24580. * @param distToJoint Optional distance from the impostor to the joint.
  24581. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24582. */
  24583. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24584. /**
  24585. * Sync impostor to a bone
  24586. * @param bone The bone that the impostor will be synced to.
  24587. * @param boneMesh The mesh that the bone is influencing.
  24588. * @param jointPivot The pivot of the joint / bone in local space.
  24589. * @param distToJoint Optional distance from the impostor to the joint.
  24590. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24591. * @param boneAxis Optional vector3 axis the bone is aligned with
  24592. */
  24593. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24594. /**
  24595. * No-Imposter type
  24596. */
  24597. static NoImpostor: number;
  24598. /**
  24599. * Sphere-Imposter type
  24600. */
  24601. static SphereImpostor: number;
  24602. /**
  24603. * Box-Imposter type
  24604. */
  24605. static BoxImpostor: number;
  24606. /**
  24607. * Plane-Imposter type
  24608. */
  24609. static PlaneImpostor: number;
  24610. /**
  24611. * Mesh-imposter type
  24612. */
  24613. static MeshImpostor: number;
  24614. /**
  24615. * Capsule-Impostor type (Ammo.js plugin only)
  24616. */
  24617. static CapsuleImpostor: number;
  24618. /**
  24619. * Cylinder-Imposter type
  24620. */
  24621. static CylinderImpostor: number;
  24622. /**
  24623. * Particle-Imposter type
  24624. */
  24625. static ParticleImpostor: number;
  24626. /**
  24627. * Heightmap-Imposter type
  24628. */
  24629. static HeightmapImpostor: number;
  24630. /**
  24631. * ConvexHull-Impostor type (Ammo.js plugin only)
  24632. */
  24633. static ConvexHullImpostor: number;
  24634. /**
  24635. * Custom-Imposter type (Ammo.js plugin only)
  24636. */
  24637. static CustomImpostor: number;
  24638. /**
  24639. * Rope-Imposter type
  24640. */
  24641. static RopeImpostor: number;
  24642. /**
  24643. * Cloth-Imposter type
  24644. */
  24645. static ClothImpostor: number;
  24646. /**
  24647. * Softbody-Imposter type
  24648. */
  24649. static SoftbodyImpostor: number;
  24650. }
  24651. }
  24652. declare module BABYLON {
  24653. /**
  24654. * @hidden
  24655. **/
  24656. export class _CreationDataStorage {
  24657. closePath?: boolean;
  24658. closeArray?: boolean;
  24659. idx: number[];
  24660. dashSize: number;
  24661. gapSize: number;
  24662. path3D: Path3D;
  24663. pathArray: Vector3[][];
  24664. arc: number;
  24665. radius: number;
  24666. cap: number;
  24667. tessellation: number;
  24668. }
  24669. /**
  24670. * @hidden
  24671. **/
  24672. class _InstanceDataStorage {
  24673. visibleInstances: any;
  24674. batchCache: _InstancesBatch;
  24675. instancesBufferSize: number;
  24676. instancesBuffer: Nullable<Buffer>;
  24677. instancesData: Float32Array;
  24678. overridenInstanceCount: number;
  24679. isFrozen: boolean;
  24680. previousBatch: Nullable<_InstancesBatch>;
  24681. hardwareInstancedRendering: boolean;
  24682. sideOrientation: number;
  24683. manualUpdate: boolean;
  24684. }
  24685. /**
  24686. * @hidden
  24687. **/
  24688. export class _InstancesBatch {
  24689. mustReturn: boolean;
  24690. visibleInstances: Nullable<InstancedMesh[]>[];
  24691. renderSelf: boolean[];
  24692. hardwareInstancedRendering: boolean[];
  24693. }
  24694. /**
  24695. * Class used to represent renderable models
  24696. */
  24697. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24698. /**
  24699. * Mesh side orientation : usually the external or front surface
  24700. */
  24701. static readonly FRONTSIDE: number;
  24702. /**
  24703. * Mesh side orientation : usually the internal or back surface
  24704. */
  24705. static readonly BACKSIDE: number;
  24706. /**
  24707. * Mesh side orientation : both internal and external or front and back surfaces
  24708. */
  24709. static readonly DOUBLESIDE: number;
  24710. /**
  24711. * Mesh side orientation : by default, `FRONTSIDE`
  24712. */
  24713. static readonly DEFAULTSIDE: number;
  24714. /**
  24715. * Mesh cap setting : no cap
  24716. */
  24717. static readonly NO_CAP: number;
  24718. /**
  24719. * Mesh cap setting : one cap at the beginning of the mesh
  24720. */
  24721. static readonly CAP_START: number;
  24722. /**
  24723. * Mesh cap setting : one cap at the end of the mesh
  24724. */
  24725. static readonly CAP_END: number;
  24726. /**
  24727. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24728. */
  24729. static readonly CAP_ALL: number;
  24730. /**
  24731. * Mesh pattern setting : no flip or rotate
  24732. */
  24733. static readonly NO_FLIP: number;
  24734. /**
  24735. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24736. */
  24737. static readonly FLIP_TILE: number;
  24738. /**
  24739. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24740. */
  24741. static readonly ROTATE_TILE: number;
  24742. /**
  24743. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24744. */
  24745. static readonly FLIP_ROW: number;
  24746. /**
  24747. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24748. */
  24749. static readonly ROTATE_ROW: number;
  24750. /**
  24751. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24752. */
  24753. static readonly FLIP_N_ROTATE_TILE: number;
  24754. /**
  24755. * Mesh pattern setting : rotate pattern and rotate
  24756. */
  24757. static readonly FLIP_N_ROTATE_ROW: number;
  24758. /**
  24759. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24760. */
  24761. static readonly CENTER: number;
  24762. /**
  24763. * Mesh tile positioning : part tiles on left
  24764. */
  24765. static readonly LEFT: number;
  24766. /**
  24767. * Mesh tile positioning : part tiles on right
  24768. */
  24769. static readonly RIGHT: number;
  24770. /**
  24771. * Mesh tile positioning : part tiles on top
  24772. */
  24773. static readonly TOP: number;
  24774. /**
  24775. * Mesh tile positioning : part tiles on bottom
  24776. */
  24777. static readonly BOTTOM: number;
  24778. /**
  24779. * Gets the default side orientation.
  24780. * @param orientation the orientation to value to attempt to get
  24781. * @returns the default orientation
  24782. * @hidden
  24783. */
  24784. static _GetDefaultSideOrientation(orientation?: number): number;
  24785. private _internalMeshDataInfo;
  24786. /**
  24787. * An event triggered before rendering the mesh
  24788. */
  24789. get onBeforeRenderObservable(): Observable<Mesh>;
  24790. /**
  24791. * An event triggered before binding the mesh
  24792. */
  24793. get onBeforeBindObservable(): Observable<Mesh>;
  24794. /**
  24795. * An event triggered after rendering the mesh
  24796. */
  24797. get onAfterRenderObservable(): Observable<Mesh>;
  24798. /**
  24799. * An event triggered before drawing the mesh
  24800. */
  24801. get onBeforeDrawObservable(): Observable<Mesh>;
  24802. private _onBeforeDrawObserver;
  24803. /**
  24804. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24805. */
  24806. set onBeforeDraw(callback: () => void);
  24807. get hasInstances(): boolean;
  24808. /**
  24809. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24810. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24811. */
  24812. delayLoadState: number;
  24813. /**
  24814. * Gets the list of instances created from this mesh
  24815. * it is not supposed to be modified manually.
  24816. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24817. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24818. */
  24819. instances: InstancedMesh[];
  24820. /**
  24821. * Gets the file containing delay loading data for this mesh
  24822. */
  24823. delayLoadingFile: string;
  24824. /** @hidden */
  24825. _binaryInfo: any;
  24826. /**
  24827. * User defined function used to change how LOD level selection is done
  24828. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24829. */
  24830. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24831. /**
  24832. * Gets or sets the morph target manager
  24833. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24834. */
  24835. get morphTargetManager(): Nullable<MorphTargetManager>;
  24836. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24837. /** @hidden */
  24838. _creationDataStorage: Nullable<_CreationDataStorage>;
  24839. /** @hidden */
  24840. _geometry: Nullable<Geometry>;
  24841. /** @hidden */
  24842. _delayInfo: Array<string>;
  24843. /** @hidden */
  24844. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24845. /** @hidden */
  24846. _instanceDataStorage: _InstanceDataStorage;
  24847. private _effectiveMaterial;
  24848. /** @hidden */
  24849. _shouldGenerateFlatShading: boolean;
  24850. /** @hidden */
  24851. _originalBuilderSideOrientation: number;
  24852. /**
  24853. * Use this property to change the original side orientation defined at construction time
  24854. */
  24855. overrideMaterialSideOrientation: Nullable<number>;
  24856. /**
  24857. * Gets the source mesh (the one used to clone this one from)
  24858. */
  24859. get source(): Nullable<Mesh>;
  24860. /**
  24861. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24862. */
  24863. get isUnIndexed(): boolean;
  24864. set isUnIndexed(value: boolean);
  24865. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24866. get worldMatrixInstancedBuffer(): Float32Array;
  24867. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24868. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24869. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24870. /**
  24871. * @constructor
  24872. * @param name The value used by scene.getMeshByName() to do a lookup.
  24873. * @param scene The scene to add this mesh to.
  24874. * @param parent The parent of this mesh, if it has one
  24875. * @param source An optional Mesh from which geometry is shared, cloned.
  24876. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24877. * When false, achieved by calling a clone(), also passing False.
  24878. * This will make creation of children, recursive.
  24879. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24880. */
  24881. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24882. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24883. doNotInstantiate: boolean;
  24884. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24885. /**
  24886. * Gets the class name
  24887. * @returns the string "Mesh".
  24888. */
  24889. getClassName(): string;
  24890. /** @hidden */
  24891. get _isMesh(): boolean;
  24892. /**
  24893. * Returns a description of this mesh
  24894. * @param fullDetails define if full details about this mesh must be used
  24895. * @returns a descriptive string representing this mesh
  24896. */
  24897. toString(fullDetails?: boolean): string;
  24898. /** @hidden */
  24899. _unBindEffect(): void;
  24900. /**
  24901. * Gets a boolean indicating if this mesh has LOD
  24902. */
  24903. get hasLODLevels(): boolean;
  24904. /**
  24905. * Gets the list of MeshLODLevel associated with the current mesh
  24906. * @returns an array of MeshLODLevel
  24907. */
  24908. getLODLevels(): MeshLODLevel[];
  24909. private _sortLODLevels;
  24910. /**
  24911. * Add a mesh as LOD level triggered at the given distance.
  24912. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24913. * @param distance The distance from the center of the object to show this level
  24914. * @param mesh The mesh to be added as LOD level (can be null)
  24915. * @return This mesh (for chaining)
  24916. */
  24917. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24918. /**
  24919. * Returns the LOD level mesh at the passed distance or null if not found.
  24920. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24921. * @param distance The distance from the center of the object to show this level
  24922. * @returns a Mesh or `null`
  24923. */
  24924. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24925. /**
  24926. * Remove a mesh from the LOD array
  24927. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24928. * @param mesh defines the mesh to be removed
  24929. * @return This mesh (for chaining)
  24930. */
  24931. removeLODLevel(mesh: Mesh): Mesh;
  24932. /**
  24933. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24934. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24935. * @param camera defines the camera to use to compute distance
  24936. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24937. * @return This mesh (for chaining)
  24938. */
  24939. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24940. /**
  24941. * Gets the mesh internal Geometry object
  24942. */
  24943. get geometry(): Nullable<Geometry>;
  24944. /**
  24945. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24946. * @returns the total number of vertices
  24947. */
  24948. getTotalVertices(): number;
  24949. /**
  24950. * Returns the content of an associated vertex buffer
  24951. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24952. * - VertexBuffer.PositionKind
  24953. * - VertexBuffer.UVKind
  24954. * - VertexBuffer.UV2Kind
  24955. * - VertexBuffer.UV3Kind
  24956. * - VertexBuffer.UV4Kind
  24957. * - VertexBuffer.UV5Kind
  24958. * - VertexBuffer.UV6Kind
  24959. * - VertexBuffer.ColorKind
  24960. * - VertexBuffer.MatricesIndicesKind
  24961. * - VertexBuffer.MatricesIndicesExtraKind
  24962. * - VertexBuffer.MatricesWeightsKind
  24963. * - VertexBuffer.MatricesWeightsExtraKind
  24964. * @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
  24965. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24966. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24967. */
  24968. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24969. /**
  24970. * Returns the mesh VertexBuffer object from the requested `kind`
  24971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24972. * - VertexBuffer.PositionKind
  24973. * - VertexBuffer.NormalKind
  24974. * - VertexBuffer.UVKind
  24975. * - VertexBuffer.UV2Kind
  24976. * - VertexBuffer.UV3Kind
  24977. * - VertexBuffer.UV4Kind
  24978. * - VertexBuffer.UV5Kind
  24979. * - VertexBuffer.UV6Kind
  24980. * - VertexBuffer.ColorKind
  24981. * - VertexBuffer.MatricesIndicesKind
  24982. * - VertexBuffer.MatricesIndicesExtraKind
  24983. * - VertexBuffer.MatricesWeightsKind
  24984. * - VertexBuffer.MatricesWeightsExtraKind
  24985. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24986. */
  24987. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24988. /**
  24989. * Tests if a specific vertex buffer is associated with this mesh
  24990. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24991. * - VertexBuffer.PositionKind
  24992. * - VertexBuffer.NormalKind
  24993. * - VertexBuffer.UVKind
  24994. * - VertexBuffer.UV2Kind
  24995. * - VertexBuffer.UV3Kind
  24996. * - VertexBuffer.UV4Kind
  24997. * - VertexBuffer.UV5Kind
  24998. * - VertexBuffer.UV6Kind
  24999. * - VertexBuffer.ColorKind
  25000. * - VertexBuffer.MatricesIndicesKind
  25001. * - VertexBuffer.MatricesIndicesExtraKind
  25002. * - VertexBuffer.MatricesWeightsKind
  25003. * - VertexBuffer.MatricesWeightsExtraKind
  25004. * @returns a boolean
  25005. */
  25006. isVerticesDataPresent(kind: string): boolean;
  25007. /**
  25008. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25009. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25010. * - VertexBuffer.PositionKind
  25011. * - VertexBuffer.UVKind
  25012. * - VertexBuffer.UV2Kind
  25013. * - VertexBuffer.UV3Kind
  25014. * - VertexBuffer.UV4Kind
  25015. * - VertexBuffer.UV5Kind
  25016. * - VertexBuffer.UV6Kind
  25017. * - VertexBuffer.ColorKind
  25018. * - VertexBuffer.MatricesIndicesKind
  25019. * - VertexBuffer.MatricesIndicesExtraKind
  25020. * - VertexBuffer.MatricesWeightsKind
  25021. * - VertexBuffer.MatricesWeightsExtraKind
  25022. * @returns a boolean
  25023. */
  25024. isVertexBufferUpdatable(kind: string): boolean;
  25025. /**
  25026. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25027. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25028. * - VertexBuffer.PositionKind
  25029. * - VertexBuffer.NormalKind
  25030. * - VertexBuffer.UVKind
  25031. * - VertexBuffer.UV2Kind
  25032. * - VertexBuffer.UV3Kind
  25033. * - VertexBuffer.UV4Kind
  25034. * - VertexBuffer.UV5Kind
  25035. * - VertexBuffer.UV6Kind
  25036. * - VertexBuffer.ColorKind
  25037. * - VertexBuffer.MatricesIndicesKind
  25038. * - VertexBuffer.MatricesIndicesExtraKind
  25039. * - VertexBuffer.MatricesWeightsKind
  25040. * - VertexBuffer.MatricesWeightsExtraKind
  25041. * @returns an array of strings
  25042. */
  25043. getVerticesDataKinds(): string[];
  25044. /**
  25045. * Returns a positive integer : the total number of indices in this mesh geometry.
  25046. * @returns the numner of indices or zero if the mesh has no geometry.
  25047. */
  25048. getTotalIndices(): number;
  25049. /**
  25050. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25051. * @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.
  25052. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25053. * @returns the indices array or an empty array if the mesh has no geometry
  25054. */
  25055. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25056. get isBlocked(): boolean;
  25057. /**
  25058. * Determine if the current mesh is ready to be rendered
  25059. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25060. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25061. * @returns true if all associated assets are ready (material, textures, shaders)
  25062. */
  25063. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25064. /**
  25065. * 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.
  25066. */
  25067. get areNormalsFrozen(): boolean;
  25068. /**
  25069. * 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.
  25070. * @returns the current mesh
  25071. */
  25072. freezeNormals(): Mesh;
  25073. /**
  25074. * 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
  25075. * @returns the current mesh
  25076. */
  25077. unfreezeNormals(): Mesh;
  25078. /**
  25079. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25080. */
  25081. set overridenInstanceCount(count: number);
  25082. /** @hidden */
  25083. _preActivate(): Mesh;
  25084. /** @hidden */
  25085. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25086. /** @hidden */
  25087. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25088. /**
  25089. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25090. * This means the mesh underlying bounding box and sphere are recomputed.
  25091. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25092. * @returns the current mesh
  25093. */
  25094. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25095. /** @hidden */
  25096. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25097. /**
  25098. * This function will subdivide the mesh into multiple submeshes
  25099. * @param count defines the expected number of submeshes
  25100. */
  25101. subdivide(count: number): void;
  25102. /**
  25103. * Copy a FloatArray into a specific associated vertex buffer
  25104. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25105. * - VertexBuffer.PositionKind
  25106. * - VertexBuffer.UVKind
  25107. * - VertexBuffer.UV2Kind
  25108. * - VertexBuffer.UV3Kind
  25109. * - VertexBuffer.UV4Kind
  25110. * - VertexBuffer.UV5Kind
  25111. * - VertexBuffer.UV6Kind
  25112. * - VertexBuffer.ColorKind
  25113. * - VertexBuffer.MatricesIndicesKind
  25114. * - VertexBuffer.MatricesIndicesExtraKind
  25115. * - VertexBuffer.MatricesWeightsKind
  25116. * - VertexBuffer.MatricesWeightsExtraKind
  25117. * @param data defines the data source
  25118. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25119. * @param stride defines the data stride size (can be null)
  25120. * @returns the current mesh
  25121. */
  25122. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25123. /**
  25124. * Delete a vertex buffer associated with this mesh
  25125. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25126. * - VertexBuffer.PositionKind
  25127. * - VertexBuffer.UVKind
  25128. * - VertexBuffer.UV2Kind
  25129. * - VertexBuffer.UV3Kind
  25130. * - VertexBuffer.UV4Kind
  25131. * - VertexBuffer.UV5Kind
  25132. * - VertexBuffer.UV6Kind
  25133. * - VertexBuffer.ColorKind
  25134. * - VertexBuffer.MatricesIndicesKind
  25135. * - VertexBuffer.MatricesIndicesExtraKind
  25136. * - VertexBuffer.MatricesWeightsKind
  25137. * - VertexBuffer.MatricesWeightsExtraKind
  25138. */
  25139. removeVerticesData(kind: string): void;
  25140. /**
  25141. * Flags an associated vertex buffer as updatable
  25142. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25143. * - VertexBuffer.PositionKind
  25144. * - VertexBuffer.UVKind
  25145. * - VertexBuffer.UV2Kind
  25146. * - VertexBuffer.UV3Kind
  25147. * - VertexBuffer.UV4Kind
  25148. * - VertexBuffer.UV5Kind
  25149. * - VertexBuffer.UV6Kind
  25150. * - VertexBuffer.ColorKind
  25151. * - VertexBuffer.MatricesIndicesKind
  25152. * - VertexBuffer.MatricesIndicesExtraKind
  25153. * - VertexBuffer.MatricesWeightsKind
  25154. * - VertexBuffer.MatricesWeightsExtraKind
  25155. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25156. */
  25157. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25158. /**
  25159. * Sets the mesh global Vertex Buffer
  25160. * @param buffer defines the buffer to use
  25161. * @returns the current mesh
  25162. */
  25163. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25164. /**
  25165. * Update a specific associated vertex buffer
  25166. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25167. * - VertexBuffer.PositionKind
  25168. * - VertexBuffer.UVKind
  25169. * - VertexBuffer.UV2Kind
  25170. * - VertexBuffer.UV3Kind
  25171. * - VertexBuffer.UV4Kind
  25172. * - VertexBuffer.UV5Kind
  25173. * - VertexBuffer.UV6Kind
  25174. * - VertexBuffer.ColorKind
  25175. * - VertexBuffer.MatricesIndicesKind
  25176. * - VertexBuffer.MatricesIndicesExtraKind
  25177. * - VertexBuffer.MatricesWeightsKind
  25178. * - VertexBuffer.MatricesWeightsExtraKind
  25179. * @param data defines the data source
  25180. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25181. * @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)
  25182. * @returns the current mesh
  25183. */
  25184. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25185. /**
  25186. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25187. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25188. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25189. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25190. * @returns the current mesh
  25191. */
  25192. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25193. /**
  25194. * Creates a un-shared specific occurence of the geometry for the mesh.
  25195. * @returns the current mesh
  25196. */
  25197. makeGeometryUnique(): Mesh;
  25198. /**
  25199. * Set the index buffer of this mesh
  25200. * @param indices defines the source data
  25201. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25202. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25203. * @returns the current mesh
  25204. */
  25205. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25206. /**
  25207. * Update the current index buffer
  25208. * @param indices defines the source data
  25209. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25210. * @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)
  25211. * @returns the current mesh
  25212. */
  25213. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25214. /**
  25215. * Invert the geometry to move from a right handed system to a left handed one.
  25216. * @returns the current mesh
  25217. */
  25218. toLeftHanded(): Mesh;
  25219. /** @hidden */
  25220. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25221. /** @hidden */
  25222. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25223. /**
  25224. * Registers for this mesh a javascript function called just before the rendering process
  25225. * @param func defines the function to call before rendering this mesh
  25226. * @returns the current mesh
  25227. */
  25228. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25229. /**
  25230. * Disposes a previously registered javascript function called before the rendering
  25231. * @param func defines the function to remove
  25232. * @returns the current mesh
  25233. */
  25234. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25235. /**
  25236. * Registers for this mesh a javascript function called just after the rendering is complete
  25237. * @param func defines the function to call after rendering this mesh
  25238. * @returns the current mesh
  25239. */
  25240. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25241. /**
  25242. * Disposes a previously registered javascript function called after the rendering.
  25243. * @param func defines the function to remove
  25244. * @returns the current mesh
  25245. */
  25246. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25247. /** @hidden */
  25248. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25249. /** @hidden */
  25250. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25251. /** @hidden */
  25252. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25253. /** @hidden */
  25254. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25255. /** @hidden */
  25256. _rebuild(): void;
  25257. /** @hidden */
  25258. _freeze(): void;
  25259. /** @hidden */
  25260. _unFreeze(): void;
  25261. /**
  25262. * 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
  25263. * @param subMesh defines the subMesh to render
  25264. * @param enableAlphaMode defines if alpha mode can be changed
  25265. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25266. * @returns the current mesh
  25267. */
  25268. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25269. private _onBeforeDraw;
  25270. /**
  25271. * Renormalize the mesh and patch it up if there are no weights
  25272. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25273. * However in the case of zero weights then we set just a single influence to 1.
  25274. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25275. */
  25276. cleanMatrixWeights(): void;
  25277. private normalizeSkinFourWeights;
  25278. private normalizeSkinWeightsAndExtra;
  25279. /**
  25280. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25281. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25282. * the user know there was an issue with importing the mesh
  25283. * @returns a validation object with skinned, valid and report string
  25284. */
  25285. validateSkinning(): {
  25286. skinned: boolean;
  25287. valid: boolean;
  25288. report: string;
  25289. };
  25290. /** @hidden */
  25291. _checkDelayState(): Mesh;
  25292. private _queueLoad;
  25293. /**
  25294. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25295. * A mesh is in the frustum if its bounding box intersects the frustum
  25296. * @param frustumPlanes defines the frustum to test
  25297. * @returns true if the mesh is in the frustum planes
  25298. */
  25299. isInFrustum(frustumPlanes: Plane[]): boolean;
  25300. /**
  25301. * Sets the mesh material by the material or multiMaterial `id` property
  25302. * @param id is a string identifying the material or the multiMaterial
  25303. * @returns the current mesh
  25304. */
  25305. setMaterialByID(id: string): Mesh;
  25306. /**
  25307. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25308. * @returns an array of IAnimatable
  25309. */
  25310. getAnimatables(): IAnimatable[];
  25311. /**
  25312. * Modifies the mesh geometry according to the passed transformation matrix.
  25313. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25314. * The mesh normals are modified using the same transformation.
  25315. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25316. * @param transform defines the transform matrix to use
  25317. * @see http://doc.babylonjs.com/resources/baking_transformations
  25318. * @returns the current mesh
  25319. */
  25320. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25321. /**
  25322. * Modifies the mesh geometry according to its own current World Matrix.
  25323. * The mesh World Matrix is then reset.
  25324. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25325. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25326. * @see http://doc.babylonjs.com/resources/baking_transformations
  25327. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25328. * @returns the current mesh
  25329. */
  25330. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25331. /** @hidden */
  25332. get _positions(): Nullable<Vector3[]>;
  25333. /** @hidden */
  25334. _resetPointsArrayCache(): Mesh;
  25335. /** @hidden */
  25336. _generatePointsArray(): boolean;
  25337. /**
  25338. * Returns a new Mesh object generated from the current mesh properties.
  25339. * This method must not get confused with createInstance()
  25340. * @param name is a string, the name given to the new mesh
  25341. * @param newParent can be any Node object (default `null`)
  25342. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25343. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25344. * @returns a new mesh
  25345. */
  25346. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25347. /**
  25348. * Releases resources associated with this mesh.
  25349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25351. */
  25352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25353. /** @hidden */
  25354. _disposeInstanceSpecificData(): void;
  25355. /**
  25356. * Modifies the mesh geometry according to a displacement map.
  25357. * 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.
  25358. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25359. * @param url is a string, the URL from the image file is to be downloaded.
  25360. * @param minHeight is the lower limit of the displacement.
  25361. * @param maxHeight is the upper limit of the displacement.
  25362. * @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.
  25363. * @param uvOffset is an optional vector2 used to offset UV.
  25364. * @param uvScale is an optional vector2 used to scale UV.
  25365. * @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.
  25366. * @returns the Mesh.
  25367. */
  25368. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25369. /**
  25370. * Modifies the mesh geometry according to a displacementMap buffer.
  25371. * 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.
  25372. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25373. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25374. * @param heightMapWidth is the width of the buffer image.
  25375. * @param heightMapHeight is the height of the buffer image.
  25376. * @param minHeight is the lower limit of the displacement.
  25377. * @param maxHeight is the upper limit of the displacement.
  25378. * @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.
  25379. * @param uvOffset is an optional vector2 used to offset UV.
  25380. * @param uvScale is an optional vector2 used to scale UV.
  25381. * @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.
  25382. * @returns the Mesh.
  25383. */
  25384. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25385. /**
  25386. * Modify the mesh to get a flat shading rendering.
  25387. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25388. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25389. * @returns current mesh
  25390. */
  25391. convertToFlatShadedMesh(): Mesh;
  25392. /**
  25393. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25394. * In other words, more vertices, no more indices and a single bigger VBO.
  25395. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25396. * @returns current mesh
  25397. */
  25398. convertToUnIndexedMesh(): Mesh;
  25399. /**
  25400. * Inverses facet orientations.
  25401. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25402. * @param flipNormals will also inverts the normals
  25403. * @returns current mesh
  25404. */
  25405. flipFaces(flipNormals?: boolean): Mesh;
  25406. /**
  25407. * Increase the number of facets and hence vertices in a mesh
  25408. * Vertex normals are interpolated from existing vertex normals
  25409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25410. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25411. */
  25412. increaseVertices(numberPerEdge: number): void;
  25413. /**
  25414. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25415. * This will undo any application of covertToFlatShadedMesh
  25416. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25417. */
  25418. forceSharedVertices(): void;
  25419. /** @hidden */
  25420. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25421. /** @hidden */
  25422. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25423. /**
  25424. * Creates a new InstancedMesh object from the mesh model.
  25425. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25426. * @param name defines the name of the new instance
  25427. * @returns a new InstancedMesh
  25428. */
  25429. createInstance(name: string): InstancedMesh;
  25430. /**
  25431. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25432. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25433. * @returns the current mesh
  25434. */
  25435. synchronizeInstances(): Mesh;
  25436. /**
  25437. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25438. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25439. * This should be used together with the simplification to avoid disappearing triangles.
  25440. * @param successCallback an optional success callback to be called after the optimization finished.
  25441. * @returns the current mesh
  25442. */
  25443. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25444. /**
  25445. * Serialize current mesh
  25446. * @param serializationObject defines the object which will receive the serialization data
  25447. */
  25448. serialize(serializationObject: any): void;
  25449. /** @hidden */
  25450. _syncGeometryWithMorphTargetManager(): void;
  25451. /** @hidden */
  25452. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25453. /**
  25454. * Returns a new Mesh object parsed from the source provided.
  25455. * @param parsedMesh is the source
  25456. * @param scene defines the hosting scene
  25457. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25458. * @returns a new Mesh
  25459. */
  25460. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25461. /**
  25462. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25463. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25464. * @param name defines the name of the mesh to create
  25465. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25466. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25467. * @param closePath creates a seam between the first and the last points of each path of the path array
  25468. * @param offset is taken in account only if the `pathArray` is containing a single path
  25469. * @param scene defines the hosting scene
  25470. * @param updatable defines if the mesh must be flagged as updatable
  25471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25472. * @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)
  25473. * @returns a new Mesh
  25474. */
  25475. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25476. /**
  25477. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25478. * @param name defines the name of the mesh to create
  25479. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25480. * @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
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @returns a new Mesh
  25485. */
  25486. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25487. /**
  25488. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25489. * @param name defines the name of the mesh to create
  25490. * @param size sets the size (float) of each box side (default 1)
  25491. * @param scene defines the hosting scene
  25492. * @param updatable defines if the mesh must be flagged as updatable
  25493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25494. * @returns a new Mesh
  25495. */
  25496. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25497. /**
  25498. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25499. * @param name defines the name of the mesh to create
  25500. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25501. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25505. * @returns a new Mesh
  25506. */
  25507. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25508. /**
  25509. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25510. * @param name defines the name of the mesh to create
  25511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25513. * @param scene defines the hosting scene
  25514. * @returns a new Mesh
  25515. */
  25516. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25517. /**
  25518. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25519. * @param name defines the name of the mesh to create
  25520. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25521. * @param diameterTop set the top cap diameter (floats, default 1)
  25522. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25523. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25524. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25525. * @param scene defines the hosting scene
  25526. * @param updatable defines if the mesh must be flagged as updatable
  25527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25528. * @returns a new Mesh
  25529. */
  25530. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25531. /**
  25532. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25533. * @param name defines the name of the mesh to create
  25534. * @param diameter sets the diameter size (float) of the torus (default 1)
  25535. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25536. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25537. * @param scene defines the hosting scene
  25538. * @param updatable defines if the mesh must be flagged as updatable
  25539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25540. * @returns a new Mesh
  25541. */
  25542. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25543. /**
  25544. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25545. * @param name defines the name of the mesh to create
  25546. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25547. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25548. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25549. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25550. * @param p the number of windings on X axis (positive integers, default 2)
  25551. * @param q the number of windings on Y axis (positive integers, default 3)
  25552. * @param scene defines the hosting scene
  25553. * @param updatable defines if the mesh must be flagged as updatable
  25554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25555. * @returns a new Mesh
  25556. */
  25557. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25558. /**
  25559. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25560. * @param name defines the name of the mesh to create
  25561. * @param points is an array successive Vector3
  25562. * @param scene defines the hosting scene
  25563. * @param updatable defines if the mesh must be flagged as updatable
  25564. * @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).
  25565. * @returns a new Mesh
  25566. */
  25567. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25568. /**
  25569. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25570. * @param name defines the name of the mesh to create
  25571. * @param points is an array successive Vector3
  25572. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25573. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25574. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25575. * @param scene defines the hosting scene
  25576. * @param updatable defines if the mesh must be flagged as updatable
  25577. * @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)
  25578. * @returns a new Mesh
  25579. */
  25580. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25581. /**
  25582. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25583. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25584. * 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.
  25585. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25586. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25587. * Remember you can only change the shape positions, not their number when updating a polygon.
  25588. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25589. * @param name defines the name of the mesh to create
  25590. * @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
  25591. * @param scene defines the hosting scene
  25592. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25593. * @param updatable defines if the mesh must be flagged as updatable
  25594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25595. * @param earcutInjection can be used to inject your own earcut reference
  25596. * @returns a new Mesh
  25597. */
  25598. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25599. /**
  25600. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25601. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25602. * @param name defines the name of the mesh to create
  25603. * @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
  25604. * @param depth defines the height of extrusion
  25605. * @param scene defines the hosting scene
  25606. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25607. * @param updatable defines if the mesh must be flagged as updatable
  25608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25609. * @param earcutInjection can be used to inject your own earcut reference
  25610. * @returns a new Mesh
  25611. */
  25612. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25613. /**
  25614. * Creates an extruded shape mesh.
  25615. * 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
  25616. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25618. * @param name defines the name of the mesh to create
  25619. * @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
  25620. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25621. * @param scale is the value to scale the shape
  25622. * @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
  25623. * @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
  25624. * @param scene defines the hosting scene
  25625. * @param updatable defines if the mesh must be flagged as updatable
  25626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25627. * @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)
  25628. * @returns a new Mesh
  25629. */
  25630. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25631. /**
  25632. * Creates an custom extruded shape mesh.
  25633. * The custom extrusion is a parametric shape.
  25634. * It has no predefined shape. Its final shape will depend on the input parameters.
  25635. * Please consider using the same method from the MeshBuilder class instead
  25636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25637. * @param name defines the name of the mesh to create
  25638. * @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
  25639. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25640. * @param scaleFunction is a custom Javascript function called on each path point
  25641. * @param rotationFunction is a custom Javascript function called on each path point
  25642. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25643. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25644. * @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
  25645. * @param scene defines the hosting scene
  25646. * @param updatable defines if the mesh must be flagged as updatable
  25647. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25648. * @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)
  25649. * @returns a new Mesh
  25650. */
  25651. 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;
  25652. /**
  25653. * Creates lathe mesh.
  25654. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25655. * Please consider using the same method from the MeshBuilder class instead
  25656. * @param name defines the name of the mesh to create
  25657. * @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
  25658. * @param radius is the radius value of the lathe
  25659. * @param tessellation is the side number of the lathe.
  25660. * @param scene defines the hosting scene
  25661. * @param updatable defines if the mesh must be flagged as updatable
  25662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25663. * @returns a new Mesh
  25664. */
  25665. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25666. /**
  25667. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25668. * @param name defines the name of the mesh to create
  25669. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25670. * @param scene defines the hosting scene
  25671. * @param updatable defines if the mesh must be flagged as updatable
  25672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25673. * @returns a new Mesh
  25674. */
  25675. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25676. /**
  25677. * Creates a ground mesh.
  25678. * Please consider using the same method from the MeshBuilder class instead
  25679. * @param name defines the name of the mesh to create
  25680. * @param width set the width of the ground
  25681. * @param height set the height of the ground
  25682. * @param subdivisions sets the number of subdivisions per side
  25683. * @param scene defines the hosting scene
  25684. * @param updatable defines if the mesh must be flagged as updatable
  25685. * @returns a new Mesh
  25686. */
  25687. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25688. /**
  25689. * Creates a tiled ground mesh.
  25690. * Please consider using the same method from the MeshBuilder class instead
  25691. * @param name defines the name of the mesh to create
  25692. * @param xmin set the ground minimum X coordinate
  25693. * @param zmin set the ground minimum Y coordinate
  25694. * @param xmax set the ground maximum X coordinate
  25695. * @param zmax set the ground maximum Z coordinate
  25696. * @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
  25697. * @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
  25698. * @param scene defines the hosting scene
  25699. * @param updatable defines if the mesh must be flagged as updatable
  25700. * @returns a new Mesh
  25701. */
  25702. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25703. w: number;
  25704. h: number;
  25705. }, precision: {
  25706. w: number;
  25707. h: number;
  25708. }, scene: Scene, updatable?: boolean): Mesh;
  25709. /**
  25710. * Creates a ground mesh from a height map.
  25711. * Please consider using the same method from the MeshBuilder class instead
  25712. * @see http://doc.babylonjs.com/babylon101/height_map
  25713. * @param name defines the name of the mesh to create
  25714. * @param url sets the URL of the height map image resource
  25715. * @param width set the ground width size
  25716. * @param height set the ground height size
  25717. * @param subdivisions sets the number of subdivision per side
  25718. * @param minHeight is the minimum altitude on the ground
  25719. * @param maxHeight is the maximum altitude on the ground
  25720. * @param scene defines the hosting scene
  25721. * @param updatable defines if the mesh must be flagged as updatable
  25722. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25723. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25724. * @returns a new Mesh
  25725. */
  25726. 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;
  25727. /**
  25728. * Creates a tube mesh.
  25729. * The tube is a parametric shape.
  25730. * It has no predefined shape. Its final shape will depend on the input parameters.
  25731. * Please consider using the same method from the MeshBuilder class instead
  25732. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25733. * @param name defines the name of the mesh to create
  25734. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25735. * @param radius sets the tube radius size
  25736. * @param tessellation is the number of sides on the tubular surface
  25737. * @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
  25738. * @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
  25739. * @param scene defines the hosting scene
  25740. * @param updatable defines if the mesh must be flagged as updatable
  25741. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25742. * @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)
  25743. * @returns a new Mesh
  25744. */
  25745. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25746. (i: number, distance: number): number;
  25747. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25748. /**
  25749. * Creates a polyhedron mesh.
  25750. * Please consider using the same method from the MeshBuilder class instead.
  25751. * * 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
  25752. * * The parameter `size` (positive float, default 1) sets the polygon size
  25753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25754. * * 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`
  25755. * * 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
  25756. * * 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)`)
  25757. * * 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
  25758. * * 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
  25759. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25760. * * 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
  25761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25762. * @param name defines the name of the mesh to create
  25763. * @param options defines the options used to create the mesh
  25764. * @param scene defines the hosting scene
  25765. * @returns a new Mesh
  25766. */
  25767. static CreatePolyhedron(name: string, options: {
  25768. type?: number;
  25769. size?: number;
  25770. sizeX?: number;
  25771. sizeY?: number;
  25772. sizeZ?: number;
  25773. custom?: any;
  25774. faceUV?: Vector4[];
  25775. faceColors?: Color4[];
  25776. updatable?: boolean;
  25777. sideOrientation?: number;
  25778. }, scene: Scene): Mesh;
  25779. /**
  25780. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25781. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25782. * * 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`)
  25783. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25784. * * 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
  25785. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25786. * * 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
  25787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25788. * @param name defines the name of the mesh
  25789. * @param options defines the options used to create the mesh
  25790. * @param scene defines the hosting scene
  25791. * @returns a new Mesh
  25792. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25793. */
  25794. static CreateIcoSphere(name: string, options: {
  25795. radius?: number;
  25796. flat?: boolean;
  25797. subdivisions?: number;
  25798. sideOrientation?: number;
  25799. updatable?: boolean;
  25800. }, scene: Scene): Mesh;
  25801. /**
  25802. * Creates a decal mesh.
  25803. * Please consider using the same method from the MeshBuilder class instead.
  25804. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25805. * @param name defines the name of the mesh
  25806. * @param sourceMesh defines the mesh receiving the decal
  25807. * @param position sets the position of the decal in world coordinates
  25808. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25809. * @param size sets the decal scaling
  25810. * @param angle sets the angle to rotate the decal
  25811. * @returns a new Mesh
  25812. */
  25813. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25814. /**
  25815. * Prepare internal position array for software CPU skinning
  25816. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25817. */
  25818. setPositionsForCPUSkinning(): Float32Array;
  25819. /**
  25820. * Prepare internal normal array for software CPU skinning
  25821. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25822. */
  25823. setNormalsForCPUSkinning(): Float32Array;
  25824. /**
  25825. * Updates the vertex buffer by applying transformation from the bones
  25826. * @param skeleton defines the skeleton to apply to current mesh
  25827. * @returns the current mesh
  25828. */
  25829. applySkeleton(skeleton: Skeleton): Mesh;
  25830. /**
  25831. * 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
  25832. * @param meshes defines the list of meshes to scan
  25833. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25834. */
  25835. static MinMax(meshes: AbstractMesh[]): {
  25836. min: Vector3;
  25837. max: Vector3;
  25838. };
  25839. /**
  25840. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25841. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25842. * @returns a vector3
  25843. */
  25844. static Center(meshesOrMinMaxVector: {
  25845. min: Vector3;
  25846. max: Vector3;
  25847. } | AbstractMesh[]): Vector3;
  25848. /**
  25849. * Merge the array of meshes into a single mesh for performance reasons.
  25850. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25851. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25852. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25853. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25854. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25855. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25856. * @returns a new mesh
  25857. */
  25858. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25859. /** @hidden */
  25860. addInstance(instance: InstancedMesh): void;
  25861. /** @hidden */
  25862. removeInstance(instance: InstancedMesh): void;
  25863. }
  25864. }
  25865. declare module BABYLON {
  25866. /**
  25867. * This is the base class of all the camera used in the application.
  25868. * @see http://doc.babylonjs.com/features/cameras
  25869. */
  25870. export class Camera extends Node {
  25871. /** @hidden */
  25872. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25873. /**
  25874. * This is the default projection mode used by the cameras.
  25875. * It helps recreating a feeling of perspective and better appreciate depth.
  25876. * This is the best way to simulate real life cameras.
  25877. */
  25878. static readonly PERSPECTIVE_CAMERA: number;
  25879. /**
  25880. * This helps creating camera with an orthographic mode.
  25881. * 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.
  25882. */
  25883. static readonly ORTHOGRAPHIC_CAMERA: number;
  25884. /**
  25885. * This is the default FOV mode for perspective cameras.
  25886. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25887. */
  25888. static readonly FOVMODE_VERTICAL_FIXED: number;
  25889. /**
  25890. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25891. */
  25892. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25893. /**
  25894. * This specifies ther is no need for a camera rig.
  25895. * Basically only one eye is rendered corresponding to the camera.
  25896. */
  25897. static readonly RIG_MODE_NONE: number;
  25898. /**
  25899. * Simulates a camera Rig with one blue eye and one red eye.
  25900. * This can be use with 3d blue and red glasses.
  25901. */
  25902. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25903. /**
  25904. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25905. */
  25906. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25907. /**
  25908. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25909. */
  25910. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25911. /**
  25912. * Defines that both eyes of the camera will be rendered over under each other.
  25913. */
  25914. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25915. /**
  25916. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25917. */
  25918. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25919. /**
  25920. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25921. */
  25922. static readonly RIG_MODE_VR: number;
  25923. /**
  25924. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25925. */
  25926. static readonly RIG_MODE_WEBVR: number;
  25927. /**
  25928. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25929. */
  25930. static readonly RIG_MODE_CUSTOM: number;
  25931. /**
  25932. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25933. */
  25934. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25935. /**
  25936. * Define the input manager associated with the camera.
  25937. */
  25938. inputs: CameraInputsManager<Camera>;
  25939. /** @hidden */
  25940. _position: Vector3;
  25941. /**
  25942. * Define the current local position of the camera in the scene
  25943. */
  25944. get position(): Vector3;
  25945. set position(newPosition: Vector3);
  25946. /**
  25947. * The vector the camera should consider as up.
  25948. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25949. */
  25950. upVector: Vector3;
  25951. /**
  25952. * Define the current limit on the left side for an orthographic camera
  25953. * In scene unit
  25954. */
  25955. orthoLeft: Nullable<number>;
  25956. /**
  25957. * Define the current limit on the right side for an orthographic camera
  25958. * In scene unit
  25959. */
  25960. orthoRight: Nullable<number>;
  25961. /**
  25962. * Define the current limit on the bottom side for an orthographic camera
  25963. * In scene unit
  25964. */
  25965. orthoBottom: Nullable<number>;
  25966. /**
  25967. * Define the current limit on the top side for an orthographic camera
  25968. * In scene unit
  25969. */
  25970. orthoTop: Nullable<number>;
  25971. /**
  25972. * Field Of View is set in Radians. (default is 0.8)
  25973. */
  25974. fov: number;
  25975. /**
  25976. * Define the minimum distance the camera can see from.
  25977. * This is important to note that the depth buffer are not infinite and the closer it starts
  25978. * the more your scene might encounter depth fighting issue.
  25979. */
  25980. minZ: number;
  25981. /**
  25982. * Define the maximum distance the camera can see to.
  25983. * This is important to note that the depth buffer are not infinite and the further it end
  25984. * the more your scene might encounter depth fighting issue.
  25985. */
  25986. maxZ: number;
  25987. /**
  25988. * Define the default inertia of the camera.
  25989. * This helps giving a smooth feeling to the camera movement.
  25990. */
  25991. inertia: number;
  25992. /**
  25993. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25994. */
  25995. mode: number;
  25996. /**
  25997. * Define whether the camera is intermediate.
  25998. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25999. */
  26000. isIntermediate: boolean;
  26001. /**
  26002. * Define the viewport of the camera.
  26003. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26004. */
  26005. viewport: Viewport;
  26006. /**
  26007. * Restricts the camera to viewing objects with the same layerMask.
  26008. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26009. */
  26010. layerMask: number;
  26011. /**
  26012. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26013. */
  26014. fovMode: number;
  26015. /**
  26016. * Rig mode of the camera.
  26017. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26018. * This is normally controlled byt the camera themselves as internal use.
  26019. */
  26020. cameraRigMode: number;
  26021. /**
  26022. * Defines the distance between both "eyes" in case of a RIG
  26023. */
  26024. interaxialDistance: number;
  26025. /**
  26026. * Defines if stereoscopic rendering is done side by side or over under.
  26027. */
  26028. isStereoscopicSideBySide: boolean;
  26029. /**
  26030. * 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
  26031. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26032. * else in the scene. (Eg. security camera)
  26033. *
  26034. * 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)
  26035. */
  26036. customRenderTargets: RenderTargetTexture[];
  26037. /**
  26038. * When set, the camera will render to this render target instead of the default canvas
  26039. *
  26040. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26041. */
  26042. outputRenderTarget: Nullable<RenderTargetTexture>;
  26043. /**
  26044. * Observable triggered when the camera view matrix has changed.
  26045. */
  26046. onViewMatrixChangedObservable: Observable<Camera>;
  26047. /**
  26048. * Observable triggered when the camera Projection matrix has changed.
  26049. */
  26050. onProjectionMatrixChangedObservable: Observable<Camera>;
  26051. /**
  26052. * Observable triggered when the inputs have been processed.
  26053. */
  26054. onAfterCheckInputsObservable: Observable<Camera>;
  26055. /**
  26056. * Observable triggered when reset has been called and applied to the camera.
  26057. */
  26058. onRestoreStateObservable: Observable<Camera>;
  26059. /**
  26060. * Is this camera a part of a rig system?
  26061. */
  26062. isRigCamera: boolean;
  26063. /**
  26064. * If isRigCamera set to true this will be set with the parent camera.
  26065. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26066. */
  26067. rigParent?: Camera;
  26068. /** @hidden */
  26069. _cameraRigParams: any;
  26070. /** @hidden */
  26071. _rigCameras: Camera[];
  26072. /** @hidden */
  26073. _rigPostProcess: Nullable<PostProcess>;
  26074. protected _webvrViewMatrix: Matrix;
  26075. /** @hidden */
  26076. _skipRendering: boolean;
  26077. /** @hidden */
  26078. _projectionMatrix: Matrix;
  26079. /** @hidden */
  26080. _postProcesses: Nullable<PostProcess>[];
  26081. /** @hidden */
  26082. _activeMeshes: SmartArray<AbstractMesh>;
  26083. protected _globalPosition: Vector3;
  26084. /** @hidden */
  26085. _computedViewMatrix: Matrix;
  26086. private _doNotComputeProjectionMatrix;
  26087. private _transformMatrix;
  26088. private _frustumPlanes;
  26089. private _refreshFrustumPlanes;
  26090. private _storedFov;
  26091. private _stateStored;
  26092. /**
  26093. * Instantiates a new camera object.
  26094. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26095. * @see http://doc.babylonjs.com/features/cameras
  26096. * @param name Defines the name of the camera in the scene
  26097. * @param position Defines the position of the camera
  26098. * @param scene Defines the scene the camera belongs too
  26099. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26100. */
  26101. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26102. /**
  26103. * Store current camera state (fov, position, etc..)
  26104. * @returns the camera
  26105. */
  26106. storeState(): Camera;
  26107. /**
  26108. * Restores the camera state values if it has been stored. You must call storeState() first
  26109. */
  26110. protected _restoreStateValues(): boolean;
  26111. /**
  26112. * Restored camera state. You must call storeState() first.
  26113. * @returns true if restored and false otherwise
  26114. */
  26115. restoreState(): boolean;
  26116. /**
  26117. * Gets the class name of the camera.
  26118. * @returns the class name
  26119. */
  26120. getClassName(): string;
  26121. /** @hidden */
  26122. readonly _isCamera: boolean;
  26123. /**
  26124. * Gets a string representation of the camera useful for debug purpose.
  26125. * @param fullDetails Defines that a more verboe level of logging is required
  26126. * @returns the string representation
  26127. */
  26128. toString(fullDetails?: boolean): string;
  26129. /**
  26130. * Gets the current world space position of the camera.
  26131. */
  26132. get globalPosition(): Vector3;
  26133. /**
  26134. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26135. * @returns the active meshe list
  26136. */
  26137. getActiveMeshes(): SmartArray<AbstractMesh>;
  26138. /**
  26139. * Check whether a mesh is part of the current active mesh list of the camera
  26140. * @param mesh Defines the mesh to check
  26141. * @returns true if active, false otherwise
  26142. */
  26143. isActiveMesh(mesh: Mesh): boolean;
  26144. /**
  26145. * Is this camera ready to be used/rendered
  26146. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26147. * @return true if the camera is ready
  26148. */
  26149. isReady(completeCheck?: boolean): boolean;
  26150. /** @hidden */
  26151. _initCache(): void;
  26152. /** @hidden */
  26153. _updateCache(ignoreParentClass?: boolean): void;
  26154. /** @hidden */
  26155. _isSynchronized(): boolean;
  26156. /** @hidden */
  26157. _isSynchronizedViewMatrix(): boolean;
  26158. /** @hidden */
  26159. _isSynchronizedProjectionMatrix(): boolean;
  26160. /**
  26161. * Attach the input controls to a specific dom element to get the input from.
  26162. * @param element Defines the element the controls should be listened from
  26163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26164. */
  26165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26166. /**
  26167. * Detach the current controls from the specified dom element.
  26168. * @param element Defines the element to stop listening the inputs from
  26169. */
  26170. detachControl(element: HTMLElement): void;
  26171. /**
  26172. * Update the camera state according to the different inputs gathered during the frame.
  26173. */
  26174. update(): void;
  26175. /** @hidden */
  26176. _checkInputs(): void;
  26177. /** @hidden */
  26178. get rigCameras(): Camera[];
  26179. /**
  26180. * Gets the post process used by the rig cameras
  26181. */
  26182. get rigPostProcess(): Nullable<PostProcess>;
  26183. /**
  26184. * Internal, gets the first post proces.
  26185. * @returns the first post process to be run on this camera.
  26186. */
  26187. _getFirstPostProcess(): Nullable<PostProcess>;
  26188. private _cascadePostProcessesToRigCams;
  26189. /**
  26190. * Attach a post process to the camera.
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26192. * @param postProcess The post process to attach to the camera
  26193. * @param insertAt The position of the post process in case several of them are in use in the scene
  26194. * @returns the position the post process has been inserted at
  26195. */
  26196. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26197. /**
  26198. * Detach a post process to the camera.
  26199. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26200. * @param postProcess The post process to detach from the camera
  26201. */
  26202. detachPostProcess(postProcess: PostProcess): void;
  26203. /**
  26204. * Gets the current world matrix of the camera
  26205. */
  26206. getWorldMatrix(): Matrix;
  26207. /** @hidden */
  26208. _getViewMatrix(): Matrix;
  26209. /**
  26210. * Gets the current view matrix of the camera.
  26211. * @param force forces the camera to recompute the matrix without looking at the cached state
  26212. * @returns the view matrix
  26213. */
  26214. getViewMatrix(force?: boolean): Matrix;
  26215. /**
  26216. * Freeze the projection matrix.
  26217. * It will prevent the cache check of the camera projection compute and can speed up perf
  26218. * if no parameter of the camera are meant to change
  26219. * @param projection Defines manually a projection if necessary
  26220. */
  26221. freezeProjectionMatrix(projection?: Matrix): void;
  26222. /**
  26223. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26224. */
  26225. unfreezeProjectionMatrix(): void;
  26226. /**
  26227. * Gets the current projection matrix of the camera.
  26228. * @param force forces the camera to recompute the matrix without looking at the cached state
  26229. * @returns the projection matrix
  26230. */
  26231. getProjectionMatrix(force?: boolean): Matrix;
  26232. /**
  26233. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26234. * @returns a Matrix
  26235. */
  26236. getTransformationMatrix(): Matrix;
  26237. private _updateFrustumPlanes;
  26238. /**
  26239. * Checks if a cullable object (mesh...) is in the camera frustum
  26240. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26241. * @param target The object to check
  26242. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26243. * @returns true if the object is in frustum otherwise false
  26244. */
  26245. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26246. /**
  26247. * Checks if a cullable object (mesh...) is in the camera frustum
  26248. * Unlike isInFrustum this cheks the full bounding box
  26249. * @param target The object to check
  26250. * @returns true if the object is in frustum otherwise false
  26251. */
  26252. isCompletelyInFrustum(target: ICullable): boolean;
  26253. /**
  26254. * Gets a ray in the forward direction from the camera.
  26255. * @param length Defines the length of the ray to create
  26256. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26257. * @param origin Defines the start point of the ray which defaults to the camera position
  26258. * @returns the forward ray
  26259. */
  26260. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26261. /**
  26262. * Releases resources associated with this node.
  26263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26265. */
  26266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26267. /** @hidden */
  26268. _isLeftCamera: boolean;
  26269. /**
  26270. * Gets the left camera of a rig setup in case of Rigged Camera
  26271. */
  26272. get isLeftCamera(): boolean;
  26273. /** @hidden */
  26274. _isRightCamera: boolean;
  26275. /**
  26276. * Gets the right camera of a rig setup in case of Rigged Camera
  26277. */
  26278. get isRightCamera(): boolean;
  26279. /**
  26280. * Gets the left camera of a rig setup in case of Rigged Camera
  26281. */
  26282. get leftCamera(): Nullable<FreeCamera>;
  26283. /**
  26284. * Gets the right camera of a rig setup in case of Rigged Camera
  26285. */
  26286. get rightCamera(): Nullable<FreeCamera>;
  26287. /**
  26288. * Gets the left camera target of a rig setup in case of Rigged Camera
  26289. * @returns the target position
  26290. */
  26291. getLeftTarget(): Nullable<Vector3>;
  26292. /**
  26293. * Gets the right camera target of a rig setup in case of Rigged Camera
  26294. * @returns the target position
  26295. */
  26296. getRightTarget(): Nullable<Vector3>;
  26297. /**
  26298. * @hidden
  26299. */
  26300. setCameraRigMode(mode: number, rigParams: any): void;
  26301. /** @hidden */
  26302. static _setStereoscopicRigMode(camera: Camera): void;
  26303. /** @hidden */
  26304. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26305. /** @hidden */
  26306. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26307. /** @hidden */
  26308. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26309. /** @hidden */
  26310. _getVRProjectionMatrix(): Matrix;
  26311. protected _updateCameraRotationMatrix(): void;
  26312. protected _updateWebVRCameraRotationMatrix(): void;
  26313. /**
  26314. * This function MUST be overwritten by the different WebVR cameras available.
  26315. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26316. * @hidden
  26317. */
  26318. _getWebVRProjectionMatrix(): Matrix;
  26319. /**
  26320. * This function MUST be overwritten by the different WebVR cameras available.
  26321. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26322. * @hidden
  26323. */
  26324. _getWebVRViewMatrix(): Matrix;
  26325. /** @hidden */
  26326. setCameraRigParameter(name: string, value: any): void;
  26327. /**
  26328. * needs to be overridden by children so sub has required properties to be copied
  26329. * @hidden
  26330. */
  26331. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26332. /**
  26333. * May need to be overridden by children
  26334. * @hidden
  26335. */
  26336. _updateRigCameras(): void;
  26337. /** @hidden */
  26338. _setupInputs(): void;
  26339. /**
  26340. * Serialiaze the camera setup to a json represention
  26341. * @returns the JSON representation
  26342. */
  26343. serialize(): any;
  26344. /**
  26345. * Clones the current camera.
  26346. * @param name The cloned camera name
  26347. * @returns the cloned camera
  26348. */
  26349. clone(name: string): Camera;
  26350. /**
  26351. * Gets the direction of the camera relative to a given local axis.
  26352. * @param localAxis Defines the reference axis to provide a relative direction.
  26353. * @return the direction
  26354. */
  26355. getDirection(localAxis: Vector3): Vector3;
  26356. /**
  26357. * Returns the current camera absolute rotation
  26358. */
  26359. get absoluteRotation(): Quaternion;
  26360. /**
  26361. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26362. * @param localAxis Defines the reference axis to provide a relative direction.
  26363. * @param result Defines the vector to store the result in
  26364. */
  26365. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26366. /**
  26367. * Gets a camera constructor for a given camera type
  26368. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26369. * @param name The name of the camera the result will be able to instantiate
  26370. * @param scene The scene the result will construct the camera in
  26371. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26372. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26373. * @returns a factory method to construc the camera
  26374. */
  26375. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26376. /**
  26377. * Compute the world matrix of the camera.
  26378. * @returns the camera world matrix
  26379. */
  26380. computeWorldMatrix(): Matrix;
  26381. /**
  26382. * Parse a JSON and creates the camera from the parsed information
  26383. * @param parsedCamera The JSON to parse
  26384. * @param scene The scene to instantiate the camera in
  26385. * @returns the newly constructed camera
  26386. */
  26387. static Parse(parsedCamera: any, scene: Scene): Camera;
  26388. }
  26389. }
  26390. declare module BABYLON {
  26391. /**
  26392. * Class containing static functions to help procedurally build meshes
  26393. */
  26394. export class DiscBuilder {
  26395. /**
  26396. * Creates a plane polygonal mesh. By default, this is a disc
  26397. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26398. * * 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
  26399. * * 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
  26400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26401. * * 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
  26402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26403. * @param name defines the name of the mesh
  26404. * @param options defines the options used to create the mesh
  26405. * @param scene defines the hosting scene
  26406. * @returns the plane polygonal mesh
  26407. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26408. */
  26409. static CreateDisc(name: string, options: {
  26410. radius?: number;
  26411. tessellation?: number;
  26412. arc?: number;
  26413. updatable?: boolean;
  26414. sideOrientation?: number;
  26415. frontUVs?: Vector4;
  26416. backUVs?: Vector4;
  26417. }, scene?: Nullable<Scene>): Mesh;
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. /**
  26422. * Options to be used when creating a FresnelParameters.
  26423. */
  26424. export type IFresnelParametersCreationOptions = {
  26425. /**
  26426. * Define the color used on edges (grazing angle)
  26427. */
  26428. leftColor?: Color3;
  26429. /**
  26430. * Define the color used on center
  26431. */
  26432. rightColor?: Color3;
  26433. /**
  26434. * Define bias applied to computed fresnel term
  26435. */
  26436. bias?: number;
  26437. /**
  26438. * Defined the power exponent applied to fresnel term
  26439. */
  26440. power?: number;
  26441. /**
  26442. * Define if the fresnel effect is enable or not.
  26443. */
  26444. isEnabled?: boolean;
  26445. };
  26446. /**
  26447. * Serialized format for FresnelParameters.
  26448. */
  26449. export type IFresnelParametersSerialized = {
  26450. /**
  26451. * Define the color used on edges (grazing angle) [as an array]
  26452. */
  26453. leftColor: number[];
  26454. /**
  26455. * Define the color used on center [as an array]
  26456. */
  26457. rightColor: number[];
  26458. /**
  26459. * Define bias applied to computed fresnel term
  26460. */
  26461. bias: number;
  26462. /**
  26463. * Defined the power exponent applied to fresnel term
  26464. */
  26465. power?: number;
  26466. /**
  26467. * Define if the fresnel effect is enable or not.
  26468. */
  26469. isEnabled: boolean;
  26470. };
  26471. /**
  26472. * This represents all the required information to add a fresnel effect on a material:
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26474. */
  26475. export class FresnelParameters {
  26476. private _isEnabled;
  26477. /**
  26478. * Define if the fresnel effect is enable or not.
  26479. */
  26480. get isEnabled(): boolean;
  26481. set isEnabled(value: boolean);
  26482. /**
  26483. * Define the color used on edges (grazing angle)
  26484. */
  26485. leftColor: Color3;
  26486. /**
  26487. * Define the color used on center
  26488. */
  26489. rightColor: Color3;
  26490. /**
  26491. * Define bias applied to computed fresnel term
  26492. */
  26493. bias: number;
  26494. /**
  26495. * Defined the power exponent applied to fresnel term
  26496. */
  26497. power: number;
  26498. /**
  26499. * Creates a new FresnelParameters object.
  26500. *
  26501. * @param options provide your own settings to optionally to override defaults
  26502. */
  26503. constructor(options?: IFresnelParametersCreationOptions);
  26504. /**
  26505. * Clones the current fresnel and its valuues
  26506. * @returns a clone fresnel configuration
  26507. */
  26508. clone(): FresnelParameters;
  26509. /**
  26510. * Determines equality between FresnelParameters objects
  26511. * @param otherFresnelParameters defines the second operand
  26512. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26513. */
  26514. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26515. /**
  26516. * Serializes the current fresnel parameters to a JSON representation.
  26517. * @return the JSON serialization
  26518. */
  26519. serialize(): IFresnelParametersSerialized;
  26520. /**
  26521. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26522. * @param parsedFresnelParameters Define the JSON representation
  26523. * @returns the parsed parameters
  26524. */
  26525. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26526. }
  26527. }
  26528. declare module BABYLON {
  26529. /**
  26530. * Base class of materials working in push mode in babylon JS
  26531. * @hidden
  26532. */
  26533. export class PushMaterial extends Material {
  26534. protected _activeEffect: Effect;
  26535. protected _normalMatrix: Matrix;
  26536. /**
  26537. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26538. * This means that the material can keep using a previous shader while a new one is being compiled.
  26539. * This is mostly used when shader parallel compilation is supported (true by default)
  26540. */
  26541. allowShaderHotSwapping: boolean;
  26542. constructor(name: string, scene: Scene);
  26543. getEffect(): Effect;
  26544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26545. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26546. /**
  26547. * Binds the given world matrix to the active effect
  26548. *
  26549. * @param world the matrix to bind
  26550. */
  26551. bindOnlyWorldMatrix(world: Matrix): void;
  26552. /**
  26553. * Binds the given normal matrix to the active effect
  26554. *
  26555. * @param normalMatrix the matrix to bind
  26556. */
  26557. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26558. bind(world: Matrix, mesh?: Mesh): void;
  26559. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26560. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26561. }
  26562. }
  26563. declare module BABYLON {
  26564. /**
  26565. * This groups all the flags used to control the materials channel.
  26566. */
  26567. export class MaterialFlags {
  26568. private static _DiffuseTextureEnabled;
  26569. /**
  26570. * Are diffuse textures enabled in the application.
  26571. */
  26572. static get DiffuseTextureEnabled(): boolean;
  26573. static set DiffuseTextureEnabled(value: boolean);
  26574. private static _AmbientTextureEnabled;
  26575. /**
  26576. * Are ambient textures enabled in the application.
  26577. */
  26578. static get AmbientTextureEnabled(): boolean;
  26579. static set AmbientTextureEnabled(value: boolean);
  26580. private static _OpacityTextureEnabled;
  26581. /**
  26582. * Are opacity textures enabled in the application.
  26583. */
  26584. static get OpacityTextureEnabled(): boolean;
  26585. static set OpacityTextureEnabled(value: boolean);
  26586. private static _ReflectionTextureEnabled;
  26587. /**
  26588. * Are reflection textures enabled in the application.
  26589. */
  26590. static get ReflectionTextureEnabled(): boolean;
  26591. static set ReflectionTextureEnabled(value: boolean);
  26592. private static _EmissiveTextureEnabled;
  26593. /**
  26594. * Are emissive textures enabled in the application.
  26595. */
  26596. static get EmissiveTextureEnabled(): boolean;
  26597. static set EmissiveTextureEnabled(value: boolean);
  26598. private static _SpecularTextureEnabled;
  26599. /**
  26600. * Are specular textures enabled in the application.
  26601. */
  26602. static get SpecularTextureEnabled(): boolean;
  26603. static set SpecularTextureEnabled(value: boolean);
  26604. private static _BumpTextureEnabled;
  26605. /**
  26606. * Are bump textures enabled in the application.
  26607. */
  26608. static get BumpTextureEnabled(): boolean;
  26609. static set BumpTextureEnabled(value: boolean);
  26610. private static _LightmapTextureEnabled;
  26611. /**
  26612. * Are lightmap textures enabled in the application.
  26613. */
  26614. static get LightmapTextureEnabled(): boolean;
  26615. static set LightmapTextureEnabled(value: boolean);
  26616. private static _RefractionTextureEnabled;
  26617. /**
  26618. * Are refraction textures enabled in the application.
  26619. */
  26620. static get RefractionTextureEnabled(): boolean;
  26621. static set RefractionTextureEnabled(value: boolean);
  26622. private static _ColorGradingTextureEnabled;
  26623. /**
  26624. * Are color grading textures enabled in the application.
  26625. */
  26626. static get ColorGradingTextureEnabled(): boolean;
  26627. static set ColorGradingTextureEnabled(value: boolean);
  26628. private static _FresnelEnabled;
  26629. /**
  26630. * Are fresnels enabled in the application.
  26631. */
  26632. static get FresnelEnabled(): boolean;
  26633. static set FresnelEnabled(value: boolean);
  26634. private static _ClearCoatTextureEnabled;
  26635. /**
  26636. * Are clear coat textures enabled in the application.
  26637. */
  26638. static get ClearCoatTextureEnabled(): boolean;
  26639. static set ClearCoatTextureEnabled(value: boolean);
  26640. private static _ClearCoatBumpTextureEnabled;
  26641. /**
  26642. * Are clear coat bump textures enabled in the application.
  26643. */
  26644. static get ClearCoatBumpTextureEnabled(): boolean;
  26645. static set ClearCoatBumpTextureEnabled(value: boolean);
  26646. private static _ClearCoatTintTextureEnabled;
  26647. /**
  26648. * Are clear coat tint textures enabled in the application.
  26649. */
  26650. static get ClearCoatTintTextureEnabled(): boolean;
  26651. static set ClearCoatTintTextureEnabled(value: boolean);
  26652. private static _SheenTextureEnabled;
  26653. /**
  26654. * Are sheen textures enabled in the application.
  26655. */
  26656. static get SheenTextureEnabled(): boolean;
  26657. static set SheenTextureEnabled(value: boolean);
  26658. private static _AnisotropicTextureEnabled;
  26659. /**
  26660. * Are anisotropic textures enabled in the application.
  26661. */
  26662. static get AnisotropicTextureEnabled(): boolean;
  26663. static set AnisotropicTextureEnabled(value: boolean);
  26664. private static _ThicknessTextureEnabled;
  26665. /**
  26666. * Are thickness textures enabled in the application.
  26667. */
  26668. static get ThicknessTextureEnabled(): boolean;
  26669. static set ThicknessTextureEnabled(value: boolean);
  26670. }
  26671. }
  26672. declare module BABYLON {
  26673. /** @hidden */
  26674. export var defaultFragmentDeclaration: {
  26675. name: string;
  26676. shader: string;
  26677. };
  26678. }
  26679. declare module BABYLON {
  26680. /** @hidden */
  26681. export var defaultUboDeclaration: {
  26682. name: string;
  26683. shader: string;
  26684. };
  26685. }
  26686. declare module BABYLON {
  26687. /** @hidden */
  26688. export var lightFragmentDeclaration: {
  26689. name: string;
  26690. shader: string;
  26691. };
  26692. }
  26693. declare module BABYLON {
  26694. /** @hidden */
  26695. export var lightUboDeclaration: {
  26696. name: string;
  26697. shader: string;
  26698. };
  26699. }
  26700. declare module BABYLON {
  26701. /** @hidden */
  26702. export var lightsFragmentFunctions: {
  26703. name: string;
  26704. shader: string;
  26705. };
  26706. }
  26707. declare module BABYLON {
  26708. /** @hidden */
  26709. export var shadowsFragmentFunctions: {
  26710. name: string;
  26711. shader: string;
  26712. };
  26713. }
  26714. declare module BABYLON {
  26715. /** @hidden */
  26716. export var fresnelFunction: {
  26717. name: string;
  26718. shader: string;
  26719. };
  26720. }
  26721. declare module BABYLON {
  26722. /** @hidden */
  26723. export var reflectionFunction: {
  26724. name: string;
  26725. shader: string;
  26726. };
  26727. }
  26728. declare module BABYLON {
  26729. /** @hidden */
  26730. export var bumpFragmentMainFunctions: {
  26731. name: string;
  26732. shader: string;
  26733. };
  26734. }
  26735. declare module BABYLON {
  26736. /** @hidden */
  26737. export var bumpFragmentFunctions: {
  26738. name: string;
  26739. shader: string;
  26740. };
  26741. }
  26742. declare module BABYLON {
  26743. /** @hidden */
  26744. export var logDepthDeclaration: {
  26745. name: string;
  26746. shader: string;
  26747. };
  26748. }
  26749. declare module BABYLON {
  26750. /** @hidden */
  26751. export var bumpFragment: {
  26752. name: string;
  26753. shader: string;
  26754. };
  26755. }
  26756. declare module BABYLON {
  26757. /** @hidden */
  26758. export var depthPrePass: {
  26759. name: string;
  26760. shader: string;
  26761. };
  26762. }
  26763. declare module BABYLON {
  26764. /** @hidden */
  26765. export var lightFragment: {
  26766. name: string;
  26767. shader: string;
  26768. };
  26769. }
  26770. declare module BABYLON {
  26771. /** @hidden */
  26772. export var logDepthFragment: {
  26773. name: string;
  26774. shader: string;
  26775. };
  26776. }
  26777. declare module BABYLON {
  26778. /** @hidden */
  26779. export var defaultPixelShader: {
  26780. name: string;
  26781. shader: string;
  26782. };
  26783. }
  26784. declare module BABYLON {
  26785. /** @hidden */
  26786. export var defaultVertexDeclaration: {
  26787. name: string;
  26788. shader: string;
  26789. };
  26790. }
  26791. declare module BABYLON {
  26792. /** @hidden */
  26793. export var bumpVertexDeclaration: {
  26794. name: string;
  26795. shader: string;
  26796. };
  26797. }
  26798. declare module BABYLON {
  26799. /** @hidden */
  26800. export var bumpVertex: {
  26801. name: string;
  26802. shader: string;
  26803. };
  26804. }
  26805. declare module BABYLON {
  26806. /** @hidden */
  26807. export var fogVertex: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module BABYLON {
  26813. /** @hidden */
  26814. export var shadowsVertex: {
  26815. name: string;
  26816. shader: string;
  26817. };
  26818. }
  26819. declare module BABYLON {
  26820. /** @hidden */
  26821. export var pointCloudVertex: {
  26822. name: string;
  26823. shader: string;
  26824. };
  26825. }
  26826. declare module BABYLON {
  26827. /** @hidden */
  26828. export var logDepthVertex: {
  26829. name: string;
  26830. shader: string;
  26831. };
  26832. }
  26833. declare module BABYLON {
  26834. /** @hidden */
  26835. export var defaultVertexShader: {
  26836. name: string;
  26837. shader: string;
  26838. };
  26839. }
  26840. declare module BABYLON {
  26841. /** @hidden */
  26842. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26843. MAINUV1: boolean;
  26844. MAINUV2: boolean;
  26845. DIFFUSE: boolean;
  26846. DIFFUSEDIRECTUV: number;
  26847. AMBIENT: boolean;
  26848. AMBIENTDIRECTUV: number;
  26849. OPACITY: boolean;
  26850. OPACITYDIRECTUV: number;
  26851. OPACITYRGB: boolean;
  26852. REFLECTION: boolean;
  26853. EMISSIVE: boolean;
  26854. EMISSIVEDIRECTUV: number;
  26855. SPECULAR: boolean;
  26856. SPECULARDIRECTUV: number;
  26857. BUMP: boolean;
  26858. BUMPDIRECTUV: number;
  26859. PARALLAX: boolean;
  26860. PARALLAXOCCLUSION: boolean;
  26861. SPECULAROVERALPHA: boolean;
  26862. CLIPPLANE: boolean;
  26863. CLIPPLANE2: boolean;
  26864. CLIPPLANE3: boolean;
  26865. CLIPPLANE4: boolean;
  26866. CLIPPLANE5: boolean;
  26867. CLIPPLANE6: boolean;
  26868. ALPHATEST: boolean;
  26869. DEPTHPREPASS: boolean;
  26870. ALPHAFROMDIFFUSE: boolean;
  26871. POINTSIZE: boolean;
  26872. FOG: boolean;
  26873. SPECULARTERM: boolean;
  26874. DIFFUSEFRESNEL: boolean;
  26875. OPACITYFRESNEL: boolean;
  26876. REFLECTIONFRESNEL: boolean;
  26877. REFRACTIONFRESNEL: boolean;
  26878. EMISSIVEFRESNEL: boolean;
  26879. FRESNEL: boolean;
  26880. NORMAL: boolean;
  26881. UV1: boolean;
  26882. UV2: boolean;
  26883. VERTEXCOLOR: boolean;
  26884. VERTEXALPHA: boolean;
  26885. NUM_BONE_INFLUENCERS: number;
  26886. BonesPerMesh: number;
  26887. BONETEXTURE: boolean;
  26888. INSTANCES: boolean;
  26889. GLOSSINESS: boolean;
  26890. ROUGHNESS: boolean;
  26891. EMISSIVEASILLUMINATION: boolean;
  26892. LINKEMISSIVEWITHDIFFUSE: boolean;
  26893. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26894. LIGHTMAP: boolean;
  26895. LIGHTMAPDIRECTUV: number;
  26896. OBJECTSPACE_NORMALMAP: boolean;
  26897. USELIGHTMAPASSHADOWMAP: boolean;
  26898. REFLECTIONMAP_3D: boolean;
  26899. REFLECTIONMAP_SPHERICAL: boolean;
  26900. REFLECTIONMAP_PLANAR: boolean;
  26901. REFLECTIONMAP_CUBIC: boolean;
  26902. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26903. REFLECTIONMAP_PROJECTION: boolean;
  26904. REFLECTIONMAP_SKYBOX: boolean;
  26905. REFLECTIONMAP_EXPLICIT: boolean;
  26906. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26907. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26908. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26909. INVERTCUBICMAP: boolean;
  26910. LOGARITHMICDEPTH: boolean;
  26911. REFRACTION: boolean;
  26912. REFRACTIONMAP_3D: boolean;
  26913. REFLECTIONOVERALPHA: boolean;
  26914. TWOSIDEDLIGHTING: boolean;
  26915. SHADOWFLOAT: boolean;
  26916. MORPHTARGETS: boolean;
  26917. MORPHTARGETS_NORMAL: boolean;
  26918. MORPHTARGETS_TANGENT: boolean;
  26919. MORPHTARGETS_UV: boolean;
  26920. NUM_MORPH_INFLUENCERS: number;
  26921. NONUNIFORMSCALING: boolean;
  26922. PREMULTIPLYALPHA: boolean;
  26923. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26924. ALPHABLEND: boolean;
  26925. IMAGEPROCESSING: boolean;
  26926. VIGNETTE: boolean;
  26927. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26928. VIGNETTEBLENDMODEOPAQUE: boolean;
  26929. TONEMAPPING: boolean;
  26930. TONEMAPPING_ACES: boolean;
  26931. CONTRAST: boolean;
  26932. COLORCURVES: boolean;
  26933. COLORGRADING: boolean;
  26934. COLORGRADING3D: boolean;
  26935. SAMPLER3DGREENDEPTH: boolean;
  26936. SAMPLER3DBGRMAP: boolean;
  26937. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26938. MULTIVIEW: boolean;
  26939. /**
  26940. * If the reflection texture on this material is in linear color space
  26941. * @hidden
  26942. */
  26943. IS_REFLECTION_LINEAR: boolean;
  26944. /**
  26945. * If the refraction texture on this material is in linear color space
  26946. * @hidden
  26947. */
  26948. IS_REFRACTION_LINEAR: boolean;
  26949. EXPOSURE: boolean;
  26950. constructor();
  26951. setReflectionMode(modeToEnable: string): void;
  26952. }
  26953. /**
  26954. * This is the default material used in Babylon. It is the best trade off between quality
  26955. * and performances.
  26956. * @see http://doc.babylonjs.com/babylon101/materials
  26957. */
  26958. export class StandardMaterial extends PushMaterial {
  26959. private _diffuseTexture;
  26960. /**
  26961. * The basic texture of the material as viewed under a light.
  26962. */
  26963. diffuseTexture: Nullable<BaseTexture>;
  26964. private _ambientTexture;
  26965. /**
  26966. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26967. */
  26968. ambientTexture: Nullable<BaseTexture>;
  26969. private _opacityTexture;
  26970. /**
  26971. * Define the transparency of the material from a texture.
  26972. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26973. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26974. */
  26975. opacityTexture: Nullable<BaseTexture>;
  26976. private _reflectionTexture;
  26977. /**
  26978. * Define the texture used to display the reflection.
  26979. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26980. */
  26981. reflectionTexture: Nullable<BaseTexture>;
  26982. private _emissiveTexture;
  26983. /**
  26984. * Define texture of the material as if self lit.
  26985. * This will be mixed in the final result even in the absence of light.
  26986. */
  26987. emissiveTexture: Nullable<BaseTexture>;
  26988. private _specularTexture;
  26989. /**
  26990. * Define how the color and intensity of the highlight given by the light in the material.
  26991. */
  26992. specularTexture: Nullable<BaseTexture>;
  26993. private _bumpTexture;
  26994. /**
  26995. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26996. * 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.
  26997. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26998. */
  26999. bumpTexture: Nullable<BaseTexture>;
  27000. private _lightmapTexture;
  27001. /**
  27002. * Complex lighting can be computationally expensive to compute at runtime.
  27003. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27004. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27005. */
  27006. lightmapTexture: Nullable<BaseTexture>;
  27007. private _refractionTexture;
  27008. /**
  27009. * Define the texture used to display the refraction.
  27010. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27011. */
  27012. refractionTexture: Nullable<BaseTexture>;
  27013. /**
  27014. * The color of the material lit by the environmental background lighting.
  27015. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27016. */
  27017. ambientColor: Color3;
  27018. /**
  27019. * The basic color of the material as viewed under a light.
  27020. */
  27021. diffuseColor: Color3;
  27022. /**
  27023. * Define how the color and intensity of the highlight given by the light in the material.
  27024. */
  27025. specularColor: Color3;
  27026. /**
  27027. * Define the color of the material as if self lit.
  27028. * This will be mixed in the final result even in the absence of light.
  27029. */
  27030. emissiveColor: Color3;
  27031. /**
  27032. * Defines how sharp are the highlights in the material.
  27033. * The bigger the value the sharper giving a more glossy feeling to the result.
  27034. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27035. */
  27036. specularPower: number;
  27037. private _useAlphaFromDiffuseTexture;
  27038. /**
  27039. * Does the transparency come from the diffuse texture alpha channel.
  27040. */
  27041. useAlphaFromDiffuseTexture: boolean;
  27042. private _useEmissiveAsIllumination;
  27043. /**
  27044. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27045. */
  27046. useEmissiveAsIllumination: boolean;
  27047. private _linkEmissiveWithDiffuse;
  27048. /**
  27049. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27050. * the emissive level when the final color is close to one.
  27051. */
  27052. linkEmissiveWithDiffuse: boolean;
  27053. private _useSpecularOverAlpha;
  27054. /**
  27055. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27057. */
  27058. useSpecularOverAlpha: boolean;
  27059. private _useReflectionOverAlpha;
  27060. /**
  27061. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27062. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27063. */
  27064. useReflectionOverAlpha: boolean;
  27065. private _disableLighting;
  27066. /**
  27067. * Does lights from the scene impacts this material.
  27068. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27069. */
  27070. disableLighting: boolean;
  27071. private _useObjectSpaceNormalMap;
  27072. /**
  27073. * Allows using an object space normal map (instead of tangent space).
  27074. */
  27075. useObjectSpaceNormalMap: boolean;
  27076. private _useParallax;
  27077. /**
  27078. * Is parallax enabled or not.
  27079. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27080. */
  27081. useParallax: boolean;
  27082. private _useParallaxOcclusion;
  27083. /**
  27084. * Is parallax occlusion enabled or not.
  27085. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27086. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27087. */
  27088. useParallaxOcclusion: boolean;
  27089. /**
  27090. * 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.
  27091. */
  27092. parallaxScaleBias: number;
  27093. private _roughness;
  27094. /**
  27095. * Helps to define how blurry the reflections should appears in the material.
  27096. */
  27097. roughness: number;
  27098. /**
  27099. * In case of refraction, define the value of the index of refraction.
  27100. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27101. */
  27102. indexOfRefraction: number;
  27103. /**
  27104. * Invert the refraction texture alongside the y axis.
  27105. * It can be useful with procedural textures or probe for instance.
  27106. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27107. */
  27108. invertRefractionY: boolean;
  27109. /**
  27110. * Defines the alpha limits in alpha test mode.
  27111. */
  27112. alphaCutOff: number;
  27113. private _useLightmapAsShadowmap;
  27114. /**
  27115. * In case of light mapping, define whether the map contains light or shadow informations.
  27116. */
  27117. useLightmapAsShadowmap: boolean;
  27118. private _diffuseFresnelParameters;
  27119. /**
  27120. * Define the diffuse fresnel parameters of the material.
  27121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27122. */
  27123. diffuseFresnelParameters: FresnelParameters;
  27124. private _opacityFresnelParameters;
  27125. /**
  27126. * Define the opacity fresnel parameters of the material.
  27127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27128. */
  27129. opacityFresnelParameters: FresnelParameters;
  27130. private _reflectionFresnelParameters;
  27131. /**
  27132. * Define the reflection fresnel parameters of the material.
  27133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27134. */
  27135. reflectionFresnelParameters: FresnelParameters;
  27136. private _refractionFresnelParameters;
  27137. /**
  27138. * Define the refraction fresnel parameters of the material.
  27139. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27140. */
  27141. refractionFresnelParameters: FresnelParameters;
  27142. private _emissiveFresnelParameters;
  27143. /**
  27144. * Define the emissive fresnel parameters of the material.
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27146. */
  27147. emissiveFresnelParameters: FresnelParameters;
  27148. private _useReflectionFresnelFromSpecular;
  27149. /**
  27150. * If true automatically deducts the fresnels values from the material specularity.
  27151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27152. */
  27153. useReflectionFresnelFromSpecular: boolean;
  27154. private _useGlossinessFromSpecularMapAlpha;
  27155. /**
  27156. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27157. */
  27158. useGlossinessFromSpecularMapAlpha: boolean;
  27159. private _maxSimultaneousLights;
  27160. /**
  27161. * Defines the maximum number of lights that can be used in the material
  27162. */
  27163. maxSimultaneousLights: number;
  27164. private _invertNormalMapX;
  27165. /**
  27166. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27167. */
  27168. invertNormalMapX: boolean;
  27169. private _invertNormalMapY;
  27170. /**
  27171. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27172. */
  27173. invertNormalMapY: boolean;
  27174. private _twoSidedLighting;
  27175. /**
  27176. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27177. */
  27178. twoSidedLighting: boolean;
  27179. /**
  27180. * Default configuration related to image processing available in the standard Material.
  27181. */
  27182. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27183. /**
  27184. * Gets the image processing configuration used either in this material.
  27185. */
  27186. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27187. /**
  27188. * Sets the Default image processing configuration used either in the this material.
  27189. *
  27190. * If sets to null, the scene one is in use.
  27191. */
  27192. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27193. /**
  27194. * Keep track of the image processing observer to allow dispose and replace.
  27195. */
  27196. private _imageProcessingObserver;
  27197. /**
  27198. * Attaches a new image processing configuration to the Standard Material.
  27199. * @param configuration
  27200. */
  27201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27202. /**
  27203. * Gets wether the color curves effect is enabled.
  27204. */
  27205. get cameraColorCurvesEnabled(): boolean;
  27206. /**
  27207. * Sets wether the color curves effect is enabled.
  27208. */
  27209. set cameraColorCurvesEnabled(value: boolean);
  27210. /**
  27211. * Gets wether the color grading effect is enabled.
  27212. */
  27213. get cameraColorGradingEnabled(): boolean;
  27214. /**
  27215. * Gets wether the color grading effect is enabled.
  27216. */
  27217. set cameraColorGradingEnabled(value: boolean);
  27218. /**
  27219. * Gets wether tonemapping is enabled or not.
  27220. */
  27221. get cameraToneMappingEnabled(): boolean;
  27222. /**
  27223. * Sets wether tonemapping is enabled or not
  27224. */
  27225. set cameraToneMappingEnabled(value: boolean);
  27226. /**
  27227. * The camera exposure used on this material.
  27228. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27229. * This corresponds to a photographic exposure.
  27230. */
  27231. get cameraExposure(): number;
  27232. /**
  27233. * The camera exposure used on this material.
  27234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27235. * This corresponds to a photographic exposure.
  27236. */
  27237. set cameraExposure(value: number);
  27238. /**
  27239. * Gets The camera contrast used on this material.
  27240. */
  27241. get cameraContrast(): number;
  27242. /**
  27243. * Sets The camera contrast used on this material.
  27244. */
  27245. set cameraContrast(value: number);
  27246. /**
  27247. * Gets the Color Grading 2D Lookup Texture.
  27248. */
  27249. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27250. /**
  27251. * Sets the Color Grading 2D Lookup Texture.
  27252. */
  27253. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27254. /**
  27255. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27256. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27257. * 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;
  27258. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27259. */
  27260. get cameraColorCurves(): Nullable<ColorCurves>;
  27261. /**
  27262. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27263. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27264. * 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;
  27265. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27266. */
  27267. set cameraColorCurves(value: Nullable<ColorCurves>);
  27268. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27269. protected _worldViewProjectionMatrix: Matrix;
  27270. protected _globalAmbientColor: Color3;
  27271. protected _useLogarithmicDepth: boolean;
  27272. protected _rebuildInParallel: boolean;
  27273. /**
  27274. * Instantiates a new standard material.
  27275. * This is the default material used in Babylon. It is the best trade off between quality
  27276. * and performances.
  27277. * @see http://doc.babylonjs.com/babylon101/materials
  27278. * @param name Define the name of the material in the scene
  27279. * @param scene Define the scene the material belong to
  27280. */
  27281. constructor(name: string, scene: Scene);
  27282. /**
  27283. * Gets a boolean indicating that current material needs to register RTT
  27284. */
  27285. get hasRenderTargetTextures(): boolean;
  27286. /**
  27287. * Gets the current class name of the material e.g. "StandardMaterial"
  27288. * Mainly use in serialization.
  27289. * @returns the class name
  27290. */
  27291. getClassName(): string;
  27292. /**
  27293. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27294. * You can try switching to logarithmic depth.
  27295. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27296. */
  27297. get useLogarithmicDepth(): boolean;
  27298. set useLogarithmicDepth(value: boolean);
  27299. /**
  27300. * Specifies if the material will require alpha blending
  27301. * @returns a boolean specifying if alpha blending is needed
  27302. */
  27303. needAlphaBlending(): boolean;
  27304. /**
  27305. * Specifies if this material should be rendered in alpha test mode
  27306. * @returns a boolean specifying if an alpha test is needed.
  27307. */
  27308. needAlphaTesting(): boolean;
  27309. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27310. /**
  27311. * Get the texture used for alpha test purpose.
  27312. * @returns the diffuse texture in case of the standard material.
  27313. */
  27314. getAlphaTestTexture(): Nullable<BaseTexture>;
  27315. /**
  27316. * Get if the submesh is ready to be used and all its information available.
  27317. * Child classes can use it to update shaders
  27318. * @param mesh defines the mesh to check
  27319. * @param subMesh defines which submesh to check
  27320. * @param useInstances specifies that instances should be used
  27321. * @returns a boolean indicating that the submesh is ready or not
  27322. */
  27323. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27324. /**
  27325. * Builds the material UBO layouts.
  27326. * Used internally during the effect preparation.
  27327. */
  27328. buildUniformLayout(): void;
  27329. /**
  27330. * Unbinds the material from the mesh
  27331. */
  27332. unbind(): void;
  27333. /**
  27334. * Binds the submesh to this material by preparing the effect and shader to draw
  27335. * @param world defines the world transformation matrix
  27336. * @param mesh defines the mesh containing the submesh
  27337. * @param subMesh defines the submesh to bind the material to
  27338. */
  27339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27340. /**
  27341. * Get the list of animatables in the material.
  27342. * @returns the list of animatables object used in the material
  27343. */
  27344. getAnimatables(): IAnimatable[];
  27345. /**
  27346. * Gets the active textures from the material
  27347. * @returns an array of textures
  27348. */
  27349. getActiveTextures(): BaseTexture[];
  27350. /**
  27351. * Specifies if the material uses a texture
  27352. * @param texture defines the texture to check against the material
  27353. * @returns a boolean specifying if the material uses the texture
  27354. */
  27355. hasTexture(texture: BaseTexture): boolean;
  27356. /**
  27357. * Disposes the material
  27358. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27359. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27360. */
  27361. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27362. /**
  27363. * Makes a duplicate of the material, and gives it a new name
  27364. * @param name defines the new name for the duplicated material
  27365. * @returns the cloned material
  27366. */
  27367. clone(name: string): StandardMaterial;
  27368. /**
  27369. * Serializes this material in a JSON representation
  27370. * @returns the serialized material object
  27371. */
  27372. serialize(): any;
  27373. /**
  27374. * Creates a standard material from parsed material data
  27375. * @param source defines the JSON representation of the material
  27376. * @param scene defines the hosting scene
  27377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27378. * @returns a new standard material
  27379. */
  27380. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27381. /**
  27382. * Are diffuse textures enabled in the application.
  27383. */
  27384. static get DiffuseTextureEnabled(): boolean;
  27385. static set DiffuseTextureEnabled(value: boolean);
  27386. /**
  27387. * Are ambient textures enabled in the application.
  27388. */
  27389. static get AmbientTextureEnabled(): boolean;
  27390. static set AmbientTextureEnabled(value: boolean);
  27391. /**
  27392. * Are opacity textures enabled in the application.
  27393. */
  27394. static get OpacityTextureEnabled(): boolean;
  27395. static set OpacityTextureEnabled(value: boolean);
  27396. /**
  27397. * Are reflection textures enabled in the application.
  27398. */
  27399. static get ReflectionTextureEnabled(): boolean;
  27400. static set ReflectionTextureEnabled(value: boolean);
  27401. /**
  27402. * Are emissive textures enabled in the application.
  27403. */
  27404. static get EmissiveTextureEnabled(): boolean;
  27405. static set EmissiveTextureEnabled(value: boolean);
  27406. /**
  27407. * Are specular textures enabled in the application.
  27408. */
  27409. static get SpecularTextureEnabled(): boolean;
  27410. static set SpecularTextureEnabled(value: boolean);
  27411. /**
  27412. * Are bump textures enabled in the application.
  27413. */
  27414. static get BumpTextureEnabled(): boolean;
  27415. static set BumpTextureEnabled(value: boolean);
  27416. /**
  27417. * Are lightmap textures enabled in the application.
  27418. */
  27419. static get LightmapTextureEnabled(): boolean;
  27420. static set LightmapTextureEnabled(value: boolean);
  27421. /**
  27422. * Are refraction textures enabled in the application.
  27423. */
  27424. static get RefractionTextureEnabled(): boolean;
  27425. static set RefractionTextureEnabled(value: boolean);
  27426. /**
  27427. * Are color grading textures enabled in the application.
  27428. */
  27429. static get ColorGradingTextureEnabled(): boolean;
  27430. static set ColorGradingTextureEnabled(value: boolean);
  27431. /**
  27432. * Are fresnels enabled in the application.
  27433. */
  27434. static get FresnelEnabled(): boolean;
  27435. static set FresnelEnabled(value: boolean);
  27436. }
  27437. }
  27438. declare module BABYLON {
  27439. /**
  27440. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27441. *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.
  27442. * The SPS is also a particle system. It provides some methods to manage the particles.
  27443. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27444. *
  27445. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27446. */
  27447. export class SolidParticleSystem implements IDisposable {
  27448. /**
  27449. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27450. * Example : var p = SPS.particles[i];
  27451. */
  27452. particles: SolidParticle[];
  27453. /**
  27454. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27455. */
  27456. nbParticles: number;
  27457. /**
  27458. * If the particles must ever face the camera (default false). Useful for planar particles.
  27459. */
  27460. billboard: boolean;
  27461. /**
  27462. * Recompute normals when adding a shape
  27463. */
  27464. recomputeNormals: boolean;
  27465. /**
  27466. * This a counter ofr your own usage. It's not set by any SPS functions.
  27467. */
  27468. counter: number;
  27469. /**
  27470. * The SPS name. This name is also given to the underlying mesh.
  27471. */
  27472. name: string;
  27473. /**
  27474. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27475. */
  27476. mesh: Mesh;
  27477. /**
  27478. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27479. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27480. */
  27481. vars: any;
  27482. /**
  27483. * This array is populated when the SPS is set as 'pickable'.
  27484. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27485. * Each element of this array is an object `{idx: int, faceId: int}`.
  27486. * `idx` is the picked particle index in the `SPS.particles` array
  27487. * `faceId` is the picked face index counted within this particle.
  27488. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27489. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27490. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27491. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27492. */
  27493. pickedParticles: {
  27494. idx: number;
  27495. faceId: number;
  27496. }[];
  27497. /**
  27498. * This array is populated when the SPS is set as 'pickable'
  27499. * Each key of this array is a submesh index.
  27500. * Each element of this array is a second array defined like this :
  27501. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27502. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27503. * `idx` is the picked particle index in the `SPS.particles` array
  27504. * `faceId` is the picked face index counted within this particle.
  27505. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27506. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27507. */
  27508. pickedBySubMesh: {
  27509. idx: number;
  27510. faceId: number;
  27511. }[][];
  27512. /**
  27513. * This array is populated when `enableDepthSort` is set to true.
  27514. * Each element of this array is an instance of the class DepthSortedParticle.
  27515. */
  27516. depthSortedParticles: DepthSortedParticle[];
  27517. /**
  27518. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27519. * @hidden
  27520. */
  27521. _bSphereOnly: boolean;
  27522. /**
  27523. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27524. * @hidden
  27525. */
  27526. _bSphereRadiusFactor: number;
  27527. private _scene;
  27528. private _positions;
  27529. private _indices;
  27530. private _normals;
  27531. private _colors;
  27532. private _uvs;
  27533. private _indices32;
  27534. private _positions32;
  27535. private _normals32;
  27536. private _fixedNormal32;
  27537. private _colors32;
  27538. private _uvs32;
  27539. private _index;
  27540. private _updatable;
  27541. private _pickable;
  27542. private _isVisibilityBoxLocked;
  27543. private _alwaysVisible;
  27544. private _depthSort;
  27545. private _expandable;
  27546. private _shapeCounter;
  27547. private _copy;
  27548. private _color;
  27549. private _computeParticleColor;
  27550. private _computeParticleTexture;
  27551. private _computeParticleRotation;
  27552. private _computeParticleVertex;
  27553. private _computeBoundingBox;
  27554. private _depthSortParticles;
  27555. private _camera;
  27556. private _mustUnrotateFixedNormals;
  27557. private _particlesIntersect;
  27558. private _needs32Bits;
  27559. private _isNotBuilt;
  27560. private _lastParticleId;
  27561. private _idxOfId;
  27562. private _multimaterialEnabled;
  27563. private _useModelMaterial;
  27564. private _indicesByMaterial;
  27565. private _materialIndexes;
  27566. private _depthSortFunction;
  27567. private _materialSortFunction;
  27568. private _materials;
  27569. private _multimaterial;
  27570. private _materialIndexesById;
  27571. private _defaultMaterial;
  27572. private _autoUpdateSubMeshes;
  27573. private _tmpVertex;
  27574. /**
  27575. * Creates a SPS (Solid Particle System) object.
  27576. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27577. * @param scene (Scene) is the scene in which the SPS is added.
  27578. * @param options defines the options of the sps e.g.
  27579. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27580. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27581. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27582. * * 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.
  27583. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27584. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27585. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27586. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27587. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27588. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27589. */
  27590. constructor(name: string, scene: Scene, options?: {
  27591. updatable?: boolean;
  27592. isPickable?: boolean;
  27593. enableDepthSort?: boolean;
  27594. particleIntersection?: boolean;
  27595. boundingSphereOnly?: boolean;
  27596. bSphereRadiusFactor?: number;
  27597. expandable?: boolean;
  27598. useModelMaterial?: boolean;
  27599. enableMultiMaterial?: boolean;
  27600. });
  27601. /**
  27602. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27603. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27604. * @returns the created mesh
  27605. */
  27606. buildMesh(): Mesh;
  27607. /**
  27608. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27609. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27610. * Thus the particles generated from `digest()` have their property `position` set yet.
  27611. * @param mesh ( Mesh ) is the mesh to be digested
  27612. * @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
  27613. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27614. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27615. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27616. * @returns the current SPS
  27617. */
  27618. digest(mesh: Mesh, options?: {
  27619. facetNb?: number;
  27620. number?: number;
  27621. delta?: number;
  27622. storage?: [];
  27623. }): SolidParticleSystem;
  27624. /**
  27625. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27626. * @hidden
  27627. */
  27628. private _unrotateFixedNormals;
  27629. /**
  27630. * Resets the temporary working copy particle
  27631. * @hidden
  27632. */
  27633. private _resetCopy;
  27634. /**
  27635. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27636. * @param p the current index in the positions array to be updated
  27637. * @param ind the current index in the indices array
  27638. * @param shape a Vector3 array, the shape geometry
  27639. * @param positions the positions array to be updated
  27640. * @param meshInd the shape indices array
  27641. * @param indices the indices array to be updated
  27642. * @param meshUV the shape uv array
  27643. * @param uvs the uv array to be updated
  27644. * @param meshCol the shape color array
  27645. * @param colors the color array to be updated
  27646. * @param meshNor the shape normals array
  27647. * @param normals the normals array to be updated
  27648. * @param idx the particle index
  27649. * @param idxInShape the particle index in its shape
  27650. * @param options the addShape() method passed options
  27651. * @model the particle model
  27652. * @hidden
  27653. */
  27654. private _meshBuilder;
  27655. /**
  27656. * Returns a shape Vector3 array from positions float array
  27657. * @param positions float array
  27658. * @returns a vector3 array
  27659. * @hidden
  27660. */
  27661. private _posToShape;
  27662. /**
  27663. * Returns a shapeUV array from a float uvs (array deep copy)
  27664. * @param uvs as a float array
  27665. * @returns a shapeUV array
  27666. * @hidden
  27667. */
  27668. private _uvsToShapeUV;
  27669. /**
  27670. * Adds a new particle object in the particles array
  27671. * @param idx particle index in particles array
  27672. * @param id particle id
  27673. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27674. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27675. * @param model particle ModelShape object
  27676. * @param shapeId model shape identifier
  27677. * @param idxInShape index of the particle in the current model
  27678. * @param bInfo model bounding info object
  27679. * @param storage target storage array, if any
  27680. * @hidden
  27681. */
  27682. private _addParticle;
  27683. /**
  27684. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27685. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27686. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27687. * @param nb (positive integer) the number of particles to be created from this model
  27688. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27689. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27690. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27691. * @returns the number of shapes in the system
  27692. */
  27693. addShape(mesh: Mesh, nb: number, options?: {
  27694. positionFunction?: any;
  27695. vertexFunction?: any;
  27696. storage?: [];
  27697. }): number;
  27698. /**
  27699. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27700. * @hidden
  27701. */
  27702. private _rebuildParticle;
  27703. /**
  27704. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27705. * @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.
  27706. * @returns the SPS.
  27707. */
  27708. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27709. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27710. * Returns an array with the removed particles.
  27711. * 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.
  27712. * The SPS can't be empty so at least one particle needs to remain in place.
  27713. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27714. * @param start index of the first particle to remove
  27715. * @param end index of the last particle to remove (included)
  27716. * @returns an array populated with the removed particles
  27717. */
  27718. removeParticles(start: number, end: number): SolidParticle[];
  27719. /**
  27720. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27721. * @param solidParticleArray an array populated with Solid Particles objects
  27722. * @returns the SPS
  27723. */
  27724. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27725. /**
  27726. * Creates a new particle and modifies the SPS mesh geometry :
  27727. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27728. * - calls _addParticle() to populate the particle array
  27729. * factorized code from addShape() and insertParticlesFromArray()
  27730. * @param idx particle index in the particles array
  27731. * @param i particle index in its shape
  27732. * @param modelShape particle ModelShape object
  27733. * @param shape shape vertex array
  27734. * @param meshInd shape indices array
  27735. * @param meshUV shape uv array
  27736. * @param meshCol shape color array
  27737. * @param meshNor shape normals array
  27738. * @param bbInfo shape bounding info
  27739. * @param storage target particle storage
  27740. * @options addShape() passed options
  27741. * @hidden
  27742. */
  27743. private _insertNewParticle;
  27744. /**
  27745. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27746. * This method calls `updateParticle()` for each particle of the SPS.
  27747. * For an animated SPS, it is usually called within the render loop.
  27748. * 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.
  27749. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27750. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27751. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27752. * @returns the SPS.
  27753. */
  27754. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27755. /**
  27756. * Disposes the SPS.
  27757. */
  27758. dispose(): void;
  27759. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27760. * idx is the particle index in the SPS
  27761. * faceId is the picked face index counted within this particle.
  27762. * Returns null if the pickInfo can't identify a picked particle.
  27763. * @param pickingInfo (PickingInfo object)
  27764. * @returns {idx: number, faceId: number} or null
  27765. */
  27766. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27767. idx: number;
  27768. faceId: number;
  27769. }>;
  27770. /**
  27771. * Returns a SolidParticle object from its identifier : particle.id
  27772. * @param id (integer) the particle Id
  27773. * @returns the searched particle or null if not found in the SPS.
  27774. */
  27775. getParticleById(id: number): Nullable<SolidParticle>;
  27776. /**
  27777. * Returns a new array populated with the particles having the passed shapeId.
  27778. * @param shapeId (integer) the shape identifier
  27779. * @returns a new solid particle array
  27780. */
  27781. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27782. /**
  27783. * Populates the passed array "ref" with the particles having the passed shapeId.
  27784. * @param shapeId the shape identifier
  27785. * @returns the SPS
  27786. * @param ref
  27787. */
  27788. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27789. /**
  27790. * Computes the required SubMeshes according the materials assigned to the particles.
  27791. * @returns the solid particle system.
  27792. * Does nothing if called before the SPS mesh is built.
  27793. */
  27794. computeSubMeshes(): SolidParticleSystem;
  27795. /**
  27796. * Sorts the solid particles by material when MultiMaterial is enabled.
  27797. * Updates the indices32 array.
  27798. * Updates the indicesByMaterial array.
  27799. * Updates the mesh indices array.
  27800. * @returns the SPS
  27801. * @hidden
  27802. */
  27803. private _sortParticlesByMaterial;
  27804. /**
  27805. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27806. * @hidden
  27807. */
  27808. private _setMaterialIndexesById;
  27809. /**
  27810. * Returns an array with unique values of Materials from the passed array
  27811. * @param array the material array to be checked and filtered
  27812. * @hidden
  27813. */
  27814. private _filterUniqueMaterialId;
  27815. /**
  27816. * Sets a new Standard Material as _defaultMaterial if not already set.
  27817. * @hidden
  27818. */
  27819. private _setDefaultMaterial;
  27820. /**
  27821. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27823. * @returns the SPS.
  27824. */
  27825. refreshVisibleSize(): SolidParticleSystem;
  27826. /**
  27827. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27828. * @param size the size (float) of the visibility box
  27829. * note : this doesn't lock the SPS mesh bounding box.
  27830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27831. */
  27832. setVisibilityBox(size: number): void;
  27833. /**
  27834. * Gets whether the SPS as always visible or not
  27835. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27836. */
  27837. get isAlwaysVisible(): boolean;
  27838. /**
  27839. * Sets the SPS as always visible or not
  27840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27841. */
  27842. set isAlwaysVisible(val: boolean);
  27843. /**
  27844. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27845. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27846. */
  27847. set isVisibilityBoxLocked(val: boolean);
  27848. /**
  27849. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27850. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27851. */
  27852. get isVisibilityBoxLocked(): boolean;
  27853. /**
  27854. * Tells to `setParticles()` to compute the particle rotations or not.
  27855. * Default value : true. The SPS is faster when it's set to false.
  27856. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27857. */
  27858. set computeParticleRotation(val: boolean);
  27859. /**
  27860. * Tells to `setParticles()` to compute the particle colors or not.
  27861. * Default value : true. The SPS is faster when it's set to false.
  27862. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27863. */
  27864. set computeParticleColor(val: boolean);
  27865. set computeParticleTexture(val: boolean);
  27866. /**
  27867. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27868. * Default value : false. The SPS is faster when it's set to false.
  27869. * Note : the particle custom vertex positions aren't stored values.
  27870. */
  27871. set computeParticleVertex(val: boolean);
  27872. /**
  27873. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27874. */
  27875. set computeBoundingBox(val: boolean);
  27876. /**
  27877. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27878. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27879. * Default : `true`
  27880. */
  27881. set depthSortParticles(val: boolean);
  27882. /**
  27883. * Gets if `setParticles()` computes the particle rotations or not.
  27884. * Default value : true. The SPS is faster when it's set to false.
  27885. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27886. */
  27887. get computeParticleRotation(): boolean;
  27888. /**
  27889. * Gets if `setParticles()` computes the particle colors or not.
  27890. * Default value : true. The SPS is faster when it's set to false.
  27891. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27892. */
  27893. get computeParticleColor(): boolean;
  27894. /**
  27895. * Gets if `setParticles()` computes the particle textures or not.
  27896. * Default value : true. The SPS is faster when it's set to false.
  27897. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27898. */
  27899. get computeParticleTexture(): boolean;
  27900. /**
  27901. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27902. * Default value : false. The SPS is faster when it's set to false.
  27903. * Note : the particle custom vertex positions aren't stored values.
  27904. */
  27905. get computeParticleVertex(): boolean;
  27906. /**
  27907. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27908. */
  27909. get computeBoundingBox(): boolean;
  27910. /**
  27911. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27912. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27913. * Default : `true`
  27914. */
  27915. get depthSortParticles(): boolean;
  27916. /**
  27917. * Gets if the SPS is created as expandable at construction time.
  27918. * Default : `false`
  27919. */
  27920. get expandable(): boolean;
  27921. /**
  27922. * Gets if the SPS supports the Multi Materials
  27923. */
  27924. get multimaterialEnabled(): boolean;
  27925. /**
  27926. * Gets if the SPS uses the model materials for its own multimaterial.
  27927. */
  27928. get useModelMaterial(): boolean;
  27929. /**
  27930. * The SPS used material array.
  27931. */
  27932. get materials(): Material[];
  27933. /**
  27934. * Sets the SPS MultiMaterial from the passed materials.
  27935. * Note : the passed array is internally copied and not used then by reference.
  27936. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27937. */
  27938. setMultiMaterial(materials: Material[]): void;
  27939. /**
  27940. * The SPS computed multimaterial object
  27941. */
  27942. get multimaterial(): MultiMaterial;
  27943. set multimaterial(mm: MultiMaterial);
  27944. /**
  27945. * If the subMeshes must be updated on the next call to setParticles()
  27946. */
  27947. get autoUpdateSubMeshes(): boolean;
  27948. set autoUpdateSubMeshes(val: boolean);
  27949. /**
  27950. * This function does nothing. It may be overwritten to set all the particle first values.
  27951. * The SPS doesn't call this function, you may have to call it by your own.
  27952. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27953. */
  27954. initParticles(): void;
  27955. /**
  27956. * This function does nothing. It may be overwritten to recycle a particle.
  27957. * The SPS doesn't call this function, you may have to call it by your own.
  27958. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27959. * @param particle The particle to recycle
  27960. * @returns the recycled particle
  27961. */
  27962. recycleParticle(particle: SolidParticle): SolidParticle;
  27963. /**
  27964. * Updates a particle : this function should be overwritten by the user.
  27965. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27966. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27967. * @example : just set a particle position or velocity and recycle conditions
  27968. * @param particle The particle to update
  27969. * @returns the updated particle
  27970. */
  27971. updateParticle(particle: SolidParticle): SolidParticle;
  27972. /**
  27973. * Updates a vertex of a particle : it can be overwritten by the user.
  27974. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27975. * @param particle the current particle
  27976. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  27977. * @param pt the index of the current vertex in the particle shape
  27978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27979. * @example : just set a vertex particle position or color
  27980. * @returns the sps
  27981. */
  27982. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  27983. /**
  27984. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27985. * This does nothing and may be overwritten by the user.
  27986. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27987. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27988. * @param update the boolean update value actually passed to setParticles()
  27989. */
  27990. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27991. /**
  27992. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27993. * This will be passed three parameters.
  27994. * This does nothing and may be overwritten by the user.
  27995. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27996. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27997. * @param update the boolean update value actually passed to setParticles()
  27998. */
  27999. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28000. }
  28001. }
  28002. declare module BABYLON {
  28003. /**
  28004. * Represents one particle of a solid particle system.
  28005. */
  28006. export class SolidParticle {
  28007. /**
  28008. * particle global index
  28009. */
  28010. idx: number;
  28011. /**
  28012. * particle identifier
  28013. */
  28014. id: number;
  28015. /**
  28016. * The color of the particle
  28017. */
  28018. color: Nullable<Color4>;
  28019. /**
  28020. * The world space position of the particle.
  28021. */
  28022. position: Vector3;
  28023. /**
  28024. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28025. */
  28026. rotation: Vector3;
  28027. /**
  28028. * The world space rotation quaternion of the particle.
  28029. */
  28030. rotationQuaternion: Nullable<Quaternion>;
  28031. /**
  28032. * The scaling of the particle.
  28033. */
  28034. scaling: Vector3;
  28035. /**
  28036. * The uvs of the particle.
  28037. */
  28038. uvs: Vector4;
  28039. /**
  28040. * The current speed of the particle.
  28041. */
  28042. velocity: Vector3;
  28043. /**
  28044. * The pivot point in the particle local space.
  28045. */
  28046. pivot: Vector3;
  28047. /**
  28048. * Must the particle be translated from its pivot point in its local space ?
  28049. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28050. * Default : false
  28051. */
  28052. translateFromPivot: boolean;
  28053. /**
  28054. * Is the particle active or not ?
  28055. */
  28056. alive: boolean;
  28057. /**
  28058. * Is the particle visible or not ?
  28059. */
  28060. isVisible: boolean;
  28061. /**
  28062. * Index of this particle in the global "positions" array (Internal use)
  28063. * @hidden
  28064. */
  28065. _pos: number;
  28066. /**
  28067. * @hidden Index of this particle in the global "indices" array (Internal use)
  28068. */
  28069. _ind: number;
  28070. /**
  28071. * @hidden ModelShape of this particle (Internal use)
  28072. */
  28073. _model: ModelShape;
  28074. /**
  28075. * ModelShape id of this particle
  28076. */
  28077. shapeId: number;
  28078. /**
  28079. * Index of the particle in its shape id
  28080. */
  28081. idxInShape: number;
  28082. /**
  28083. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28084. */
  28085. _modelBoundingInfo: BoundingInfo;
  28086. /**
  28087. * @hidden Particle BoundingInfo object (Internal use)
  28088. */
  28089. _boundingInfo: BoundingInfo;
  28090. /**
  28091. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28092. */
  28093. _sps: SolidParticleSystem;
  28094. /**
  28095. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28096. */
  28097. _stillInvisible: boolean;
  28098. /**
  28099. * @hidden Last computed particle rotation matrix
  28100. */
  28101. _rotationMatrix: number[];
  28102. /**
  28103. * Parent particle Id, if any.
  28104. * Default null.
  28105. */
  28106. parentId: Nullable<number>;
  28107. /**
  28108. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28109. */
  28110. materialIndex: Nullable<number>;
  28111. /**
  28112. * Custom object or properties.
  28113. */
  28114. props: Nullable<any>;
  28115. /**
  28116. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28117. * The possible values are :
  28118. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28119. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28120. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28121. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28122. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28123. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28124. * */
  28125. cullingStrategy: number;
  28126. /**
  28127. * @hidden Internal global position in the SPS.
  28128. */
  28129. _globalPosition: Vector3;
  28130. /**
  28131. * Creates a Solid Particle object.
  28132. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28133. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28134. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28135. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28136. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28137. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28138. * @param shapeId (integer) is the model shape identifier in the SPS.
  28139. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28140. * @param sps defines the sps it is associated to
  28141. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28142. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28143. */
  28144. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28145. /**
  28146. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28147. * @param target the particle target
  28148. * @returns the current particle
  28149. */
  28150. copyToRef(target: SolidParticle): SolidParticle;
  28151. /**
  28152. * Legacy support, changed scale to scaling
  28153. */
  28154. get scale(): Vector3;
  28155. /**
  28156. * Legacy support, changed scale to scaling
  28157. */
  28158. set scale(scale: Vector3);
  28159. /**
  28160. * Legacy support, changed quaternion to rotationQuaternion
  28161. */
  28162. get quaternion(): Nullable<Quaternion>;
  28163. /**
  28164. * Legacy support, changed quaternion to rotationQuaternion
  28165. */
  28166. set quaternion(q: Nullable<Quaternion>);
  28167. /**
  28168. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28169. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28170. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28171. * @returns true if it intersects
  28172. */
  28173. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28174. /**
  28175. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28176. * A particle is in the frustum if its bounding box intersects the frustum
  28177. * @param frustumPlanes defines the frustum to test
  28178. * @returns true if the particle is in the frustum planes
  28179. */
  28180. isInFrustum(frustumPlanes: Plane[]): boolean;
  28181. /**
  28182. * get the rotation matrix of the particle
  28183. * @hidden
  28184. */
  28185. getRotationMatrix(m: Matrix): void;
  28186. }
  28187. /**
  28188. * Represents the shape of the model used by one particle of a solid particle system.
  28189. * SPS internal tool, don't use it manually.
  28190. */
  28191. export class ModelShape {
  28192. /**
  28193. * The shape id
  28194. * @hidden
  28195. */
  28196. shapeID: number;
  28197. /**
  28198. * flat array of model positions (internal use)
  28199. * @hidden
  28200. */
  28201. _shape: Vector3[];
  28202. /**
  28203. * flat array of model UVs (internal use)
  28204. * @hidden
  28205. */
  28206. _shapeUV: number[];
  28207. /**
  28208. * color array of the model
  28209. * @hidden
  28210. */
  28211. _shapeColors: number[];
  28212. /**
  28213. * indices array of the model
  28214. * @hidden
  28215. */
  28216. _indices: number[];
  28217. /**
  28218. * normals array of the model
  28219. * @hidden
  28220. */
  28221. _normals: number[];
  28222. /**
  28223. * length of the shape in the model indices array (internal use)
  28224. * @hidden
  28225. */
  28226. _indicesLength: number;
  28227. /**
  28228. * Custom position function (internal use)
  28229. * @hidden
  28230. */
  28231. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28232. /**
  28233. * Custom vertex function (internal use)
  28234. * @hidden
  28235. */
  28236. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28237. /**
  28238. * Model material (internal use)
  28239. * @hidden
  28240. */
  28241. _material: Nullable<Material>;
  28242. /**
  28243. * 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.
  28244. * SPS internal tool, don't use it manually.
  28245. * @hidden
  28246. */
  28247. 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>);
  28248. }
  28249. /**
  28250. * Represents a Depth Sorted Particle in the solid particle system.
  28251. * @hidden
  28252. */
  28253. export class DepthSortedParticle {
  28254. /**
  28255. * Particle index
  28256. */
  28257. idx: number;
  28258. /**
  28259. * Index of the particle in the "indices" array
  28260. */
  28261. ind: number;
  28262. /**
  28263. * Length of the particle shape in the "indices" array
  28264. */
  28265. indicesLength: number;
  28266. /**
  28267. * Squared distance from the particle to the camera
  28268. */
  28269. sqDistance: number;
  28270. /**
  28271. * Material index when used with MultiMaterials
  28272. */
  28273. materialIndex: number;
  28274. /**
  28275. * Creates a new sorted particle
  28276. * @param materialIndex
  28277. */
  28278. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28279. }
  28280. /**
  28281. * Represents a solid particle vertex
  28282. */
  28283. export class SolidParticleVertex {
  28284. /**
  28285. * Vertex position
  28286. */
  28287. position: Vector3;
  28288. /**
  28289. * Vertex color
  28290. */
  28291. color: Color4;
  28292. /**
  28293. * Vertex UV
  28294. */
  28295. uv: Vector2;
  28296. /**
  28297. * Creates a new solid particle vertex
  28298. */
  28299. constructor();
  28300. /** Vertex x coordinate */
  28301. get x(): number;
  28302. set x(val: number);
  28303. /** Vertex y coordinate */
  28304. get y(): number;
  28305. set y(val: number);
  28306. /** Vertex z coordinate */
  28307. get z(): number;
  28308. set z(val: number);
  28309. }
  28310. }
  28311. declare module BABYLON {
  28312. /**
  28313. * @hidden
  28314. */
  28315. export class _MeshCollisionData {
  28316. _checkCollisions: boolean;
  28317. _collisionMask: number;
  28318. _collisionGroup: number;
  28319. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28320. _collider: Nullable<Collider>;
  28321. _oldPositionForCollisions: Vector3;
  28322. _diffPositionForCollisions: Vector3;
  28323. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28324. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28325. }
  28326. }
  28327. declare module BABYLON {
  28328. /** @hidden */
  28329. class _FacetDataStorage {
  28330. facetPositions: Vector3[];
  28331. facetNormals: Vector3[];
  28332. facetPartitioning: number[][];
  28333. facetNb: number;
  28334. partitioningSubdivisions: number;
  28335. partitioningBBoxRatio: number;
  28336. facetDataEnabled: boolean;
  28337. facetParameters: any;
  28338. bbSize: Vector3;
  28339. subDiv: {
  28340. max: number;
  28341. X: number;
  28342. Y: number;
  28343. Z: number;
  28344. };
  28345. facetDepthSort: boolean;
  28346. facetDepthSortEnabled: boolean;
  28347. depthSortedIndices: IndicesArray;
  28348. depthSortedFacets: {
  28349. ind: number;
  28350. sqDistance: number;
  28351. }[];
  28352. facetDepthSortFunction: (f1: {
  28353. ind: number;
  28354. sqDistance: number;
  28355. }, f2: {
  28356. ind: number;
  28357. sqDistance: number;
  28358. }) => number;
  28359. facetDepthSortFrom: Vector3;
  28360. facetDepthSortOrigin: Vector3;
  28361. invertedMatrix: Matrix;
  28362. }
  28363. /**
  28364. * @hidden
  28365. **/
  28366. class _InternalAbstractMeshDataInfo {
  28367. _hasVertexAlpha: boolean;
  28368. _useVertexColors: boolean;
  28369. _numBoneInfluencers: number;
  28370. _applyFog: boolean;
  28371. _receiveShadows: boolean;
  28372. _facetData: _FacetDataStorage;
  28373. _visibility: number;
  28374. _skeleton: Nullable<Skeleton>;
  28375. _layerMask: number;
  28376. _computeBonesUsingShaders: boolean;
  28377. _isActive: boolean;
  28378. _onlyForInstances: boolean;
  28379. _isActiveIntermediate: boolean;
  28380. _onlyForInstancesIntermediate: boolean;
  28381. _actAsRegularMesh: boolean;
  28382. }
  28383. /**
  28384. * Class used to store all common mesh properties
  28385. */
  28386. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28387. /** No occlusion */
  28388. static OCCLUSION_TYPE_NONE: number;
  28389. /** Occlusion set to optimisitic */
  28390. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28391. /** Occlusion set to strict */
  28392. static OCCLUSION_TYPE_STRICT: number;
  28393. /** Use an accurante occlusion algorithm */
  28394. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28395. /** Use a conservative occlusion algorithm */
  28396. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28397. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28398. * Test order :
  28399. * Is the bounding sphere outside the frustum ?
  28400. * If not, are the bounding box vertices outside the frustum ?
  28401. * It not, then the cullable object is in the frustum.
  28402. */
  28403. static readonly CULLINGSTRATEGY_STANDARD: number;
  28404. /** Culling strategy : Bounding Sphere Only.
  28405. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28406. * It's also less accurate than the standard because some not visible objects can still be selected.
  28407. * Test : is the bounding sphere outside the frustum ?
  28408. * If not, then the cullable object is in the frustum.
  28409. */
  28410. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28411. /** Culling strategy : Optimistic Inclusion.
  28412. * This in an inclusion test first, then the standard exclusion test.
  28413. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28414. * 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.
  28415. * Anyway, it's as accurate as the standard strategy.
  28416. * Test :
  28417. * Is the cullable object bounding sphere center in the frustum ?
  28418. * If not, apply the default culling strategy.
  28419. */
  28420. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28421. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28422. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28423. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28424. * 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.
  28425. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28426. * Test :
  28427. * Is the cullable object bounding sphere center in the frustum ?
  28428. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28429. */
  28430. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28431. /**
  28432. * No billboard
  28433. */
  28434. static get BILLBOARDMODE_NONE(): number;
  28435. /** Billboard on X axis */
  28436. static get BILLBOARDMODE_X(): number;
  28437. /** Billboard on Y axis */
  28438. static get BILLBOARDMODE_Y(): number;
  28439. /** Billboard on Z axis */
  28440. static get BILLBOARDMODE_Z(): number;
  28441. /** Billboard on all axes */
  28442. static get BILLBOARDMODE_ALL(): number;
  28443. /** Billboard on using position instead of orientation */
  28444. static get BILLBOARDMODE_USE_POSITION(): number;
  28445. /** @hidden */
  28446. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28447. /**
  28448. * The culling strategy to use to check whether the mesh must be rendered or not.
  28449. * This value can be changed at any time and will be used on the next render mesh selection.
  28450. * The possible values are :
  28451. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28452. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28453. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28454. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28455. * Please read each static variable documentation to get details about the culling process.
  28456. * */
  28457. cullingStrategy: number;
  28458. /**
  28459. * Gets the number of facets in the mesh
  28460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28461. */
  28462. get facetNb(): number;
  28463. /**
  28464. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28466. */
  28467. get partitioningSubdivisions(): number;
  28468. set partitioningSubdivisions(nb: number);
  28469. /**
  28470. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28471. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28473. */
  28474. get partitioningBBoxRatio(): number;
  28475. set partitioningBBoxRatio(ratio: number);
  28476. /**
  28477. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28478. * Works only for updatable meshes.
  28479. * Doesn't work with multi-materials
  28480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28481. */
  28482. get mustDepthSortFacets(): boolean;
  28483. set mustDepthSortFacets(sort: boolean);
  28484. /**
  28485. * The location (Vector3) where the facet depth sort must be computed from.
  28486. * By default, the active camera position.
  28487. * Used only when facet depth sort is enabled
  28488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28489. */
  28490. get facetDepthSortFrom(): Vector3;
  28491. set facetDepthSortFrom(location: Vector3);
  28492. /**
  28493. * gets a boolean indicating if facetData is enabled
  28494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28495. */
  28496. get isFacetDataEnabled(): boolean;
  28497. /** @hidden */
  28498. _updateNonUniformScalingState(value: boolean): boolean;
  28499. /**
  28500. * An event triggered when this mesh collides with another one
  28501. */
  28502. onCollideObservable: Observable<AbstractMesh>;
  28503. /** Set a function to call when this mesh collides with another one */
  28504. set onCollide(callback: () => void);
  28505. /**
  28506. * An event triggered when the collision's position changes
  28507. */
  28508. onCollisionPositionChangeObservable: Observable<Vector3>;
  28509. /** Set a function to call when the collision's position changes */
  28510. set onCollisionPositionChange(callback: () => void);
  28511. /**
  28512. * An event triggered when material is changed
  28513. */
  28514. onMaterialChangedObservable: Observable<AbstractMesh>;
  28515. /**
  28516. * Gets or sets the orientation for POV movement & rotation
  28517. */
  28518. definedFacingForward: boolean;
  28519. /** @hidden */
  28520. _occlusionQuery: Nullable<WebGLQuery>;
  28521. /** @hidden */
  28522. _renderingGroup: Nullable<RenderingGroup>;
  28523. /**
  28524. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28525. */
  28526. get visibility(): number;
  28527. /**
  28528. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28529. */
  28530. set visibility(value: number);
  28531. /** Gets or sets the alpha index used to sort transparent meshes
  28532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28533. */
  28534. alphaIndex: number;
  28535. /**
  28536. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28537. */
  28538. isVisible: boolean;
  28539. /**
  28540. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28541. */
  28542. isPickable: boolean;
  28543. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28544. showSubMeshesBoundingBox: boolean;
  28545. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28546. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28547. */
  28548. isBlocker: boolean;
  28549. /**
  28550. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28551. */
  28552. enablePointerMoveEvents: boolean;
  28553. /**
  28554. * Specifies the rendering group id for this mesh (0 by default)
  28555. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28556. */
  28557. renderingGroupId: number;
  28558. private _material;
  28559. /** Gets or sets current material */
  28560. get material(): Nullable<Material>;
  28561. set material(value: Nullable<Material>);
  28562. /**
  28563. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28564. * @see http://doc.babylonjs.com/babylon101/shadows
  28565. */
  28566. get receiveShadows(): boolean;
  28567. set receiveShadows(value: boolean);
  28568. /** Defines color to use when rendering outline */
  28569. outlineColor: Color3;
  28570. /** Define width to use when rendering outline */
  28571. outlineWidth: number;
  28572. /** Defines color to use when rendering overlay */
  28573. overlayColor: Color3;
  28574. /** Defines alpha to use when rendering overlay */
  28575. overlayAlpha: number;
  28576. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28577. get hasVertexAlpha(): boolean;
  28578. set hasVertexAlpha(value: boolean);
  28579. /** 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) */
  28580. get useVertexColors(): boolean;
  28581. set useVertexColors(value: boolean);
  28582. /**
  28583. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28584. */
  28585. get computeBonesUsingShaders(): boolean;
  28586. set computeBonesUsingShaders(value: boolean);
  28587. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28588. get numBoneInfluencers(): number;
  28589. set numBoneInfluencers(value: number);
  28590. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28591. get applyFog(): boolean;
  28592. set applyFog(value: boolean);
  28593. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28594. useOctreeForRenderingSelection: boolean;
  28595. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28596. useOctreeForPicking: boolean;
  28597. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28598. useOctreeForCollisions: boolean;
  28599. /**
  28600. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28601. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28602. */
  28603. get layerMask(): number;
  28604. set layerMask(value: number);
  28605. /**
  28606. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28607. */
  28608. alwaysSelectAsActiveMesh: boolean;
  28609. /**
  28610. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28611. */
  28612. doNotSyncBoundingInfo: boolean;
  28613. /**
  28614. * Gets or sets the current action manager
  28615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28616. */
  28617. actionManager: Nullable<AbstractActionManager>;
  28618. private _meshCollisionData;
  28619. /**
  28620. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28622. */
  28623. ellipsoid: Vector3;
  28624. /**
  28625. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28627. */
  28628. ellipsoidOffset: Vector3;
  28629. /**
  28630. * Gets or sets a collision mask used to mask collisions (default is -1).
  28631. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28632. */
  28633. get collisionMask(): number;
  28634. set collisionMask(mask: number);
  28635. /**
  28636. * Gets or sets the current collision group mask (-1 by default).
  28637. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28638. */
  28639. get collisionGroup(): number;
  28640. set collisionGroup(mask: number);
  28641. /**
  28642. * Gets or sets current surrounding meshes (null by default).
  28643. *
  28644. * By default collision detection is tested against every mesh in the scene.
  28645. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28646. * meshes will be tested for the collision.
  28647. *
  28648. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28649. */
  28650. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28651. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28652. /**
  28653. * Defines edge width used when edgesRenderer is enabled
  28654. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28655. */
  28656. edgesWidth: number;
  28657. /**
  28658. * Defines edge color used when edgesRenderer is enabled
  28659. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28660. */
  28661. edgesColor: Color4;
  28662. /** @hidden */
  28663. _edgesRenderer: Nullable<IEdgesRenderer>;
  28664. /** @hidden */
  28665. _masterMesh: Nullable<AbstractMesh>;
  28666. /** @hidden */
  28667. _boundingInfo: Nullable<BoundingInfo>;
  28668. /** @hidden */
  28669. _renderId: number;
  28670. /**
  28671. * Gets or sets the list of subMeshes
  28672. * @see http://doc.babylonjs.com/how_to/multi_materials
  28673. */
  28674. subMeshes: SubMesh[];
  28675. /** @hidden */
  28676. _intersectionsInProgress: AbstractMesh[];
  28677. /** @hidden */
  28678. _unIndexed: boolean;
  28679. /** @hidden */
  28680. _lightSources: Light[];
  28681. /** Gets the list of lights affecting that mesh */
  28682. get lightSources(): Light[];
  28683. /** @hidden */
  28684. get _positions(): Nullable<Vector3[]>;
  28685. /** @hidden */
  28686. _waitingData: {
  28687. lods: Nullable<any>;
  28688. actions: Nullable<any>;
  28689. freezeWorldMatrix: Nullable<boolean>;
  28690. };
  28691. /** @hidden */
  28692. _bonesTransformMatrices: Nullable<Float32Array>;
  28693. /** @hidden */
  28694. _transformMatrixTexture: Nullable<RawTexture>;
  28695. /**
  28696. * Gets or sets a skeleton to apply skining transformations
  28697. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28698. */
  28699. set skeleton(value: Nullable<Skeleton>);
  28700. get skeleton(): Nullable<Skeleton>;
  28701. /**
  28702. * An event triggered when the mesh is rebuilt.
  28703. */
  28704. onRebuildObservable: Observable<AbstractMesh>;
  28705. /**
  28706. * Creates a new AbstractMesh
  28707. * @param name defines the name of the mesh
  28708. * @param scene defines the hosting scene
  28709. */
  28710. constructor(name: string, scene?: Nullable<Scene>);
  28711. /**
  28712. * Returns the string "AbstractMesh"
  28713. * @returns "AbstractMesh"
  28714. */
  28715. getClassName(): string;
  28716. /**
  28717. * Gets a string representation of the current mesh
  28718. * @param fullDetails defines a boolean indicating if full details must be included
  28719. * @returns a string representation of the current mesh
  28720. */
  28721. toString(fullDetails?: boolean): string;
  28722. /**
  28723. * @hidden
  28724. */
  28725. protected _getEffectiveParent(): Nullable<Node>;
  28726. /** @hidden */
  28727. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28728. /** @hidden */
  28729. _rebuild(): void;
  28730. /** @hidden */
  28731. _resyncLightSources(): void;
  28732. /** @hidden */
  28733. _resyncLightSource(light: Light): void;
  28734. /** @hidden */
  28735. _unBindEffect(): void;
  28736. /** @hidden */
  28737. _removeLightSource(light: Light, dispose: boolean): void;
  28738. private _markSubMeshesAsDirty;
  28739. /** @hidden */
  28740. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28741. /** @hidden */
  28742. _markSubMeshesAsAttributesDirty(): void;
  28743. /** @hidden */
  28744. _markSubMeshesAsMiscDirty(): void;
  28745. /**
  28746. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28747. */
  28748. get scaling(): Vector3;
  28749. set scaling(newScaling: Vector3);
  28750. /**
  28751. * Returns true if the mesh is blocked. Implemented by child classes
  28752. */
  28753. get isBlocked(): boolean;
  28754. /**
  28755. * Returns the mesh itself by default. Implemented by child classes
  28756. * @param camera defines the camera to use to pick the right LOD level
  28757. * @returns the currentAbstractMesh
  28758. */
  28759. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28760. /**
  28761. * Returns 0 by default. Implemented by child classes
  28762. * @returns an integer
  28763. */
  28764. getTotalVertices(): number;
  28765. /**
  28766. * Returns a positive integer : the total number of indices in this mesh geometry.
  28767. * @returns the numner of indices or zero if the mesh has no geometry.
  28768. */
  28769. getTotalIndices(): number;
  28770. /**
  28771. * Returns null by default. Implemented by child classes
  28772. * @returns null
  28773. */
  28774. getIndices(): Nullable<IndicesArray>;
  28775. /**
  28776. * Returns the array of the requested vertex data kind. Implemented by child classes
  28777. * @param kind defines the vertex data kind to use
  28778. * @returns null
  28779. */
  28780. getVerticesData(kind: string): Nullable<FloatArray>;
  28781. /**
  28782. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28783. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28784. * Note that a new underlying VertexBuffer object is created each call.
  28785. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28786. * @param kind defines vertex data kind:
  28787. * * VertexBuffer.PositionKind
  28788. * * VertexBuffer.UVKind
  28789. * * VertexBuffer.UV2Kind
  28790. * * VertexBuffer.UV3Kind
  28791. * * VertexBuffer.UV4Kind
  28792. * * VertexBuffer.UV5Kind
  28793. * * VertexBuffer.UV6Kind
  28794. * * VertexBuffer.ColorKind
  28795. * * VertexBuffer.MatricesIndicesKind
  28796. * * VertexBuffer.MatricesIndicesExtraKind
  28797. * * VertexBuffer.MatricesWeightsKind
  28798. * * VertexBuffer.MatricesWeightsExtraKind
  28799. * @param data defines the data source
  28800. * @param updatable defines if the data must be flagged as updatable (or static)
  28801. * @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
  28802. * @returns the current mesh
  28803. */
  28804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28805. /**
  28806. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28807. * If the mesh has no geometry, it is simply returned as it is.
  28808. * @param kind defines vertex data kind:
  28809. * * VertexBuffer.PositionKind
  28810. * * VertexBuffer.UVKind
  28811. * * VertexBuffer.UV2Kind
  28812. * * VertexBuffer.UV3Kind
  28813. * * VertexBuffer.UV4Kind
  28814. * * VertexBuffer.UV5Kind
  28815. * * VertexBuffer.UV6Kind
  28816. * * VertexBuffer.ColorKind
  28817. * * VertexBuffer.MatricesIndicesKind
  28818. * * VertexBuffer.MatricesIndicesExtraKind
  28819. * * VertexBuffer.MatricesWeightsKind
  28820. * * VertexBuffer.MatricesWeightsExtraKind
  28821. * @param data defines the data source
  28822. * @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
  28823. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28824. * @returns the current mesh
  28825. */
  28826. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28827. /**
  28828. * Sets the mesh indices,
  28829. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28830. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28831. * @param totalVertices Defines the total number of vertices
  28832. * @returns the current mesh
  28833. */
  28834. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28835. /**
  28836. * Gets a boolean indicating if specific vertex data is present
  28837. * @param kind defines the vertex data kind to use
  28838. * @returns true is data kind is present
  28839. */
  28840. isVerticesDataPresent(kind: string): boolean;
  28841. /**
  28842. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28843. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28844. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28845. * @returns a BoundingInfo
  28846. */
  28847. getBoundingInfo(): BoundingInfo;
  28848. /**
  28849. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28850. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28851. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28852. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28853. * @returns the current mesh
  28854. */
  28855. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28856. /**
  28857. * Overwrite the current bounding info
  28858. * @param boundingInfo defines the new bounding info
  28859. * @returns the current mesh
  28860. */
  28861. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28862. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28863. get useBones(): boolean;
  28864. /** @hidden */
  28865. _preActivate(): void;
  28866. /** @hidden */
  28867. _preActivateForIntermediateRendering(renderId: number): void;
  28868. /** @hidden */
  28869. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28870. /** @hidden */
  28871. _postActivate(): void;
  28872. /** @hidden */
  28873. _freeze(): void;
  28874. /** @hidden */
  28875. _unFreeze(): void;
  28876. /**
  28877. * Gets the current world matrix
  28878. * @returns a Matrix
  28879. */
  28880. getWorldMatrix(): Matrix;
  28881. /** @hidden */
  28882. _getWorldMatrixDeterminant(): number;
  28883. /**
  28884. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28885. */
  28886. get isAnInstance(): boolean;
  28887. /**
  28888. * Gets a boolean indicating if this mesh has instances
  28889. */
  28890. get hasInstances(): boolean;
  28891. /**
  28892. * Perform relative position change from the point of view of behind the front of the mesh.
  28893. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28894. * Supports definition of mesh facing forward or backward
  28895. * @param amountRight defines the distance on the right axis
  28896. * @param amountUp defines the distance on the up axis
  28897. * @param amountForward defines the distance on the forward axis
  28898. * @returns the current mesh
  28899. */
  28900. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28901. /**
  28902. * Calculate relative position change from the point of view of behind the front of the mesh.
  28903. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28904. * Supports definition of mesh facing forward or backward
  28905. * @param amountRight defines the distance on the right axis
  28906. * @param amountUp defines the distance on the up axis
  28907. * @param amountForward defines the distance on the forward axis
  28908. * @returns the new displacement vector
  28909. */
  28910. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28911. /**
  28912. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28913. * Supports definition of mesh facing forward or backward
  28914. * @param flipBack defines the flip
  28915. * @param twirlClockwise defines the twirl
  28916. * @param tiltRight defines the tilt
  28917. * @returns the current mesh
  28918. */
  28919. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28920. /**
  28921. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28922. * Supports definition of mesh facing forward or backward.
  28923. * @param flipBack defines the flip
  28924. * @param twirlClockwise defines the twirl
  28925. * @param tiltRight defines the tilt
  28926. * @returns the new rotation vector
  28927. */
  28928. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28929. /**
  28930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28931. * This means the mesh underlying bounding box and sphere are recomputed.
  28932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28933. * @returns the current mesh
  28934. */
  28935. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28936. /** @hidden */
  28937. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28938. /** @hidden */
  28939. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28940. /** @hidden */
  28941. _updateBoundingInfo(): AbstractMesh;
  28942. /** @hidden */
  28943. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28944. /** @hidden */
  28945. protected _afterComputeWorldMatrix(): void;
  28946. /** @hidden */
  28947. get _effectiveMesh(): AbstractMesh;
  28948. /**
  28949. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28950. * A mesh is in the frustum if its bounding box intersects the frustum
  28951. * @param frustumPlanes defines the frustum to test
  28952. * @returns true if the mesh is in the frustum planes
  28953. */
  28954. isInFrustum(frustumPlanes: Plane[]): boolean;
  28955. /**
  28956. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28957. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28958. * @param frustumPlanes defines the frustum to test
  28959. * @returns true if the mesh is completely in the frustum planes
  28960. */
  28961. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28962. /**
  28963. * True if the mesh intersects another mesh or a SolidParticle object
  28964. * @param mesh defines a target mesh or SolidParticle to test
  28965. * @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)
  28966. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28967. * @returns true if there is an intersection
  28968. */
  28969. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28970. /**
  28971. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28972. * @param point defines the point to test
  28973. * @returns true if there is an intersection
  28974. */
  28975. intersectsPoint(point: Vector3): boolean;
  28976. /**
  28977. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28979. */
  28980. get checkCollisions(): boolean;
  28981. set checkCollisions(collisionEnabled: boolean);
  28982. /**
  28983. * Gets Collider object used to compute collisions (not physics)
  28984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28985. */
  28986. get collider(): Nullable<Collider>;
  28987. /**
  28988. * Move the mesh using collision engine
  28989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28990. * @param displacement defines the requested displacement vector
  28991. * @returns the current mesh
  28992. */
  28993. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28994. private _onCollisionPositionChange;
  28995. /** @hidden */
  28996. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28997. /** @hidden */
  28998. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28999. /** @hidden */
  29000. _checkCollision(collider: Collider): AbstractMesh;
  29001. /** @hidden */
  29002. _generatePointsArray(): boolean;
  29003. /**
  29004. * Checks if the passed Ray intersects with the mesh
  29005. * @param ray defines the ray to use
  29006. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29008. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29009. * @returns the picking info
  29010. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29011. */
  29012. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29013. /**
  29014. * Clones the current mesh
  29015. * @param name defines the mesh name
  29016. * @param newParent defines the new mesh parent
  29017. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29018. * @returns the new mesh
  29019. */
  29020. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29021. /**
  29022. * Disposes all the submeshes of the current meshnp
  29023. * @returns the current mesh
  29024. */
  29025. releaseSubMeshes(): AbstractMesh;
  29026. /**
  29027. * Releases resources associated with this abstract mesh.
  29028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29030. */
  29031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29032. /**
  29033. * Adds the passed mesh as a child to the current mesh
  29034. * @param mesh defines the child mesh
  29035. * @returns the current mesh
  29036. */
  29037. addChild(mesh: AbstractMesh): AbstractMesh;
  29038. /**
  29039. * Removes the passed mesh from the current mesh children list
  29040. * @param mesh defines the child mesh
  29041. * @returns the current mesh
  29042. */
  29043. removeChild(mesh: AbstractMesh): AbstractMesh;
  29044. /** @hidden */
  29045. private _initFacetData;
  29046. /**
  29047. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29048. * This method can be called within the render loop.
  29049. * 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
  29050. * @returns the current mesh
  29051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29052. */
  29053. updateFacetData(): AbstractMesh;
  29054. /**
  29055. * Returns the facetLocalNormals array.
  29056. * The normals are expressed in the mesh local spac
  29057. * @returns an array of Vector3
  29058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29059. */
  29060. getFacetLocalNormals(): Vector3[];
  29061. /**
  29062. * Returns the facetLocalPositions array.
  29063. * The facet positions are expressed in the mesh local space
  29064. * @returns an array of Vector3
  29065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29066. */
  29067. getFacetLocalPositions(): Vector3[];
  29068. /**
  29069. * Returns the facetLocalPartioning array
  29070. * @returns an array of array of numbers
  29071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29072. */
  29073. getFacetLocalPartitioning(): number[][];
  29074. /**
  29075. * Returns the i-th facet position in the world system.
  29076. * This method allocates a new Vector3 per call
  29077. * @param i defines the facet index
  29078. * @returns a new Vector3
  29079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29080. */
  29081. getFacetPosition(i: number): Vector3;
  29082. /**
  29083. * Sets the reference Vector3 with the i-th facet position in the world system
  29084. * @param i defines the facet index
  29085. * @param ref defines the target vector
  29086. * @returns the current mesh
  29087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29088. */
  29089. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29090. /**
  29091. * Returns the i-th facet normal in the world system.
  29092. * This method allocates a new Vector3 per call
  29093. * @param i defines the facet index
  29094. * @returns a new Vector3
  29095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29096. */
  29097. getFacetNormal(i: number): Vector3;
  29098. /**
  29099. * Sets the reference Vector3 with the i-th facet normal in the world system
  29100. * @param i defines the facet index
  29101. * @param ref defines the target vector
  29102. * @returns the current mesh
  29103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29104. */
  29105. getFacetNormalToRef(i: number, ref: Vector3): this;
  29106. /**
  29107. * 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)
  29108. * @param x defines x coordinate
  29109. * @param y defines y coordinate
  29110. * @param z defines z coordinate
  29111. * @returns the array of facet indexes
  29112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29113. */
  29114. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29115. /**
  29116. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29117. * @param projected sets as the (x,y,z) world projection on the facet
  29118. * @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
  29119. * @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
  29120. * @param x defines x coordinate
  29121. * @param y defines y coordinate
  29122. * @param z defines z coordinate
  29123. * @returns the face index if found (or null instead)
  29124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29125. */
  29126. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29127. /**
  29128. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29129. * @param projected sets as the (x,y,z) local projection on the facet
  29130. * @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
  29131. * @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
  29132. * @param x defines x coordinate
  29133. * @param y defines y coordinate
  29134. * @param z defines z coordinate
  29135. * @returns the face index if found (or null instead)
  29136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29137. */
  29138. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29139. /**
  29140. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29141. * @returns the parameters
  29142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29143. */
  29144. getFacetDataParameters(): any;
  29145. /**
  29146. * Disables the feature FacetData and frees the related memory
  29147. * @returns the current mesh
  29148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29149. */
  29150. disableFacetData(): AbstractMesh;
  29151. /**
  29152. * Updates the AbstractMesh indices array
  29153. * @param indices defines the data source
  29154. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29155. * @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)
  29156. * @returns the current mesh
  29157. */
  29158. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29159. /**
  29160. * Creates new normals data for the mesh
  29161. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29162. * @returns the current mesh
  29163. */
  29164. createNormals(updatable: boolean): AbstractMesh;
  29165. /**
  29166. * Align the mesh with a normal
  29167. * @param normal defines the normal to use
  29168. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29169. * @returns the current mesh
  29170. */
  29171. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29172. /** @hidden */
  29173. _checkOcclusionQuery(): boolean;
  29174. /**
  29175. * Disables the mesh edge rendering mode
  29176. * @returns the currentAbstractMesh
  29177. */
  29178. disableEdgesRendering(): AbstractMesh;
  29179. /**
  29180. * Enables the edge rendering mode on the mesh.
  29181. * This mode makes the mesh edges visible
  29182. * @param epsilon defines the maximal distance between two angles to detect a face
  29183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29184. * @returns the currentAbstractMesh
  29185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29186. */
  29187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29188. }
  29189. }
  29190. declare module BABYLON {
  29191. /**
  29192. * Interface used to define ActionEvent
  29193. */
  29194. export interface IActionEvent {
  29195. /** The mesh or sprite that triggered the action */
  29196. source: any;
  29197. /** The X mouse cursor position at the time of the event */
  29198. pointerX: number;
  29199. /** The Y mouse cursor position at the time of the event */
  29200. pointerY: number;
  29201. /** The mesh that is currently pointed at (can be null) */
  29202. meshUnderPointer: Nullable<AbstractMesh>;
  29203. /** the original (browser) event that triggered the ActionEvent */
  29204. sourceEvent?: any;
  29205. /** additional data for the event */
  29206. additionalData?: any;
  29207. }
  29208. /**
  29209. * ActionEvent is the event being sent when an action is triggered.
  29210. */
  29211. export class ActionEvent implements IActionEvent {
  29212. /** The mesh or sprite that triggered the action */
  29213. source: any;
  29214. /** The X mouse cursor position at the time of the event */
  29215. pointerX: number;
  29216. /** The Y mouse cursor position at the time of the event */
  29217. pointerY: number;
  29218. /** The mesh that is currently pointed at (can be null) */
  29219. meshUnderPointer: Nullable<AbstractMesh>;
  29220. /** the original (browser) event that triggered the ActionEvent */
  29221. sourceEvent?: any;
  29222. /** additional data for the event */
  29223. additionalData?: any;
  29224. /**
  29225. * Creates a new ActionEvent
  29226. * @param source The mesh or sprite that triggered the action
  29227. * @param pointerX The X mouse cursor position at the time of the event
  29228. * @param pointerY The Y mouse cursor position at the time of the event
  29229. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29230. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29231. * @param additionalData additional data for the event
  29232. */
  29233. constructor(
  29234. /** The mesh or sprite that triggered the action */
  29235. source: any,
  29236. /** The X mouse cursor position at the time of the event */
  29237. pointerX: number,
  29238. /** The Y mouse cursor position at the time of the event */
  29239. pointerY: number,
  29240. /** The mesh that is currently pointed at (can be null) */
  29241. meshUnderPointer: Nullable<AbstractMesh>,
  29242. /** the original (browser) event that triggered the ActionEvent */
  29243. sourceEvent?: any,
  29244. /** additional data for the event */
  29245. additionalData?: any);
  29246. /**
  29247. * Helper function to auto-create an ActionEvent from a source mesh.
  29248. * @param source The source mesh that triggered the event
  29249. * @param evt The original (browser) event
  29250. * @param additionalData additional data for the event
  29251. * @returns the new ActionEvent
  29252. */
  29253. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29254. /**
  29255. * Helper function to auto-create an ActionEvent from a source sprite
  29256. * @param source The source sprite that triggered the event
  29257. * @param scene Scene associated with the sprite
  29258. * @param evt The original (browser) event
  29259. * @param additionalData additional data for the event
  29260. * @returns the new ActionEvent
  29261. */
  29262. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29263. /**
  29264. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29265. * @param scene the scene where the event occurred
  29266. * @param evt The original (browser) event
  29267. * @returns the new ActionEvent
  29268. */
  29269. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29270. /**
  29271. * Helper function to auto-create an ActionEvent from a primitive
  29272. * @param prim defines the target primitive
  29273. * @param pointerPos defines the pointer position
  29274. * @param evt The original (browser) event
  29275. * @param additionalData additional data for the event
  29276. * @returns the new ActionEvent
  29277. */
  29278. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29279. }
  29280. }
  29281. declare module BABYLON {
  29282. /**
  29283. * Abstract class used to decouple action Manager from scene and meshes.
  29284. * Do not instantiate.
  29285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29286. */
  29287. export abstract class AbstractActionManager implements IDisposable {
  29288. /** Gets the list of active triggers */
  29289. static Triggers: {
  29290. [key: string]: number;
  29291. };
  29292. /** Gets the cursor to use when hovering items */
  29293. hoverCursor: string;
  29294. /** Gets the list of actions */
  29295. actions: IAction[];
  29296. /**
  29297. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29298. */
  29299. isRecursive: boolean;
  29300. /**
  29301. * Releases all associated resources
  29302. */
  29303. abstract dispose(): void;
  29304. /**
  29305. * Does this action manager has pointer triggers
  29306. */
  29307. abstract get hasPointerTriggers(): boolean;
  29308. /**
  29309. * Does this action manager has pick triggers
  29310. */
  29311. abstract get hasPickTriggers(): boolean;
  29312. /**
  29313. * Process a specific trigger
  29314. * @param trigger defines the trigger to process
  29315. * @param evt defines the event details to be processed
  29316. */
  29317. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29318. /**
  29319. * Does this action manager handles actions of any of the given triggers
  29320. * @param triggers defines the triggers to be tested
  29321. * @return a boolean indicating whether one (or more) of the triggers is handled
  29322. */
  29323. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29324. /**
  29325. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29326. * speed.
  29327. * @param triggerA defines the trigger to be tested
  29328. * @param triggerB defines the trigger to be tested
  29329. * @return a boolean indicating whether one (or more) of the triggers is handled
  29330. */
  29331. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29332. /**
  29333. * Does this action manager handles actions of a given trigger
  29334. * @param trigger defines the trigger to be tested
  29335. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29336. * @return whether the trigger is handled
  29337. */
  29338. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29339. /**
  29340. * Serialize this manager to a JSON object
  29341. * @param name defines the property name to store this manager
  29342. * @returns a JSON representation of this manager
  29343. */
  29344. abstract serialize(name: string): any;
  29345. /**
  29346. * Registers an action to this action manager
  29347. * @param action defines the action to be registered
  29348. * @return the action amended (prepared) after registration
  29349. */
  29350. abstract registerAction(action: IAction): Nullable<IAction>;
  29351. /**
  29352. * Unregisters an action to this action manager
  29353. * @param action defines the action to be unregistered
  29354. * @return a boolean indicating whether the action has been unregistered
  29355. */
  29356. abstract unregisterAction(action: IAction): Boolean;
  29357. /**
  29358. * Does exist one action manager with at least one trigger
  29359. **/
  29360. static get HasTriggers(): boolean;
  29361. /**
  29362. * Does exist one action manager with at least one pick trigger
  29363. **/
  29364. static get HasPickTriggers(): boolean;
  29365. /**
  29366. * Does exist one action manager that handles actions of a given trigger
  29367. * @param trigger defines the trigger to be tested
  29368. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29369. **/
  29370. static HasSpecificTrigger(trigger: number): boolean;
  29371. }
  29372. }
  29373. declare module BABYLON {
  29374. /**
  29375. * Defines how a node can be built from a string name.
  29376. */
  29377. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29378. /**
  29379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29380. */
  29381. export class Node implements IBehaviorAware<Node> {
  29382. /** @hidden */
  29383. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29384. private static _NodeConstructors;
  29385. /**
  29386. * Add a new node constructor
  29387. * @param type defines the type name of the node to construct
  29388. * @param constructorFunc defines the constructor function
  29389. */
  29390. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29391. /**
  29392. * Returns a node constructor based on type name
  29393. * @param type defines the type name
  29394. * @param name defines the new node name
  29395. * @param scene defines the hosting scene
  29396. * @param options defines optional options to transmit to constructors
  29397. * @returns the new constructor or null
  29398. */
  29399. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29400. /**
  29401. * Gets or sets the name of the node
  29402. */
  29403. name: string;
  29404. /**
  29405. * Gets or sets the id of the node
  29406. */
  29407. id: string;
  29408. /**
  29409. * Gets or sets the unique id of the node
  29410. */
  29411. uniqueId: number;
  29412. /**
  29413. * Gets or sets a string used to store user defined state for the node
  29414. */
  29415. state: string;
  29416. /**
  29417. * Gets or sets an object used to store user defined information for the node
  29418. */
  29419. metadata: any;
  29420. /**
  29421. * For internal use only. Please do not use.
  29422. */
  29423. reservedDataStore: any;
  29424. /**
  29425. * List of inspectable custom properties (used by the Inspector)
  29426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29427. */
  29428. inspectableCustomProperties: IInspectable[];
  29429. private _doNotSerialize;
  29430. /**
  29431. * Gets or sets a boolean used to define if the node must be serialized
  29432. */
  29433. get doNotSerialize(): boolean;
  29434. set doNotSerialize(value: boolean);
  29435. /** @hidden */
  29436. _isDisposed: boolean;
  29437. /**
  29438. * Gets a list of Animations associated with the node
  29439. */
  29440. animations: Animation[];
  29441. protected _ranges: {
  29442. [name: string]: Nullable<AnimationRange>;
  29443. };
  29444. /**
  29445. * Callback raised when the node is ready to be used
  29446. */
  29447. onReady: Nullable<(node: Node) => void>;
  29448. private _isEnabled;
  29449. private _isParentEnabled;
  29450. private _isReady;
  29451. /** @hidden */
  29452. _currentRenderId: number;
  29453. private _parentUpdateId;
  29454. /** @hidden */
  29455. _childUpdateId: number;
  29456. /** @hidden */
  29457. _waitingParentId: Nullable<string>;
  29458. /** @hidden */
  29459. _scene: Scene;
  29460. /** @hidden */
  29461. _cache: any;
  29462. private _parentNode;
  29463. private _children;
  29464. /** @hidden */
  29465. _worldMatrix: Matrix;
  29466. /** @hidden */
  29467. _worldMatrixDeterminant: number;
  29468. /** @hidden */
  29469. _worldMatrixDeterminantIsDirty: boolean;
  29470. /** @hidden */
  29471. private _sceneRootNodesIndex;
  29472. /**
  29473. * Gets a boolean indicating if the node has been disposed
  29474. * @returns true if the node was disposed
  29475. */
  29476. isDisposed(): boolean;
  29477. /**
  29478. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29479. * @see https://doc.babylonjs.com/how_to/parenting
  29480. */
  29481. set parent(parent: Nullable<Node>);
  29482. get parent(): Nullable<Node>;
  29483. /** @hidden */
  29484. _addToSceneRootNodes(): void;
  29485. /** @hidden */
  29486. _removeFromSceneRootNodes(): void;
  29487. private _animationPropertiesOverride;
  29488. /**
  29489. * Gets or sets the animation properties override
  29490. */
  29491. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29492. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29493. /**
  29494. * Gets a string idenfifying the name of the class
  29495. * @returns "Node" string
  29496. */
  29497. getClassName(): string;
  29498. /** @hidden */
  29499. readonly _isNode: boolean;
  29500. /**
  29501. * An event triggered when the mesh is disposed
  29502. */
  29503. onDisposeObservable: Observable<Node>;
  29504. private _onDisposeObserver;
  29505. /**
  29506. * Sets a callback that will be raised when the node will be disposed
  29507. */
  29508. set onDispose(callback: () => void);
  29509. /**
  29510. * Creates a new Node
  29511. * @param name the name and id to be given to this node
  29512. * @param scene the scene this node will be added to
  29513. */
  29514. constructor(name: string, scene?: Nullable<Scene>);
  29515. /**
  29516. * Gets the scene of the node
  29517. * @returns a scene
  29518. */
  29519. getScene(): Scene;
  29520. /**
  29521. * Gets the engine of the node
  29522. * @returns a Engine
  29523. */
  29524. getEngine(): Engine;
  29525. private _behaviors;
  29526. /**
  29527. * Attach a behavior to the node
  29528. * @see http://doc.babylonjs.com/features/behaviour
  29529. * @param behavior defines the behavior to attach
  29530. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29531. * @returns the current Node
  29532. */
  29533. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29534. /**
  29535. * Remove an attached behavior
  29536. * @see http://doc.babylonjs.com/features/behaviour
  29537. * @param behavior defines the behavior to attach
  29538. * @returns the current Node
  29539. */
  29540. removeBehavior(behavior: Behavior<Node>): Node;
  29541. /**
  29542. * Gets the list of attached behaviors
  29543. * @see http://doc.babylonjs.com/features/behaviour
  29544. */
  29545. get behaviors(): Behavior<Node>[];
  29546. /**
  29547. * Gets an attached behavior by name
  29548. * @param name defines the name of the behavior to look for
  29549. * @see http://doc.babylonjs.com/features/behaviour
  29550. * @returns null if behavior was not found else the requested behavior
  29551. */
  29552. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29553. /**
  29554. * Returns the latest update of the World matrix
  29555. * @returns a Matrix
  29556. */
  29557. getWorldMatrix(): Matrix;
  29558. /** @hidden */
  29559. _getWorldMatrixDeterminant(): number;
  29560. /**
  29561. * Returns directly the latest state of the mesh World matrix.
  29562. * A Matrix is returned.
  29563. */
  29564. get worldMatrixFromCache(): Matrix;
  29565. /** @hidden */
  29566. _initCache(): void;
  29567. /** @hidden */
  29568. updateCache(force?: boolean): void;
  29569. /** @hidden */
  29570. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29571. /** @hidden */
  29572. _updateCache(ignoreParentClass?: boolean): void;
  29573. /** @hidden */
  29574. _isSynchronized(): boolean;
  29575. /** @hidden */
  29576. _markSyncedWithParent(): void;
  29577. /** @hidden */
  29578. isSynchronizedWithParent(): boolean;
  29579. /** @hidden */
  29580. isSynchronized(): boolean;
  29581. /**
  29582. * Is this node ready to be used/rendered
  29583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29584. * @return true if the node is ready
  29585. */
  29586. isReady(completeCheck?: boolean): boolean;
  29587. /**
  29588. * Is this node enabled?
  29589. * 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
  29590. * @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
  29591. * @return whether this node (and its parent) is enabled
  29592. */
  29593. isEnabled(checkAncestors?: boolean): boolean;
  29594. /** @hidden */
  29595. protected _syncParentEnabledState(): void;
  29596. /**
  29597. * Set the enabled state of this node
  29598. * @param value defines the new enabled state
  29599. */
  29600. setEnabled(value: boolean): void;
  29601. /**
  29602. * Is this node a descendant of the given node?
  29603. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29604. * @param ancestor defines the parent node to inspect
  29605. * @returns a boolean indicating if this node is a descendant of the given node
  29606. */
  29607. isDescendantOf(ancestor: Node): boolean;
  29608. /** @hidden */
  29609. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29610. /**
  29611. * Will return all nodes that have this node as ascendant
  29612. * @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
  29613. * @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
  29614. * @return all children nodes of all types
  29615. */
  29616. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29617. /**
  29618. * Get all child-meshes of this node
  29619. * @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)
  29620. * @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
  29621. * @returns an array of AbstractMesh
  29622. */
  29623. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29624. /**
  29625. * Get all direct children of this node
  29626. * @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
  29627. * @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)
  29628. * @returns an array of Node
  29629. */
  29630. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29631. /** @hidden */
  29632. _setReady(state: boolean): void;
  29633. /**
  29634. * Get an animation by name
  29635. * @param name defines the name of the animation to look for
  29636. * @returns null if not found else the requested animation
  29637. */
  29638. getAnimationByName(name: string): Nullable<Animation>;
  29639. /**
  29640. * Creates an animation range for this node
  29641. * @param name defines the name of the range
  29642. * @param from defines the starting key
  29643. * @param to defines the end key
  29644. */
  29645. createAnimationRange(name: string, from: number, to: number): void;
  29646. /**
  29647. * Delete a specific animation range
  29648. * @param name defines the name of the range to delete
  29649. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29650. */
  29651. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29652. /**
  29653. * Get an animation range by name
  29654. * @param name defines the name of the animation range to look for
  29655. * @returns null if not found else the requested animation range
  29656. */
  29657. getAnimationRange(name: string): Nullable<AnimationRange>;
  29658. /**
  29659. * Gets the list of all animation ranges defined on this node
  29660. * @returns an array
  29661. */
  29662. getAnimationRanges(): Nullable<AnimationRange>[];
  29663. /**
  29664. * Will start the animation sequence
  29665. * @param name defines the range frames for animation sequence
  29666. * @param loop defines if the animation should loop (false by default)
  29667. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29668. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29669. * @returns the object created for this animation. If range does not exist, it will return null
  29670. */
  29671. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29672. /**
  29673. * Serialize animation ranges into a JSON compatible object
  29674. * @returns serialization object
  29675. */
  29676. serializeAnimationRanges(): any;
  29677. /**
  29678. * Computes the world matrix of the node
  29679. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29680. * @returns the world matrix
  29681. */
  29682. computeWorldMatrix(force?: boolean): Matrix;
  29683. /**
  29684. * Releases resources associated with this node.
  29685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29687. */
  29688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29689. /**
  29690. * Parse animation range data from a serialization object and store them into a given node
  29691. * @param node defines where to store the animation ranges
  29692. * @param parsedNode defines the serialization object to read data from
  29693. * @param scene defines the hosting scene
  29694. */
  29695. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29696. /**
  29697. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29698. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29699. * @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
  29700. * @returns the new bounding vectors
  29701. */
  29702. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29703. min: Vector3;
  29704. max: Vector3;
  29705. };
  29706. }
  29707. }
  29708. declare module BABYLON {
  29709. /**
  29710. * @hidden
  29711. */
  29712. export class _IAnimationState {
  29713. key: number;
  29714. repeatCount: number;
  29715. workValue?: any;
  29716. loopMode?: number;
  29717. offsetValue?: any;
  29718. highLimitValue?: any;
  29719. }
  29720. /**
  29721. * Class used to store any kind of animation
  29722. */
  29723. export class Animation {
  29724. /**Name of the animation */
  29725. name: string;
  29726. /**Property to animate */
  29727. targetProperty: string;
  29728. /**The frames per second of the animation */
  29729. framePerSecond: number;
  29730. /**The data type of the animation */
  29731. dataType: number;
  29732. /**The loop mode of the animation */
  29733. loopMode?: number | undefined;
  29734. /**Specifies if blending should be enabled */
  29735. enableBlending?: boolean | undefined;
  29736. /**
  29737. * Use matrix interpolation instead of using direct key value when animating matrices
  29738. */
  29739. static AllowMatricesInterpolation: boolean;
  29740. /**
  29741. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29742. */
  29743. static AllowMatrixDecomposeForInterpolation: boolean;
  29744. /**
  29745. * Stores the key frames of the animation
  29746. */
  29747. private _keys;
  29748. /**
  29749. * Stores the easing function of the animation
  29750. */
  29751. private _easingFunction;
  29752. /**
  29753. * @hidden Internal use only
  29754. */
  29755. _runtimeAnimations: RuntimeAnimation[];
  29756. /**
  29757. * The set of event that will be linked to this animation
  29758. */
  29759. private _events;
  29760. /**
  29761. * Stores an array of target property paths
  29762. */
  29763. targetPropertyPath: string[];
  29764. /**
  29765. * Stores the blending speed of the animation
  29766. */
  29767. blendingSpeed: number;
  29768. /**
  29769. * Stores the animation ranges for the animation
  29770. */
  29771. private _ranges;
  29772. /**
  29773. * @hidden Internal use
  29774. */
  29775. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29776. /**
  29777. * Sets up an animation
  29778. * @param property The property to animate
  29779. * @param animationType The animation type to apply
  29780. * @param framePerSecond The frames per second of the animation
  29781. * @param easingFunction The easing function used in the animation
  29782. * @returns The created animation
  29783. */
  29784. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29785. /**
  29786. * Create and start an animation on a node
  29787. * @param name defines the name of the global animation that will be run on all nodes
  29788. * @param node defines the root node where the animation will take place
  29789. * @param targetProperty defines property to animate
  29790. * @param framePerSecond defines the number of frame per second yo use
  29791. * @param totalFrame defines the number of frames in total
  29792. * @param from defines the initial value
  29793. * @param to defines the final value
  29794. * @param loopMode defines which loop mode you want to use (off by default)
  29795. * @param easingFunction defines the easing function to use (linear by default)
  29796. * @param onAnimationEnd defines the callback to call when animation end
  29797. * @returns the animatable created for this animation
  29798. */
  29799. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29800. /**
  29801. * Create and start an animation on a node and its descendants
  29802. * @param name defines the name of the global animation that will be run on all nodes
  29803. * @param node defines the root node where the animation will take place
  29804. * @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
  29805. * @param targetProperty defines property to animate
  29806. * @param framePerSecond defines the number of frame per second to use
  29807. * @param totalFrame defines the number of frames in total
  29808. * @param from defines the initial value
  29809. * @param to defines the final value
  29810. * @param loopMode defines which loop mode you want to use (off by default)
  29811. * @param easingFunction defines the easing function to use (linear by default)
  29812. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29813. * @returns the list of animatables created for all nodes
  29814. * @example https://www.babylonjs-playground.com/#MH0VLI
  29815. */
  29816. 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[]>;
  29817. /**
  29818. * Creates a new animation, merges it with the existing animations and starts it
  29819. * @param name Name of the animation
  29820. * @param node Node which contains the scene that begins the animations
  29821. * @param targetProperty Specifies which property to animate
  29822. * @param framePerSecond The frames per second of the animation
  29823. * @param totalFrame The total number of frames
  29824. * @param from The frame at the beginning of the animation
  29825. * @param to The frame at the end of the animation
  29826. * @param loopMode Specifies the loop mode of the animation
  29827. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29828. * @param onAnimationEnd Callback to run once the animation is complete
  29829. * @returns Nullable animation
  29830. */
  29831. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29832. /**
  29833. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29834. * @param sourceAnimation defines the Animation containing keyframes to convert
  29835. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29836. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29837. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29838. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29839. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29840. */
  29841. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29842. /**
  29843. * Transition property of an host to the target Value
  29844. * @param property The property to transition
  29845. * @param targetValue The target Value of the property
  29846. * @param host The object where the property to animate belongs
  29847. * @param scene Scene used to run the animation
  29848. * @param frameRate Framerate (in frame/s) to use
  29849. * @param transition The transition type we want to use
  29850. * @param duration The duration of the animation, in milliseconds
  29851. * @param onAnimationEnd Callback trigger at the end of the animation
  29852. * @returns Nullable animation
  29853. */
  29854. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29855. /**
  29856. * Return the array of runtime animations currently using this animation
  29857. */
  29858. get runtimeAnimations(): RuntimeAnimation[];
  29859. /**
  29860. * Specifies if any of the runtime animations are currently running
  29861. */
  29862. get hasRunningRuntimeAnimations(): boolean;
  29863. /**
  29864. * Initializes the animation
  29865. * @param name Name of the animation
  29866. * @param targetProperty Property to animate
  29867. * @param framePerSecond The frames per second of the animation
  29868. * @param dataType The data type of the animation
  29869. * @param loopMode The loop mode of the animation
  29870. * @param enableBlending Specifies if blending should be enabled
  29871. */
  29872. constructor(
  29873. /**Name of the animation */
  29874. name: string,
  29875. /**Property to animate */
  29876. targetProperty: string,
  29877. /**The frames per second of the animation */
  29878. framePerSecond: number,
  29879. /**The data type of the animation */
  29880. dataType: number,
  29881. /**The loop mode of the animation */
  29882. loopMode?: number | undefined,
  29883. /**Specifies if blending should be enabled */
  29884. enableBlending?: boolean | undefined);
  29885. /**
  29886. * Converts the animation to a string
  29887. * @param fullDetails support for multiple levels of logging within scene loading
  29888. * @returns String form of the animation
  29889. */
  29890. toString(fullDetails?: boolean): string;
  29891. /**
  29892. * Add an event to this animation
  29893. * @param event Event to add
  29894. */
  29895. addEvent(event: AnimationEvent): void;
  29896. /**
  29897. * Remove all events found at the given frame
  29898. * @param frame The frame to remove events from
  29899. */
  29900. removeEvents(frame: number): void;
  29901. /**
  29902. * Retrieves all the events from the animation
  29903. * @returns Events from the animation
  29904. */
  29905. getEvents(): AnimationEvent[];
  29906. /**
  29907. * Creates an animation range
  29908. * @param name Name of the animation range
  29909. * @param from Starting frame of the animation range
  29910. * @param to Ending frame of the animation
  29911. */
  29912. createRange(name: string, from: number, to: number): void;
  29913. /**
  29914. * Deletes an animation range by name
  29915. * @param name Name of the animation range to delete
  29916. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29917. */
  29918. deleteRange(name: string, deleteFrames?: boolean): void;
  29919. /**
  29920. * Gets the animation range by name, or null if not defined
  29921. * @param name Name of the animation range
  29922. * @returns Nullable animation range
  29923. */
  29924. getRange(name: string): Nullable<AnimationRange>;
  29925. /**
  29926. * Gets the key frames from the animation
  29927. * @returns The key frames of the animation
  29928. */
  29929. getKeys(): Array<IAnimationKey>;
  29930. /**
  29931. * Gets the highest frame rate of the animation
  29932. * @returns Highest frame rate of the animation
  29933. */
  29934. getHighestFrame(): number;
  29935. /**
  29936. * Gets the easing function of the animation
  29937. * @returns Easing function of the animation
  29938. */
  29939. getEasingFunction(): IEasingFunction;
  29940. /**
  29941. * Sets the easing function of the animation
  29942. * @param easingFunction A custom mathematical formula for animation
  29943. */
  29944. setEasingFunction(easingFunction: EasingFunction): void;
  29945. /**
  29946. * Interpolates a scalar linearly
  29947. * @param startValue Start value of the animation curve
  29948. * @param endValue End value of the animation curve
  29949. * @param gradient Scalar amount to interpolate
  29950. * @returns Interpolated scalar value
  29951. */
  29952. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29953. /**
  29954. * Interpolates a scalar cubically
  29955. * @param startValue Start value of the animation curve
  29956. * @param outTangent End tangent of the animation
  29957. * @param endValue End value of the animation curve
  29958. * @param inTangent Start tangent of the animation curve
  29959. * @param gradient Scalar amount to interpolate
  29960. * @returns Interpolated scalar value
  29961. */
  29962. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29963. /**
  29964. * Interpolates a quaternion using a spherical linear interpolation
  29965. * @param startValue Start value of the animation curve
  29966. * @param endValue End value of the animation curve
  29967. * @param gradient Scalar amount to interpolate
  29968. * @returns Interpolated quaternion value
  29969. */
  29970. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29971. /**
  29972. * Interpolates a quaternion cubically
  29973. * @param startValue Start value of the animation curve
  29974. * @param outTangent End tangent of the animation curve
  29975. * @param endValue End value of the animation curve
  29976. * @param inTangent Start tangent of the animation curve
  29977. * @param gradient Scalar amount to interpolate
  29978. * @returns Interpolated quaternion value
  29979. */
  29980. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29981. /**
  29982. * Interpolates a Vector3 linearl
  29983. * @param startValue Start value of the animation curve
  29984. * @param endValue End value of the animation curve
  29985. * @param gradient Scalar amount to interpolate
  29986. * @returns Interpolated scalar value
  29987. */
  29988. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29989. /**
  29990. * Interpolates a Vector3 cubically
  29991. * @param startValue Start value of the animation curve
  29992. * @param outTangent End tangent of the animation
  29993. * @param endValue End value of the animation curve
  29994. * @param inTangent Start tangent of the animation curve
  29995. * @param gradient Scalar amount to interpolate
  29996. * @returns InterpolatedVector3 value
  29997. */
  29998. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29999. /**
  30000. * Interpolates a Vector2 linearly
  30001. * @param startValue Start value of the animation curve
  30002. * @param endValue End value of the animation curve
  30003. * @param gradient Scalar amount to interpolate
  30004. * @returns Interpolated Vector2 value
  30005. */
  30006. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30007. /**
  30008. * Interpolates a Vector2 cubically
  30009. * @param startValue Start value of the animation curve
  30010. * @param outTangent End tangent of the animation
  30011. * @param endValue End value of the animation curve
  30012. * @param inTangent Start tangent of the animation curve
  30013. * @param gradient Scalar amount to interpolate
  30014. * @returns Interpolated Vector2 value
  30015. */
  30016. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30017. /**
  30018. * Interpolates a size linearly
  30019. * @param startValue Start value of the animation curve
  30020. * @param endValue End value of the animation curve
  30021. * @param gradient Scalar amount to interpolate
  30022. * @returns Interpolated Size value
  30023. */
  30024. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30025. /**
  30026. * Interpolates a Color3 linearly
  30027. * @param startValue Start value of the animation curve
  30028. * @param endValue End value of the animation curve
  30029. * @param gradient Scalar amount to interpolate
  30030. * @returns Interpolated Color3 value
  30031. */
  30032. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30033. /**
  30034. * Interpolates a Color4 linearly
  30035. * @param startValue Start value of the animation curve
  30036. * @param endValue End value of the animation curve
  30037. * @param gradient Scalar amount to interpolate
  30038. * @returns Interpolated Color3 value
  30039. */
  30040. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30041. /**
  30042. * @hidden Internal use only
  30043. */
  30044. _getKeyValue(value: any): any;
  30045. /**
  30046. * @hidden Internal use only
  30047. */
  30048. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30049. /**
  30050. * Defines the function to use to interpolate matrices
  30051. * @param startValue defines the start matrix
  30052. * @param endValue defines the end matrix
  30053. * @param gradient defines the gradient between both matrices
  30054. * @param result defines an optional target matrix where to store the interpolation
  30055. * @returns the interpolated matrix
  30056. */
  30057. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30058. /**
  30059. * Makes a copy of the animation
  30060. * @returns Cloned animation
  30061. */
  30062. clone(): Animation;
  30063. /**
  30064. * Sets the key frames of the animation
  30065. * @param values The animation key frames to set
  30066. */
  30067. setKeys(values: Array<IAnimationKey>): void;
  30068. /**
  30069. * Serializes the animation to an object
  30070. * @returns Serialized object
  30071. */
  30072. serialize(): any;
  30073. /**
  30074. * Float animation type
  30075. */
  30076. static readonly ANIMATIONTYPE_FLOAT: number;
  30077. /**
  30078. * Vector3 animation type
  30079. */
  30080. static readonly ANIMATIONTYPE_VECTOR3: number;
  30081. /**
  30082. * Quaternion animation type
  30083. */
  30084. static readonly ANIMATIONTYPE_QUATERNION: number;
  30085. /**
  30086. * Matrix animation type
  30087. */
  30088. static readonly ANIMATIONTYPE_MATRIX: number;
  30089. /**
  30090. * Color3 animation type
  30091. */
  30092. static readonly ANIMATIONTYPE_COLOR3: number;
  30093. /**
  30094. * Color3 animation type
  30095. */
  30096. static readonly ANIMATIONTYPE_COLOR4: number;
  30097. /**
  30098. * Vector2 animation type
  30099. */
  30100. static readonly ANIMATIONTYPE_VECTOR2: number;
  30101. /**
  30102. * Size animation type
  30103. */
  30104. static readonly ANIMATIONTYPE_SIZE: number;
  30105. /**
  30106. * Relative Loop Mode
  30107. */
  30108. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30109. /**
  30110. * Cycle Loop Mode
  30111. */
  30112. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30113. /**
  30114. * Constant Loop Mode
  30115. */
  30116. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30117. /** @hidden */
  30118. static _UniversalLerp(left: any, right: any, amount: number): any;
  30119. /**
  30120. * Parses an animation object and creates an animation
  30121. * @param parsedAnimation Parsed animation object
  30122. * @returns Animation object
  30123. */
  30124. static Parse(parsedAnimation: any): Animation;
  30125. /**
  30126. * Appends the serialized animations from the source animations
  30127. * @param source Source containing the animations
  30128. * @param destination Target to store the animations
  30129. */
  30130. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30131. }
  30132. }
  30133. declare module BABYLON {
  30134. /**
  30135. * Interface containing an array of animations
  30136. */
  30137. export interface IAnimatable {
  30138. /**
  30139. * Array of animations
  30140. */
  30141. animations: Nullable<Array<Animation>>;
  30142. }
  30143. }
  30144. declare module BABYLON {
  30145. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30146. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30147. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30148. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30149. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30150. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30151. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30152. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30153. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30154. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30155. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30156. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30157. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30158. /**
  30159. * Decorator used to define property that can be serialized as reference to a camera
  30160. * @param sourceName defines the name of the property to decorate
  30161. */
  30162. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. /**
  30164. * Class used to help serialization objects
  30165. */
  30166. export class SerializationHelper {
  30167. /** @hidden */
  30168. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30169. /** @hidden */
  30170. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30171. /** @hidden */
  30172. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30173. /** @hidden */
  30174. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30175. /**
  30176. * Appends the serialized animations from the source animations
  30177. * @param source Source containing the animations
  30178. * @param destination Target to store the animations
  30179. */
  30180. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30181. /**
  30182. * Static function used to serialized a specific entity
  30183. * @param entity defines the entity to serialize
  30184. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30185. * @returns a JSON compatible object representing the serialization of the entity
  30186. */
  30187. static Serialize<T>(entity: T, serializationObject?: any): any;
  30188. /**
  30189. * Creates a new entity from a serialization data object
  30190. * @param creationFunction defines a function used to instanciated the new entity
  30191. * @param source defines the source serialization data
  30192. * @param scene defines the hosting scene
  30193. * @param rootUrl defines the root url for resources
  30194. * @returns a new entity
  30195. */
  30196. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30197. /**
  30198. * Clones an object
  30199. * @param creationFunction defines the function used to instanciate the new object
  30200. * @param source defines the source object
  30201. * @returns the cloned object
  30202. */
  30203. static Clone<T>(creationFunction: () => T, source: T): T;
  30204. /**
  30205. * Instanciates a new object based on a source one (some data will be shared between both object)
  30206. * @param creationFunction defines the function used to instanciate the new object
  30207. * @param source defines the source object
  30208. * @returns the new object
  30209. */
  30210. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30211. }
  30212. }
  30213. declare module BABYLON {
  30214. /**
  30215. * Base class of all the textures in babylon.
  30216. * It groups all the common properties the materials, post process, lights... might need
  30217. * in order to make a correct use of the texture.
  30218. */
  30219. export class BaseTexture implements IAnimatable {
  30220. /**
  30221. * Default anisotropic filtering level for the application.
  30222. * It is set to 4 as a good tradeoff between perf and quality.
  30223. */
  30224. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30225. /**
  30226. * Gets or sets the unique id of the texture
  30227. */
  30228. uniqueId: number;
  30229. /**
  30230. * Define the name of the texture.
  30231. */
  30232. name: string;
  30233. /**
  30234. * Gets or sets an object used to store user defined information.
  30235. */
  30236. metadata: any;
  30237. /**
  30238. * For internal use only. Please do not use.
  30239. */
  30240. reservedDataStore: any;
  30241. private _hasAlpha;
  30242. /**
  30243. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30244. */
  30245. set hasAlpha(value: boolean);
  30246. get hasAlpha(): boolean;
  30247. /**
  30248. * Defines if the alpha value should be determined via the rgb values.
  30249. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30250. */
  30251. getAlphaFromRGB: boolean;
  30252. /**
  30253. * Intensity or strength of the texture.
  30254. * It is commonly used by materials to fine tune the intensity of the texture
  30255. */
  30256. level: number;
  30257. /**
  30258. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30259. * This is part of the texture as textures usually maps to one uv set.
  30260. */
  30261. coordinatesIndex: number;
  30262. private _coordinatesMode;
  30263. /**
  30264. * How a texture is mapped.
  30265. *
  30266. * | Value | Type | Description |
  30267. * | ----- | ----------------------------------- | ----------- |
  30268. * | 0 | EXPLICIT_MODE | |
  30269. * | 1 | SPHERICAL_MODE | |
  30270. * | 2 | PLANAR_MODE | |
  30271. * | 3 | CUBIC_MODE | |
  30272. * | 4 | PROJECTION_MODE | |
  30273. * | 5 | SKYBOX_MODE | |
  30274. * | 6 | INVCUBIC_MODE | |
  30275. * | 7 | EQUIRECTANGULAR_MODE | |
  30276. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30277. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30278. */
  30279. set coordinatesMode(value: number);
  30280. get coordinatesMode(): number;
  30281. /**
  30282. * | Value | Type | Description |
  30283. * | ----- | ------------------ | ----------- |
  30284. * | 0 | CLAMP_ADDRESSMODE | |
  30285. * | 1 | WRAP_ADDRESSMODE | |
  30286. * | 2 | MIRROR_ADDRESSMODE | |
  30287. */
  30288. wrapU: number;
  30289. /**
  30290. * | Value | Type | Description |
  30291. * | ----- | ------------------ | ----------- |
  30292. * | 0 | CLAMP_ADDRESSMODE | |
  30293. * | 1 | WRAP_ADDRESSMODE | |
  30294. * | 2 | MIRROR_ADDRESSMODE | |
  30295. */
  30296. wrapV: number;
  30297. /**
  30298. * | Value | Type | Description |
  30299. * | ----- | ------------------ | ----------- |
  30300. * | 0 | CLAMP_ADDRESSMODE | |
  30301. * | 1 | WRAP_ADDRESSMODE | |
  30302. * | 2 | MIRROR_ADDRESSMODE | |
  30303. */
  30304. wrapR: number;
  30305. /**
  30306. * With compliant hardware and browser (supporting anisotropic filtering)
  30307. * this defines the level of anisotropic filtering in the texture.
  30308. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30309. */
  30310. anisotropicFilteringLevel: number;
  30311. /**
  30312. * Define if the texture is a cube texture or if false a 2d texture.
  30313. */
  30314. get isCube(): boolean;
  30315. set isCube(value: boolean);
  30316. /**
  30317. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30318. */
  30319. get is3D(): boolean;
  30320. set is3D(value: boolean);
  30321. /**
  30322. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30323. */
  30324. get is2DArray(): boolean;
  30325. set is2DArray(value: boolean);
  30326. /**
  30327. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30328. * HDR texture are usually stored in linear space.
  30329. * This only impacts the PBR and Background materials
  30330. */
  30331. gammaSpace: boolean;
  30332. /**
  30333. * Gets or sets whether or not the texture contains RGBD data.
  30334. */
  30335. get isRGBD(): boolean;
  30336. set isRGBD(value: boolean);
  30337. /**
  30338. * Is Z inverted in the texture (useful in a cube texture).
  30339. */
  30340. invertZ: boolean;
  30341. /**
  30342. * Are mip maps generated for this texture or not.
  30343. */
  30344. get noMipmap(): boolean;
  30345. /**
  30346. * @hidden
  30347. */
  30348. lodLevelInAlpha: boolean;
  30349. /**
  30350. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30351. */
  30352. get lodGenerationOffset(): number;
  30353. set lodGenerationOffset(value: number);
  30354. /**
  30355. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30356. */
  30357. get lodGenerationScale(): number;
  30358. set lodGenerationScale(value: number);
  30359. /**
  30360. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30361. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30362. * average roughness values.
  30363. */
  30364. get linearSpecularLOD(): boolean;
  30365. set linearSpecularLOD(value: boolean);
  30366. /**
  30367. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30368. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30369. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30370. */
  30371. get irradianceTexture(): Nullable<BaseTexture>;
  30372. set irradianceTexture(value: Nullable<BaseTexture>);
  30373. /**
  30374. * Define if the texture is a render target.
  30375. */
  30376. isRenderTarget: boolean;
  30377. /**
  30378. * Define the unique id of the texture in the scene.
  30379. */
  30380. get uid(): string;
  30381. /**
  30382. * Return a string representation of the texture.
  30383. * @returns the texture as a string
  30384. */
  30385. toString(): string;
  30386. /**
  30387. * Get the class name of the texture.
  30388. * @returns "BaseTexture"
  30389. */
  30390. getClassName(): string;
  30391. /**
  30392. * Define the list of animation attached to the texture.
  30393. */
  30394. animations: Animation[];
  30395. /**
  30396. * An event triggered when the texture is disposed.
  30397. */
  30398. onDisposeObservable: Observable<BaseTexture>;
  30399. private _onDisposeObserver;
  30400. /**
  30401. * Callback triggered when the texture has been disposed.
  30402. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30403. */
  30404. set onDispose(callback: () => void);
  30405. /**
  30406. * Define the current state of the loading sequence when in delayed load mode.
  30407. */
  30408. delayLoadState: number;
  30409. private _scene;
  30410. private _engine;
  30411. /** @hidden */
  30412. _texture: Nullable<InternalTexture>;
  30413. private _uid;
  30414. /**
  30415. * Define if the texture is preventinga material to render or not.
  30416. * If not and the texture is not ready, the engine will use a default black texture instead.
  30417. */
  30418. get isBlocking(): boolean;
  30419. /**
  30420. * Instantiates a new BaseTexture.
  30421. * Base class of all the textures in babylon.
  30422. * It groups all the common properties the materials, post process, lights... might need
  30423. * in order to make a correct use of the texture.
  30424. * @param sceneOrEngine Define the scene or engine the texture blongs to
  30425. */
  30426. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  30427. /**
  30428. * Get the scene the texture belongs to.
  30429. * @returns the scene or null if undefined
  30430. */
  30431. getScene(): Nullable<Scene>;
  30432. /** @hidden */
  30433. protected _getEngine(): Nullable<ThinEngine>;
  30434. /**
  30435. * Get the texture transform matrix used to offset tile the texture for istance.
  30436. * @returns the transformation matrix
  30437. */
  30438. getTextureMatrix(): Matrix;
  30439. /**
  30440. * Get the texture reflection matrix used to rotate/transform the reflection.
  30441. * @returns the reflection matrix
  30442. */
  30443. getReflectionTextureMatrix(): Matrix;
  30444. /**
  30445. * Get the underlying lower level texture from Babylon.
  30446. * @returns the insternal texture
  30447. */
  30448. getInternalTexture(): Nullable<InternalTexture>;
  30449. /**
  30450. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30451. * @returns true if ready or not blocking
  30452. */
  30453. isReadyOrNotBlocking(): boolean;
  30454. /**
  30455. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30456. * @returns true if fully ready
  30457. */
  30458. isReady(): boolean;
  30459. private _cachedSize;
  30460. /**
  30461. * Get the size of the texture.
  30462. * @returns the texture size.
  30463. */
  30464. getSize(): ISize;
  30465. /**
  30466. * Get the base size of the texture.
  30467. * It can be different from the size if the texture has been resized for POT for instance
  30468. * @returns the base size
  30469. */
  30470. getBaseSize(): ISize;
  30471. /**
  30472. * Update the sampling mode of the texture.
  30473. * Default is Trilinear mode.
  30474. *
  30475. * | Value | Type | Description |
  30476. * | ----- | ------------------ | ----------- |
  30477. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30478. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30479. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30480. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30481. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30482. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30483. * | 7 | NEAREST_LINEAR | |
  30484. * | 8 | NEAREST_NEAREST | |
  30485. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30486. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30487. * | 11 | LINEAR_LINEAR | |
  30488. * | 12 | LINEAR_NEAREST | |
  30489. *
  30490. * > _mag_: magnification filter (close to the viewer)
  30491. * > _min_: minification filter (far from the viewer)
  30492. * > _mip_: filter used between mip map levels
  30493. *@param samplingMode Define the new sampling mode of the texture
  30494. */
  30495. updateSamplingMode(samplingMode: number): void;
  30496. /**
  30497. * Scales the texture if is `canRescale()`
  30498. * @param ratio the resize factor we want to use to rescale
  30499. */
  30500. scale(ratio: number): void;
  30501. /**
  30502. * Get if the texture can rescale.
  30503. */
  30504. get canRescale(): boolean;
  30505. /** @hidden */
  30506. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30507. /** @hidden */
  30508. _rebuild(): void;
  30509. /**
  30510. * Triggers the load sequence in delayed load mode.
  30511. */
  30512. delayLoad(): void;
  30513. /**
  30514. * Clones the texture.
  30515. * @returns the cloned texture
  30516. */
  30517. clone(): Nullable<BaseTexture>;
  30518. /**
  30519. * Get the texture underlying type (INT, FLOAT...)
  30520. */
  30521. get textureType(): number;
  30522. /**
  30523. * Get the texture underlying format (RGB, RGBA...)
  30524. */
  30525. get textureFormat(): number;
  30526. /**
  30527. * Indicates that textures need to be re-calculated for all materials
  30528. */
  30529. protected _markAllSubMeshesAsTexturesDirty(): void;
  30530. /**
  30531. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30532. * This will returns an RGBA array buffer containing either in values (0-255) or
  30533. * float values (0-1) depending of the underlying buffer type.
  30534. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30535. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30536. * @param buffer defines a user defined buffer to fill with data (can be null)
  30537. * @returns The Array buffer containing the pixels data.
  30538. */
  30539. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30540. /**
  30541. * Release and destroy the underlying lower level texture aka internalTexture.
  30542. */
  30543. releaseInternalTexture(): void;
  30544. /** @hidden */
  30545. get _lodTextureHigh(): Nullable<BaseTexture>;
  30546. /** @hidden */
  30547. get _lodTextureMid(): Nullable<BaseTexture>;
  30548. /** @hidden */
  30549. get _lodTextureLow(): Nullable<BaseTexture>;
  30550. /**
  30551. * Dispose the texture and release its associated resources.
  30552. */
  30553. dispose(): void;
  30554. /**
  30555. * Serialize the texture into a JSON representation that can be parsed later on.
  30556. * @returns the JSON representation of the texture
  30557. */
  30558. serialize(): any;
  30559. /**
  30560. * Helper function to be called back once a list of texture contains only ready textures.
  30561. * @param textures Define the list of textures to wait for
  30562. * @param callback Define the callback triggered once the entire list will be ready
  30563. */
  30564. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30565. private static _isScene;
  30566. }
  30567. }
  30568. declare module BABYLON {
  30569. /**
  30570. * Options to be used when creating an effect.
  30571. */
  30572. export interface IEffectCreationOptions {
  30573. /**
  30574. * Atrributes that will be used in the shader.
  30575. */
  30576. attributes: string[];
  30577. /**
  30578. * Uniform varible names that will be set in the shader.
  30579. */
  30580. uniformsNames: string[];
  30581. /**
  30582. * Uniform buffer variable names that will be set in the shader.
  30583. */
  30584. uniformBuffersNames: string[];
  30585. /**
  30586. * Sampler texture variable names that will be set in the shader.
  30587. */
  30588. samplers: string[];
  30589. /**
  30590. * Define statements that will be set in the shader.
  30591. */
  30592. defines: any;
  30593. /**
  30594. * Possible fallbacks for this effect to improve performance when needed.
  30595. */
  30596. fallbacks: Nullable<IEffectFallbacks>;
  30597. /**
  30598. * Callback that will be called when the shader is compiled.
  30599. */
  30600. onCompiled: Nullable<(effect: Effect) => void>;
  30601. /**
  30602. * Callback that will be called if an error occurs during shader compilation.
  30603. */
  30604. onError: Nullable<(effect: Effect, errors: string) => void>;
  30605. /**
  30606. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30607. */
  30608. indexParameters?: any;
  30609. /**
  30610. * Max number of lights that can be used in the shader.
  30611. */
  30612. maxSimultaneousLights?: number;
  30613. /**
  30614. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30615. */
  30616. transformFeedbackVaryings?: Nullable<string[]>;
  30617. }
  30618. /**
  30619. * Effect containing vertex and fragment shader that can be executed on an object.
  30620. */
  30621. export class Effect implements IDisposable {
  30622. /**
  30623. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30624. */
  30625. static ShadersRepository: string;
  30626. /**
  30627. * Enable logging of the shader code when a compilation error occurs
  30628. */
  30629. static LogShaderCodeOnCompilationError: boolean;
  30630. /**
  30631. * Name of the effect.
  30632. */
  30633. name: any;
  30634. /**
  30635. * String container all the define statements that should be set on the shader.
  30636. */
  30637. defines: string;
  30638. /**
  30639. * Callback that will be called when the shader is compiled.
  30640. */
  30641. onCompiled: Nullable<(effect: Effect) => void>;
  30642. /**
  30643. * Callback that will be called if an error occurs during shader compilation.
  30644. */
  30645. onError: Nullable<(effect: Effect, errors: string) => void>;
  30646. /**
  30647. * Callback that will be called when effect is bound.
  30648. */
  30649. onBind: Nullable<(effect: Effect) => void>;
  30650. /**
  30651. * Unique ID of the effect.
  30652. */
  30653. uniqueId: number;
  30654. /**
  30655. * Observable that will be called when the shader is compiled.
  30656. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30657. */
  30658. onCompileObservable: Observable<Effect>;
  30659. /**
  30660. * Observable that will be called if an error occurs during shader compilation.
  30661. */
  30662. onErrorObservable: Observable<Effect>;
  30663. /** @hidden */
  30664. _onBindObservable: Nullable<Observable<Effect>>;
  30665. /**
  30666. * @hidden
  30667. * Specifies if the effect was previously ready
  30668. */
  30669. _wasPreviouslyReady: boolean;
  30670. /**
  30671. * Observable that will be called when effect is bound.
  30672. */
  30673. get onBindObservable(): Observable<Effect>;
  30674. /** @hidden */
  30675. _bonesComputationForcedToCPU: boolean;
  30676. private static _uniqueIdSeed;
  30677. private _engine;
  30678. private _uniformBuffersNames;
  30679. private _uniformBuffersNamesList;
  30680. private _uniformsNames;
  30681. private _samplerList;
  30682. private _samplers;
  30683. private _isReady;
  30684. private _compilationError;
  30685. private _allFallbacksProcessed;
  30686. private _attributesNames;
  30687. private _attributes;
  30688. private _attributeLocationByName;
  30689. private _uniforms;
  30690. /**
  30691. * Key for the effect.
  30692. * @hidden
  30693. */
  30694. _key: string;
  30695. private _indexParameters;
  30696. private _fallbacks;
  30697. private _vertexSourceCode;
  30698. private _fragmentSourceCode;
  30699. private _vertexSourceCodeOverride;
  30700. private _fragmentSourceCodeOverride;
  30701. private _transformFeedbackVaryings;
  30702. /**
  30703. * Compiled shader to webGL program.
  30704. * @hidden
  30705. */
  30706. _pipelineContext: Nullable<IPipelineContext>;
  30707. private _valueCache;
  30708. private static _baseCache;
  30709. /**
  30710. * Instantiates an effect.
  30711. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30712. * @param baseName Name of the effect.
  30713. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30714. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30715. * @param samplers List of sampler variables that will be passed to the shader.
  30716. * @param engine Engine to be used to render the effect
  30717. * @param defines Define statements to be added to the shader.
  30718. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30719. * @param onCompiled Callback that will be called when the shader is compiled.
  30720. * @param onError Callback that will be called if an error occurs during shader compilation.
  30721. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30722. */
  30723. 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);
  30724. private _useFinalCode;
  30725. /**
  30726. * Unique key for this effect
  30727. */
  30728. get key(): string;
  30729. /**
  30730. * If the effect has been compiled and prepared.
  30731. * @returns if the effect is compiled and prepared.
  30732. */
  30733. isReady(): boolean;
  30734. private _isReadyInternal;
  30735. /**
  30736. * The engine the effect was initialized with.
  30737. * @returns the engine.
  30738. */
  30739. getEngine(): Engine;
  30740. /**
  30741. * The pipeline context for this effect
  30742. * @returns the associated pipeline context
  30743. */
  30744. getPipelineContext(): Nullable<IPipelineContext>;
  30745. /**
  30746. * The set of names of attribute variables for the shader.
  30747. * @returns An array of attribute names.
  30748. */
  30749. getAttributesNames(): string[];
  30750. /**
  30751. * Returns the attribute at the given index.
  30752. * @param index The index of the attribute.
  30753. * @returns The location of the attribute.
  30754. */
  30755. getAttributeLocation(index: number): number;
  30756. /**
  30757. * Returns the attribute based on the name of the variable.
  30758. * @param name of the attribute to look up.
  30759. * @returns the attribute location.
  30760. */
  30761. getAttributeLocationByName(name: string): number;
  30762. /**
  30763. * The number of attributes.
  30764. * @returns the numnber of attributes.
  30765. */
  30766. getAttributesCount(): number;
  30767. /**
  30768. * Gets the index of a uniform variable.
  30769. * @param uniformName of the uniform to look up.
  30770. * @returns the index.
  30771. */
  30772. getUniformIndex(uniformName: string): number;
  30773. /**
  30774. * Returns the attribute based on the name of the variable.
  30775. * @param uniformName of the uniform to look up.
  30776. * @returns the location of the uniform.
  30777. */
  30778. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30779. /**
  30780. * Returns an array of sampler variable names
  30781. * @returns The array of sampler variable names.
  30782. */
  30783. getSamplers(): string[];
  30784. /**
  30785. * Returns an array of uniform variable names
  30786. * @returns The array of uniform variable names.
  30787. */
  30788. getUniformNames(): string[];
  30789. /**
  30790. * Returns an array of uniform buffer variable names
  30791. * @returns The array of uniform buffer variable names.
  30792. */
  30793. getUniformBuffersNames(): string[];
  30794. /**
  30795. * Returns the index parameters used to create the effect
  30796. * @returns The index parameters object
  30797. */
  30798. getIndexParameters(): any;
  30799. /**
  30800. * The error from the last compilation.
  30801. * @returns the error string.
  30802. */
  30803. getCompilationError(): string;
  30804. /**
  30805. * Gets a boolean indicating that all fallbacks were used during compilation
  30806. * @returns true if all fallbacks were used
  30807. */
  30808. allFallbacksProcessed(): boolean;
  30809. /**
  30810. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30811. * @param func The callback to be used.
  30812. */
  30813. executeWhenCompiled(func: (effect: Effect) => void): void;
  30814. private _checkIsReady;
  30815. private _loadShader;
  30816. /**
  30817. * Gets the vertex shader source code of this effect
  30818. */
  30819. get vertexSourceCode(): string;
  30820. /**
  30821. * Gets the fragment shader source code of this effect
  30822. */
  30823. get fragmentSourceCode(): string;
  30824. /**
  30825. * Recompiles the webGL program
  30826. * @param vertexSourceCode The source code for the vertex shader.
  30827. * @param fragmentSourceCode The source code for the fragment shader.
  30828. * @param onCompiled Callback called when completed.
  30829. * @param onError Callback called on error.
  30830. * @hidden
  30831. */
  30832. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30833. /**
  30834. * Prepares the effect
  30835. * @hidden
  30836. */
  30837. _prepareEffect(): void;
  30838. private _getShaderCodeAndErrorLine;
  30839. private _processCompilationErrors;
  30840. /**
  30841. * Checks if the effect is supported. (Must be called after compilation)
  30842. */
  30843. get isSupported(): boolean;
  30844. /**
  30845. * Binds a texture to the engine to be used as output of the shader.
  30846. * @param channel Name of the output variable.
  30847. * @param texture Texture to bind.
  30848. * @hidden
  30849. */
  30850. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30851. /**
  30852. * Sets a texture on the engine to be used in the shader.
  30853. * @param channel Name of the sampler variable.
  30854. * @param texture Texture to set.
  30855. */
  30856. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30857. /**
  30858. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30859. * @param channel Name of the sampler variable.
  30860. * @param texture Texture to set.
  30861. */
  30862. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30863. /**
  30864. * Sets an array of textures on the engine to be used in the shader.
  30865. * @param channel Name of the variable.
  30866. * @param textures Textures to set.
  30867. */
  30868. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30869. /**
  30870. * 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)
  30871. * @param channel Name of the sampler variable.
  30872. * @param postProcess Post process to get the input texture from.
  30873. */
  30874. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30875. /**
  30876. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30877. * 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)
  30878. * @param channel Name of the sampler variable.
  30879. * @param postProcess Post process to get the output texture from.
  30880. */
  30881. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30882. /** @hidden */
  30883. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30884. /** @hidden */
  30885. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30886. /** @hidden */
  30887. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30888. /** @hidden */
  30889. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30890. /**
  30891. * Binds a buffer to a uniform.
  30892. * @param buffer Buffer to bind.
  30893. * @param name Name of the uniform variable to bind to.
  30894. */
  30895. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30896. /**
  30897. * Binds block to a uniform.
  30898. * @param blockName Name of the block to bind.
  30899. * @param index Index to bind.
  30900. */
  30901. bindUniformBlock(blockName: string, index: number): void;
  30902. /**
  30903. * Sets an interger value on a uniform variable.
  30904. * @param uniformName Name of the variable.
  30905. * @param value Value to be set.
  30906. * @returns this effect.
  30907. */
  30908. setInt(uniformName: string, value: number): Effect;
  30909. /**
  30910. * Sets an int array on a uniform variable.
  30911. * @param uniformName Name of the variable.
  30912. * @param array array to be set.
  30913. * @returns this effect.
  30914. */
  30915. setIntArray(uniformName: string, array: Int32Array): Effect;
  30916. /**
  30917. * 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)
  30918. * @param uniformName Name of the variable.
  30919. * @param array array to be set.
  30920. * @returns this effect.
  30921. */
  30922. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30923. /**
  30924. * 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)
  30925. * @param uniformName Name of the variable.
  30926. * @param array array to be set.
  30927. * @returns this effect.
  30928. */
  30929. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30930. /**
  30931. * 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)
  30932. * @param uniformName Name of the variable.
  30933. * @param array array to be set.
  30934. * @returns this effect.
  30935. */
  30936. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30937. /**
  30938. * Sets an float array on a uniform variable.
  30939. * @param uniformName Name of the variable.
  30940. * @param array array to be set.
  30941. * @returns this effect.
  30942. */
  30943. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30944. /**
  30945. * 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)
  30946. * @param uniformName Name of the variable.
  30947. * @param array array to be set.
  30948. * @returns this effect.
  30949. */
  30950. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30951. /**
  30952. * 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)
  30953. * @param uniformName Name of the variable.
  30954. * @param array array to be set.
  30955. * @returns this effect.
  30956. */
  30957. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30958. /**
  30959. * 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)
  30960. * @param uniformName Name of the variable.
  30961. * @param array array to be set.
  30962. * @returns this effect.
  30963. */
  30964. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30965. /**
  30966. * Sets an array on a uniform variable.
  30967. * @param uniformName Name of the variable.
  30968. * @param array array to be set.
  30969. * @returns this effect.
  30970. */
  30971. setArray(uniformName: string, array: number[]): Effect;
  30972. /**
  30973. * 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)
  30974. * @param uniformName Name of the variable.
  30975. * @param array array to be set.
  30976. * @returns this effect.
  30977. */
  30978. setArray2(uniformName: string, array: number[]): Effect;
  30979. /**
  30980. * 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)
  30981. * @param uniformName Name of the variable.
  30982. * @param array array to be set.
  30983. * @returns this effect.
  30984. */
  30985. setArray3(uniformName: string, array: number[]): Effect;
  30986. /**
  30987. * 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)
  30988. * @param uniformName Name of the variable.
  30989. * @param array array to be set.
  30990. * @returns this effect.
  30991. */
  30992. setArray4(uniformName: string, array: number[]): Effect;
  30993. /**
  30994. * Sets matrices on a uniform variable.
  30995. * @param uniformName Name of the variable.
  30996. * @param matrices matrices to be set.
  30997. * @returns this effect.
  30998. */
  30999. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31000. /**
  31001. * Sets matrix on a uniform variable.
  31002. * @param uniformName Name of the variable.
  31003. * @param matrix matrix to be set.
  31004. * @returns this effect.
  31005. */
  31006. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31007. /**
  31008. * 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)
  31009. * @param uniformName Name of the variable.
  31010. * @param matrix matrix to be set.
  31011. * @returns this effect.
  31012. */
  31013. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31014. /**
  31015. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31016. * @param uniformName Name of the variable.
  31017. * @param matrix matrix to be set.
  31018. * @returns this effect.
  31019. */
  31020. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31021. /**
  31022. * Sets a float on a uniform variable.
  31023. * @param uniformName Name of the variable.
  31024. * @param value value to be set.
  31025. * @returns this effect.
  31026. */
  31027. setFloat(uniformName: string, value: number): Effect;
  31028. /**
  31029. * Sets a boolean on a uniform variable.
  31030. * @param uniformName Name of the variable.
  31031. * @param bool value to be set.
  31032. * @returns this effect.
  31033. */
  31034. setBool(uniformName: string, bool: boolean): Effect;
  31035. /**
  31036. * Sets a Vector2 on a uniform variable.
  31037. * @param uniformName Name of the variable.
  31038. * @param vector2 vector2 to be set.
  31039. * @returns this effect.
  31040. */
  31041. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31042. /**
  31043. * Sets a float2 on a uniform variable.
  31044. * @param uniformName Name of the variable.
  31045. * @param x First float in float2.
  31046. * @param y Second float in float2.
  31047. * @returns this effect.
  31048. */
  31049. setFloat2(uniformName: string, x: number, y: number): Effect;
  31050. /**
  31051. * Sets a Vector3 on a uniform variable.
  31052. * @param uniformName Name of the variable.
  31053. * @param vector3 Value to be set.
  31054. * @returns this effect.
  31055. */
  31056. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31057. /**
  31058. * Sets a float3 on a uniform variable.
  31059. * @param uniformName Name of the variable.
  31060. * @param x First float in float3.
  31061. * @param y Second float in float3.
  31062. * @param z Third float in float3.
  31063. * @returns this effect.
  31064. */
  31065. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31066. /**
  31067. * Sets a Vector4 on a uniform variable.
  31068. * @param uniformName Name of the variable.
  31069. * @param vector4 Value to be set.
  31070. * @returns this effect.
  31071. */
  31072. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31073. /**
  31074. * Sets a float4 on a uniform variable.
  31075. * @param uniformName Name of the variable.
  31076. * @param x First float in float4.
  31077. * @param y Second float in float4.
  31078. * @param z Third float in float4.
  31079. * @param w Fourth float in float4.
  31080. * @returns this effect.
  31081. */
  31082. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31083. /**
  31084. * Sets a Color3 on a uniform variable.
  31085. * @param uniformName Name of the variable.
  31086. * @param color3 Value to be set.
  31087. * @returns this effect.
  31088. */
  31089. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31090. /**
  31091. * Sets a Color4 on a uniform variable.
  31092. * @param uniformName Name of the variable.
  31093. * @param color3 Value to be set.
  31094. * @param alpha Alpha value to be set.
  31095. * @returns this effect.
  31096. */
  31097. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31098. /**
  31099. * Sets a Color4 on a uniform variable
  31100. * @param uniformName defines the name of the variable
  31101. * @param color4 defines the value to be set
  31102. * @returns this effect.
  31103. */
  31104. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31105. /** Release all associated resources */
  31106. dispose(): void;
  31107. /**
  31108. * This function will add a new shader to the shader store
  31109. * @param name the name of the shader
  31110. * @param pixelShader optional pixel shader content
  31111. * @param vertexShader optional vertex shader content
  31112. */
  31113. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31114. /**
  31115. * Store of each shader (The can be looked up using effect.key)
  31116. */
  31117. static ShadersStore: {
  31118. [key: string]: string;
  31119. };
  31120. /**
  31121. * Store of each included file for a shader (The can be looked up using effect.key)
  31122. */
  31123. static IncludesShadersStore: {
  31124. [key: string]: string;
  31125. };
  31126. /**
  31127. * Resets the cache of effects.
  31128. */
  31129. static ResetCache(): void;
  31130. }
  31131. }
  31132. declare module BABYLON {
  31133. /**
  31134. * Interface used to describe the capabilities of the engine relatively to the current browser
  31135. */
  31136. export interface EngineCapabilities {
  31137. /** Maximum textures units per fragment shader */
  31138. maxTexturesImageUnits: number;
  31139. /** Maximum texture units per vertex shader */
  31140. maxVertexTextureImageUnits: number;
  31141. /** Maximum textures units in the entire pipeline */
  31142. maxCombinedTexturesImageUnits: number;
  31143. /** Maximum texture size */
  31144. maxTextureSize: number;
  31145. /** Maximum texture samples */
  31146. maxSamples?: number;
  31147. /** Maximum cube texture size */
  31148. maxCubemapTextureSize: number;
  31149. /** Maximum render texture size */
  31150. maxRenderTextureSize: number;
  31151. /** Maximum number of vertex attributes */
  31152. maxVertexAttribs: number;
  31153. /** Maximum number of varyings */
  31154. maxVaryingVectors: number;
  31155. /** Maximum number of uniforms per vertex shader */
  31156. maxVertexUniformVectors: number;
  31157. /** Maximum number of uniforms per fragment shader */
  31158. maxFragmentUniformVectors: number;
  31159. /** Defines if standard derivates (dx/dy) are supported */
  31160. standardDerivatives: boolean;
  31161. /** Defines if s3tc texture compression is supported */
  31162. s3tc?: WEBGL_compressed_texture_s3tc;
  31163. /** Defines if pvrtc texture compression is supported */
  31164. pvrtc: any;
  31165. /** Defines if etc1 texture compression is supported */
  31166. etc1: any;
  31167. /** Defines if etc2 texture compression is supported */
  31168. etc2: any;
  31169. /** Defines if astc texture compression is supported */
  31170. astc: any;
  31171. /** Defines if float textures are supported */
  31172. textureFloat: boolean;
  31173. /** Defines if vertex array objects are supported */
  31174. vertexArrayObject: boolean;
  31175. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31176. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31177. /** Gets the maximum level of anisotropy supported */
  31178. maxAnisotropy: number;
  31179. /** Defines if instancing is supported */
  31180. instancedArrays: boolean;
  31181. /** Defines if 32 bits indices are supported */
  31182. uintIndices: boolean;
  31183. /** Defines if high precision shaders are supported */
  31184. highPrecisionShaderSupported: boolean;
  31185. /** Defines if depth reading in the fragment shader is supported */
  31186. fragmentDepthSupported: boolean;
  31187. /** Defines if float texture linear filtering is supported*/
  31188. textureFloatLinearFiltering: boolean;
  31189. /** Defines if rendering to float textures is supported */
  31190. textureFloatRender: boolean;
  31191. /** Defines if half float textures are supported*/
  31192. textureHalfFloat: boolean;
  31193. /** Defines if half float texture linear filtering is supported*/
  31194. textureHalfFloatLinearFiltering: boolean;
  31195. /** Defines if rendering to half float textures is supported */
  31196. textureHalfFloatRender: boolean;
  31197. /** Defines if textureLOD shader command is supported */
  31198. textureLOD: boolean;
  31199. /** Defines if draw buffers extension is supported */
  31200. drawBuffersExtension: boolean;
  31201. /** Defines if depth textures are supported */
  31202. depthTextureExtension: boolean;
  31203. /** Defines if float color buffer are supported */
  31204. colorBufferFloat: boolean;
  31205. /** Gets disjoint timer query extension (null if not supported) */
  31206. timerQuery?: EXT_disjoint_timer_query;
  31207. /** Defines if timestamp can be used with timer query */
  31208. canUseTimestampForTimerQuery: boolean;
  31209. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31210. multiview?: any;
  31211. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31212. oculusMultiview?: any;
  31213. /** Function used to let the system compiles shaders in background */
  31214. parallelShaderCompile?: {
  31215. COMPLETION_STATUS_KHR: number;
  31216. };
  31217. /** Max number of texture samples for MSAA */
  31218. maxMSAASamples: number;
  31219. /** Defines if the blend min max extension is supported */
  31220. blendMinMax: boolean;
  31221. }
  31222. }
  31223. declare module BABYLON {
  31224. /**
  31225. * @hidden
  31226. **/
  31227. export class DepthCullingState {
  31228. private _isDepthTestDirty;
  31229. private _isDepthMaskDirty;
  31230. private _isDepthFuncDirty;
  31231. private _isCullFaceDirty;
  31232. private _isCullDirty;
  31233. private _isZOffsetDirty;
  31234. private _isFrontFaceDirty;
  31235. private _depthTest;
  31236. private _depthMask;
  31237. private _depthFunc;
  31238. private _cull;
  31239. private _cullFace;
  31240. private _zOffset;
  31241. private _frontFace;
  31242. /**
  31243. * Initializes the state.
  31244. */
  31245. constructor();
  31246. get isDirty(): boolean;
  31247. get zOffset(): number;
  31248. set zOffset(value: number);
  31249. get cullFace(): Nullable<number>;
  31250. set cullFace(value: Nullable<number>);
  31251. get cull(): Nullable<boolean>;
  31252. set cull(value: Nullable<boolean>);
  31253. get depthFunc(): Nullable<number>;
  31254. set depthFunc(value: Nullable<number>);
  31255. get depthMask(): boolean;
  31256. set depthMask(value: boolean);
  31257. get depthTest(): boolean;
  31258. set depthTest(value: boolean);
  31259. get frontFace(): Nullable<number>;
  31260. set frontFace(value: Nullable<number>);
  31261. reset(): void;
  31262. apply(gl: WebGLRenderingContext): void;
  31263. }
  31264. }
  31265. declare module BABYLON {
  31266. /**
  31267. * @hidden
  31268. **/
  31269. export class StencilState {
  31270. /** 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 */
  31271. static readonly ALWAYS: number;
  31272. /** Passed to stencilOperation to specify that stencil value must be kept */
  31273. static readonly KEEP: number;
  31274. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31275. static readonly REPLACE: number;
  31276. private _isStencilTestDirty;
  31277. private _isStencilMaskDirty;
  31278. private _isStencilFuncDirty;
  31279. private _isStencilOpDirty;
  31280. private _stencilTest;
  31281. private _stencilMask;
  31282. private _stencilFunc;
  31283. private _stencilFuncRef;
  31284. private _stencilFuncMask;
  31285. private _stencilOpStencilFail;
  31286. private _stencilOpDepthFail;
  31287. private _stencilOpStencilDepthPass;
  31288. get isDirty(): boolean;
  31289. get stencilFunc(): number;
  31290. set stencilFunc(value: number);
  31291. get stencilFuncRef(): number;
  31292. set stencilFuncRef(value: number);
  31293. get stencilFuncMask(): number;
  31294. set stencilFuncMask(value: number);
  31295. get stencilOpStencilFail(): number;
  31296. set stencilOpStencilFail(value: number);
  31297. get stencilOpDepthFail(): number;
  31298. set stencilOpDepthFail(value: number);
  31299. get stencilOpStencilDepthPass(): number;
  31300. set stencilOpStencilDepthPass(value: number);
  31301. get stencilMask(): number;
  31302. set stencilMask(value: number);
  31303. get stencilTest(): boolean;
  31304. set stencilTest(value: boolean);
  31305. constructor();
  31306. reset(): void;
  31307. apply(gl: WebGLRenderingContext): void;
  31308. }
  31309. }
  31310. declare module BABYLON {
  31311. /**
  31312. * @hidden
  31313. **/
  31314. export class AlphaState {
  31315. private _isAlphaBlendDirty;
  31316. private _isBlendFunctionParametersDirty;
  31317. private _isBlendEquationParametersDirty;
  31318. private _isBlendConstantsDirty;
  31319. private _alphaBlend;
  31320. private _blendFunctionParameters;
  31321. private _blendEquationParameters;
  31322. private _blendConstants;
  31323. /**
  31324. * Initializes the state.
  31325. */
  31326. constructor();
  31327. get isDirty(): boolean;
  31328. get alphaBlend(): boolean;
  31329. set alphaBlend(value: boolean);
  31330. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31331. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31332. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31333. reset(): void;
  31334. apply(gl: WebGLRenderingContext): void;
  31335. }
  31336. }
  31337. declare module BABYLON {
  31338. /** @hidden */
  31339. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31340. attributeProcessor(attribute: string): string;
  31341. varyingProcessor(varying: string, isFragment: boolean): string;
  31342. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31343. }
  31344. }
  31345. declare module BABYLON {
  31346. /**
  31347. * Interface for attribute information associated with buffer instanciation
  31348. */
  31349. export interface InstancingAttributeInfo {
  31350. /**
  31351. * Name of the GLSL attribute
  31352. * if attribute index is not specified, this is used to retrieve the index from the effect
  31353. */
  31354. attributeName: string;
  31355. /**
  31356. * Index/offset of the attribute in the vertex shader
  31357. * if not specified, this will be computes from the name.
  31358. */
  31359. index?: number;
  31360. /**
  31361. * size of the attribute, 1, 2, 3 or 4
  31362. */
  31363. attributeSize: number;
  31364. /**
  31365. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31366. */
  31367. offset: number;
  31368. /**
  31369. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31370. * default to 1
  31371. */
  31372. divisor?: number;
  31373. /**
  31374. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31375. * default is FLOAT
  31376. */
  31377. attributeType?: number;
  31378. /**
  31379. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31380. */
  31381. normalized?: boolean;
  31382. }
  31383. }
  31384. declare module BABYLON {
  31385. interface ThinEngine {
  31386. /**
  31387. * Update a video texture
  31388. * @param texture defines the texture to update
  31389. * @param video defines the video element to use
  31390. * @param invertY defines if data must be stored with Y axis inverted
  31391. */
  31392. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31393. }
  31394. }
  31395. declare module BABYLON {
  31396. /**
  31397. * Settings for finer control over video usage
  31398. */
  31399. export interface VideoTextureSettings {
  31400. /**
  31401. * Applies `autoplay` to video, if specified
  31402. */
  31403. autoPlay?: boolean;
  31404. /**
  31405. * Applies `loop` to video, if specified
  31406. */
  31407. loop?: boolean;
  31408. /**
  31409. * Automatically updates internal texture from video at every frame in the render loop
  31410. */
  31411. autoUpdateTexture: boolean;
  31412. /**
  31413. * Image src displayed during the video loading or until the user interacts with the video.
  31414. */
  31415. poster?: string;
  31416. }
  31417. /**
  31418. * If you want to display a video in your scene, this is the special texture for that.
  31419. * This special texture works similar to other textures, with the exception of a few parameters.
  31420. * @see https://doc.babylonjs.com/how_to/video_texture
  31421. */
  31422. export class VideoTexture extends Texture {
  31423. /**
  31424. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31425. */
  31426. readonly autoUpdateTexture: boolean;
  31427. /**
  31428. * The video instance used by the texture internally
  31429. */
  31430. readonly video: HTMLVideoElement;
  31431. private _onUserActionRequestedObservable;
  31432. /**
  31433. * Event triggerd when a dom action is required by the user to play the video.
  31434. * This happens due to recent changes in browser policies preventing video to auto start.
  31435. */
  31436. get onUserActionRequestedObservable(): Observable<Texture>;
  31437. private _generateMipMaps;
  31438. private _stillImageCaptured;
  31439. private _displayingPosterTexture;
  31440. private _settings;
  31441. private _createInternalTextureOnEvent;
  31442. private _frameId;
  31443. private _currentSrc;
  31444. /**
  31445. * Creates a video texture.
  31446. * If you want to display a video in your scene, this is the special texture for that.
  31447. * This special texture works similar to other textures, with the exception of a few parameters.
  31448. * @see https://doc.babylonjs.com/how_to/video_texture
  31449. * @param name optional name, will detect from video source, if not defined
  31450. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31451. * @param scene is obviously the current scene.
  31452. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31453. * @param invertY is false by default but can be used to invert video on Y axis
  31454. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31455. * @param settings allows finer control over video usage
  31456. */
  31457. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31458. private _getName;
  31459. private _getVideo;
  31460. private _createInternalTexture;
  31461. private reset;
  31462. /**
  31463. * @hidden Internal method to initiate `update`.
  31464. */
  31465. _rebuild(): void;
  31466. /**
  31467. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31468. */
  31469. update(): void;
  31470. /**
  31471. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31472. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31473. */
  31474. updateTexture(isVisible: boolean): void;
  31475. protected _updateInternalTexture: () => void;
  31476. /**
  31477. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31478. * @param url New url.
  31479. */
  31480. updateURL(url: string): void;
  31481. /**
  31482. * Clones the texture.
  31483. * @returns the cloned texture
  31484. */
  31485. clone(): VideoTexture;
  31486. /**
  31487. * Dispose the texture and release its associated resources.
  31488. */
  31489. dispose(): void;
  31490. /**
  31491. * Creates a video texture straight from a stream.
  31492. * @param scene Define the scene the texture should be created in
  31493. * @param stream Define the stream the texture should be created from
  31494. * @returns The created video texture as a promise
  31495. */
  31496. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31497. /**
  31498. * Creates a video texture straight from your WebCam video feed.
  31499. * @param scene Define the scene the texture should be created in
  31500. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31501. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31502. * @returns The created video texture as a promise
  31503. */
  31504. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31505. minWidth: number;
  31506. maxWidth: number;
  31507. minHeight: number;
  31508. maxHeight: number;
  31509. deviceId: string;
  31510. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31511. /**
  31512. * Creates a video texture straight from your WebCam video feed.
  31513. * @param scene Define the scene the texture should be created in
  31514. * @param onReady Define a callback to triggered once the texture will be ready
  31515. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31516. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31517. */
  31518. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31519. minWidth: number;
  31520. maxWidth: number;
  31521. minHeight: number;
  31522. maxHeight: number;
  31523. deviceId: string;
  31524. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31525. }
  31526. }
  31527. declare module BABYLON {
  31528. /**
  31529. * Defines the interface used by objects working like Scene
  31530. * @hidden
  31531. */
  31532. export interface ISceneLike {
  31533. _addPendingData(data: any): void;
  31534. _removePendingData(data: any): void;
  31535. offlineProvider: IOfflineProvider;
  31536. }
  31537. /** Interface defining initialization parameters for Engine class */
  31538. export interface EngineOptions extends WebGLContextAttributes {
  31539. /**
  31540. * Defines if the engine should no exceed a specified device ratio
  31541. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31542. */
  31543. limitDeviceRatio?: number;
  31544. /**
  31545. * Defines if webvr should be enabled automatically
  31546. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31547. */
  31548. autoEnableWebVR?: boolean;
  31549. /**
  31550. * Defines if webgl2 should be turned off even if supported
  31551. * @see http://doc.babylonjs.com/features/webgl2
  31552. */
  31553. disableWebGL2Support?: boolean;
  31554. /**
  31555. * Defines if webaudio should be initialized as well
  31556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31557. */
  31558. audioEngine?: boolean;
  31559. /**
  31560. * Defines if animations should run using a deterministic lock step
  31561. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31562. */
  31563. deterministicLockstep?: boolean;
  31564. /** Defines the maximum steps to use with deterministic lock step mode */
  31565. lockstepMaxSteps?: number;
  31566. /** Defines the seconds between each deterministic lock step */
  31567. timeStep?: number;
  31568. /**
  31569. * Defines that engine should ignore context lost events
  31570. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31571. */
  31572. doNotHandleContextLost?: boolean;
  31573. /**
  31574. * Defines that engine should ignore modifying touch action attribute and style
  31575. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31576. */
  31577. doNotHandleTouchAction?: boolean;
  31578. /**
  31579. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31580. */
  31581. useHighPrecisionFloats?: boolean;
  31582. }
  31583. /**
  31584. * The base engine class (root of all engines)
  31585. */
  31586. export class ThinEngine {
  31587. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31588. static ExceptionList: ({
  31589. key: string;
  31590. capture: string;
  31591. captureConstraint: number;
  31592. targets: string[];
  31593. } | {
  31594. key: string;
  31595. capture: null;
  31596. captureConstraint: null;
  31597. targets: string[];
  31598. })[];
  31599. /** @hidden */
  31600. static _TextureLoaders: IInternalTextureLoader[];
  31601. /**
  31602. * Returns the current npm package of the sdk
  31603. */
  31604. static get NpmPackage(): string;
  31605. /**
  31606. * Returns the current version of the framework
  31607. */
  31608. static get Version(): string;
  31609. /**
  31610. * Returns a string describing the current engine
  31611. */
  31612. get description(): string;
  31613. /**
  31614. * Gets or sets the epsilon value used by collision engine
  31615. */
  31616. static CollisionsEpsilon: number;
  31617. /**
  31618. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31619. */
  31620. static get ShadersRepository(): string;
  31621. static set ShadersRepository(value: string);
  31622. /** @hidden */
  31623. _shaderProcessor: IShaderProcessor;
  31624. /**
  31625. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31626. */
  31627. forcePOTTextures: boolean;
  31628. /**
  31629. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31630. */
  31631. isFullscreen: boolean;
  31632. /**
  31633. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31634. */
  31635. cullBackFaces: boolean;
  31636. /**
  31637. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31638. */
  31639. renderEvenInBackground: boolean;
  31640. /**
  31641. * Gets or sets a boolean indicating that cache can be kept between frames
  31642. */
  31643. preventCacheWipeBetweenFrames: boolean;
  31644. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31645. validateShaderPrograms: boolean;
  31646. /**
  31647. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31648. * This can provide greater z depth for distant objects.
  31649. */
  31650. useReverseDepthBuffer: boolean;
  31651. /**
  31652. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31653. */
  31654. disableUniformBuffers: boolean;
  31655. /** @hidden */
  31656. _uniformBuffers: UniformBuffer[];
  31657. /**
  31658. * Gets a boolean indicating that the engine supports uniform buffers
  31659. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31660. */
  31661. get supportsUniformBuffers(): boolean;
  31662. /** @hidden */
  31663. _gl: WebGLRenderingContext;
  31664. /** @hidden */
  31665. _webGLVersion: number;
  31666. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31667. protected _windowIsBackground: boolean;
  31668. protected _creationOptions: EngineOptions;
  31669. protected _highPrecisionShadersAllowed: boolean;
  31670. /** @hidden */
  31671. get _shouldUseHighPrecisionShader(): boolean;
  31672. /**
  31673. * Gets a boolean indicating that only power of 2 textures are supported
  31674. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31675. */
  31676. get needPOTTextures(): boolean;
  31677. /** @hidden */
  31678. _badOS: boolean;
  31679. /** @hidden */
  31680. _badDesktopOS: boolean;
  31681. private _hardwareScalingLevel;
  31682. /** @hidden */
  31683. _caps: EngineCapabilities;
  31684. private _isStencilEnable;
  31685. private _glVersion;
  31686. private _glRenderer;
  31687. private _glVendor;
  31688. /** @hidden */
  31689. _videoTextureSupported: boolean;
  31690. protected _renderingQueueLaunched: boolean;
  31691. protected _activeRenderLoops: (() => void)[];
  31692. /**
  31693. * Observable signaled when a context lost event is raised
  31694. */
  31695. onContextLostObservable: Observable<ThinEngine>;
  31696. /**
  31697. * Observable signaled when a context restored event is raised
  31698. */
  31699. onContextRestoredObservable: Observable<ThinEngine>;
  31700. private _onContextLost;
  31701. private _onContextRestored;
  31702. protected _contextWasLost: boolean;
  31703. /** @hidden */
  31704. _doNotHandleContextLost: boolean;
  31705. /**
  31706. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31708. */
  31709. get doNotHandleContextLost(): boolean;
  31710. set doNotHandleContextLost(value: boolean);
  31711. /**
  31712. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31713. */
  31714. disableVertexArrayObjects: boolean;
  31715. /** @hidden */
  31716. protected _colorWrite: boolean;
  31717. /** @hidden */
  31718. protected _colorWriteChanged: boolean;
  31719. /** @hidden */
  31720. protected _depthCullingState: DepthCullingState;
  31721. /** @hidden */
  31722. protected _stencilState: StencilState;
  31723. /** @hidden */
  31724. _alphaState: AlphaState;
  31725. /** @hidden */
  31726. _alphaMode: number;
  31727. /** @hidden */
  31728. _alphaEquation: number;
  31729. /** @hidden */
  31730. _internalTexturesCache: InternalTexture[];
  31731. /** @hidden */
  31732. protected _activeChannel: number;
  31733. private _currentTextureChannel;
  31734. /** @hidden */
  31735. protected _boundTexturesCache: {
  31736. [key: string]: Nullable<InternalTexture>;
  31737. };
  31738. /** @hidden */
  31739. protected _currentEffect: Nullable<Effect>;
  31740. /** @hidden */
  31741. protected _currentProgram: Nullable<WebGLProgram>;
  31742. private _compiledEffects;
  31743. private _vertexAttribArraysEnabled;
  31744. /** @hidden */
  31745. protected _cachedViewport: Nullable<IViewportLike>;
  31746. private _cachedVertexArrayObject;
  31747. /** @hidden */
  31748. protected _cachedVertexBuffers: any;
  31749. /** @hidden */
  31750. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31751. /** @hidden */
  31752. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31753. /** @hidden */
  31754. _currentRenderTarget: Nullable<InternalTexture>;
  31755. private _uintIndicesCurrentlySet;
  31756. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31757. /** @hidden */
  31758. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31759. /** @hidden */
  31760. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  31761. private _currentBufferPointers;
  31762. private _currentInstanceLocations;
  31763. private _currentInstanceBuffers;
  31764. private _textureUnits;
  31765. /** @hidden */
  31766. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31767. /** @hidden */
  31768. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31769. /** @hidden */
  31770. _boundRenderFunction: any;
  31771. private _vaoRecordInProgress;
  31772. private _mustWipeVertexAttributes;
  31773. private _emptyTexture;
  31774. private _emptyCubeTexture;
  31775. private _emptyTexture3D;
  31776. private _emptyTexture2DArray;
  31777. /** @hidden */
  31778. _frameHandler: number;
  31779. private _nextFreeTextureSlots;
  31780. private _maxSimultaneousTextures;
  31781. private _activeRequests;
  31782. /** @hidden */
  31783. _transformTextureUrl: Nullable<(url: string) => string>;
  31784. protected get _supportsHardwareTextureRescaling(): boolean;
  31785. private _framebufferDimensionsObject;
  31786. /**
  31787. * sets the object from which width and height will be taken from when getting render width and height
  31788. * Will fallback to the gl object
  31789. * @param dimensions the framebuffer width and height that will be used.
  31790. */
  31791. set framebufferDimensionsObject(dimensions: Nullable<{
  31792. framebufferWidth: number;
  31793. framebufferHeight: number;
  31794. }>);
  31795. /**
  31796. * Gets the current viewport
  31797. */
  31798. get currentViewport(): Nullable<IViewportLike>;
  31799. /**
  31800. * Gets the default empty texture
  31801. */
  31802. get emptyTexture(): InternalTexture;
  31803. /**
  31804. * Gets the default empty 3D texture
  31805. */
  31806. get emptyTexture3D(): InternalTexture;
  31807. /**
  31808. * Gets the default empty 2D array texture
  31809. */
  31810. get emptyTexture2DArray(): InternalTexture;
  31811. /**
  31812. * Gets the default empty cube texture
  31813. */
  31814. get emptyCubeTexture(): InternalTexture;
  31815. /**
  31816. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31817. */
  31818. readonly premultipliedAlpha: boolean;
  31819. /**
  31820. * Observable event triggered before each texture is initialized
  31821. */
  31822. onBeforeTextureInitObservable: Observable<Texture>;
  31823. /**
  31824. * Creates a new engine
  31825. * @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
  31826. * @param antialias defines enable antialiasing (default: false)
  31827. * @param options defines further options to be sent to the getContext() function
  31828. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31829. */
  31830. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31831. private _rebuildInternalTextures;
  31832. private _rebuildEffects;
  31833. /**
  31834. * Gets a boolean indicating if all created effects are ready
  31835. * @returns true if all effects are ready
  31836. */
  31837. areAllEffectsReady(): boolean;
  31838. protected _rebuildBuffers(): void;
  31839. protected _initGLContext(): void;
  31840. /**
  31841. * Gets version of the current webGL context
  31842. */
  31843. get webGLVersion(): number;
  31844. /**
  31845. * Gets a string idenfifying the name of the class
  31846. * @returns "Engine" string
  31847. */
  31848. getClassName(): string;
  31849. /**
  31850. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31851. */
  31852. get isStencilEnable(): boolean;
  31853. /** @hidden */
  31854. _prepareWorkingCanvas(): void;
  31855. /**
  31856. * Reset the texture cache to empty state
  31857. */
  31858. resetTextureCache(): void;
  31859. /**
  31860. * Gets an object containing information about the current webGL context
  31861. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31862. */
  31863. getGlInfo(): {
  31864. vendor: string;
  31865. renderer: string;
  31866. version: string;
  31867. };
  31868. /**
  31869. * Defines the hardware scaling level.
  31870. * By default the hardware scaling level is computed from the window device ratio.
  31871. * 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.
  31872. * @param level defines the level to use
  31873. */
  31874. setHardwareScalingLevel(level: number): void;
  31875. /**
  31876. * Gets the current hardware scaling level.
  31877. * By default the hardware scaling level is computed from the window device ratio.
  31878. * 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.
  31879. * @returns a number indicating the current hardware scaling level
  31880. */
  31881. getHardwareScalingLevel(): number;
  31882. /**
  31883. * Gets the list of loaded textures
  31884. * @returns an array containing all loaded textures
  31885. */
  31886. getLoadedTexturesCache(): InternalTexture[];
  31887. /**
  31888. * Gets the object containing all engine capabilities
  31889. * @returns the EngineCapabilities object
  31890. */
  31891. getCaps(): EngineCapabilities;
  31892. /**
  31893. * stop executing a render loop function and remove it from the execution array
  31894. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31895. */
  31896. stopRenderLoop(renderFunction?: () => void): void;
  31897. /** @hidden */
  31898. _renderLoop(): void;
  31899. /**
  31900. * Gets the HTML canvas attached with the current webGL context
  31901. * @returns a HTML canvas
  31902. */
  31903. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31904. /**
  31905. * Gets host window
  31906. * @returns the host window object
  31907. */
  31908. getHostWindow(): Nullable<Window>;
  31909. /**
  31910. * Gets the current render width
  31911. * @param useScreen defines if screen size must be used (or the current render target if any)
  31912. * @returns a number defining the current render width
  31913. */
  31914. getRenderWidth(useScreen?: boolean): number;
  31915. /**
  31916. * Gets the current render height
  31917. * @param useScreen defines if screen size must be used (or the current render target if any)
  31918. * @returns a number defining the current render height
  31919. */
  31920. getRenderHeight(useScreen?: boolean): number;
  31921. /**
  31922. * Can be used to override the current requestAnimationFrame requester.
  31923. * @hidden
  31924. */
  31925. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31926. /**
  31927. * Register and execute a render loop. The engine can have more than one render function
  31928. * @param renderFunction defines the function to continuously execute
  31929. */
  31930. runRenderLoop(renderFunction: () => void): void;
  31931. /**
  31932. * Clear the current render buffer or the current render target (if any is set up)
  31933. * @param color defines the color to use
  31934. * @param backBuffer defines if the back buffer must be cleared
  31935. * @param depth defines if the depth buffer must be cleared
  31936. * @param stencil defines if the stencil buffer must be cleared
  31937. */
  31938. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31939. private _viewportCached;
  31940. /** @hidden */
  31941. _viewport(x: number, y: number, width: number, height: number): void;
  31942. /**
  31943. * Set the WebGL's viewport
  31944. * @param viewport defines the viewport element to be used
  31945. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31946. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31947. */
  31948. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31949. /**
  31950. * Begin a new frame
  31951. */
  31952. beginFrame(): void;
  31953. /**
  31954. * Enf the current frame
  31955. */
  31956. endFrame(): void;
  31957. /**
  31958. * Resize the view according to the canvas' size
  31959. */
  31960. resize(): void;
  31961. /**
  31962. * Force a specific size of the canvas
  31963. * @param width defines the new canvas' width
  31964. * @param height defines the new canvas' height
  31965. */
  31966. setSize(width: number, height: number): void;
  31967. /**
  31968. * Binds the frame buffer to the specified texture.
  31969. * @param texture The texture to render to or null for the default canvas
  31970. * @param faceIndex The face of the texture to render to in case of cube texture
  31971. * @param requiredWidth The width of the target to render to
  31972. * @param requiredHeight The height of the target to render to
  31973. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31974. * @param lodLevel defines the lod level to bind to the frame buffer
  31975. * @param layer defines the 2d array index to bind to frame buffer to
  31976. */
  31977. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31978. /** @hidden */
  31979. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31980. /**
  31981. * Unbind the current render target texture from the webGL context
  31982. * @param texture defines the render target texture to unbind
  31983. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31984. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31985. */
  31986. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31987. /**
  31988. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31989. */
  31990. flushFramebuffer(): void;
  31991. /**
  31992. * Unbind the current render target and bind the default framebuffer
  31993. */
  31994. restoreDefaultFramebuffer(): void;
  31995. /** @hidden */
  31996. protected _resetVertexBufferBinding(): void;
  31997. /**
  31998. * Creates a vertex buffer
  31999. * @param data the data for the vertex buffer
  32000. * @returns the new WebGL static buffer
  32001. */
  32002. createVertexBuffer(data: DataArray): DataBuffer;
  32003. private _createVertexBuffer;
  32004. /**
  32005. * Creates a dynamic vertex buffer
  32006. * @param data the data for the dynamic vertex buffer
  32007. * @returns the new WebGL dynamic buffer
  32008. */
  32009. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32010. protected _resetIndexBufferBinding(): void;
  32011. /**
  32012. * Creates a new index buffer
  32013. * @param indices defines the content of the index buffer
  32014. * @param updatable defines if the index buffer must be updatable
  32015. * @returns a new webGL buffer
  32016. */
  32017. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32018. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32019. /**
  32020. * Bind a webGL buffer to the webGL context
  32021. * @param buffer defines the buffer to bind
  32022. */
  32023. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32024. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32025. private bindBuffer;
  32026. /**
  32027. * update the bound buffer with the given data
  32028. * @param data defines the data to update
  32029. */
  32030. updateArrayBuffer(data: Float32Array): void;
  32031. private _vertexAttribPointer;
  32032. /** @hidden */
  32033. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32034. private _bindVertexBuffersAttributes;
  32035. /**
  32036. * Records a vertex array object
  32037. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32038. * @param vertexBuffers defines the list of vertex buffers to store
  32039. * @param indexBuffer defines the index buffer to store
  32040. * @param effect defines the effect to store
  32041. * @returns the new vertex array object
  32042. */
  32043. recordVertexArrayObject(vertexBuffers: {
  32044. [key: string]: VertexBuffer;
  32045. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32046. /**
  32047. * Bind a specific vertex array object
  32048. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32049. * @param vertexArrayObject defines the vertex array object to bind
  32050. * @param indexBuffer defines the index buffer to bind
  32051. */
  32052. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32053. /**
  32054. * Bind webGl buffers directly to the webGL context
  32055. * @param vertexBuffer defines the vertex buffer to bind
  32056. * @param indexBuffer defines the index buffer to bind
  32057. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32058. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32059. * @param effect defines the effect associated with the vertex buffer
  32060. */
  32061. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32062. private _unbindVertexArrayObject;
  32063. /**
  32064. * Bind a list of vertex buffers to the webGL context
  32065. * @param vertexBuffers defines the list of vertex buffers to bind
  32066. * @param indexBuffer defines the index buffer to bind
  32067. * @param effect defines the effect associated with the vertex buffers
  32068. */
  32069. bindBuffers(vertexBuffers: {
  32070. [key: string]: Nullable<VertexBuffer>;
  32071. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32072. /**
  32073. * Unbind all instance attributes
  32074. */
  32075. unbindInstanceAttributes(): void;
  32076. /**
  32077. * Release and free the memory of a vertex array object
  32078. * @param vao defines the vertex array object to delete
  32079. */
  32080. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32081. /** @hidden */
  32082. _releaseBuffer(buffer: DataBuffer): boolean;
  32083. protected _deleteBuffer(buffer: DataBuffer): void;
  32084. /**
  32085. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32086. * @param instancesBuffer defines the webGL buffer to update and bind
  32087. * @param data defines the data to store in the buffer
  32088. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32089. */
  32090. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32091. /**
  32092. * Bind the content of a webGL buffer used with instantiation
  32093. * @param instancesBuffer defines the webGL buffer to bind
  32094. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32095. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32096. */
  32097. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32098. /**
  32099. * Disable the instance attribute corresponding to the name in parameter
  32100. * @param name defines the name of the attribute to disable
  32101. */
  32102. disableInstanceAttributeByName(name: string): void;
  32103. /**
  32104. * Disable the instance attribute corresponding to the location in parameter
  32105. * @param attributeLocation defines the attribute location of the attribute to disable
  32106. */
  32107. disableInstanceAttribute(attributeLocation: number): void;
  32108. /**
  32109. * Disable the attribute corresponding to the location in parameter
  32110. * @param attributeLocation defines the attribute location of the attribute to disable
  32111. */
  32112. disableAttributeByIndex(attributeLocation: number): void;
  32113. /**
  32114. * Send a draw order
  32115. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32116. * @param indexStart defines the starting index
  32117. * @param indexCount defines the number of index to draw
  32118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32119. */
  32120. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32121. /**
  32122. * Draw a list of points
  32123. * @param verticesStart defines the index of first vertex to draw
  32124. * @param verticesCount defines the count of vertices to draw
  32125. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32126. */
  32127. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32128. /**
  32129. * Draw a list of unindexed primitives
  32130. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32131. * @param verticesStart defines the index of first vertex to draw
  32132. * @param verticesCount defines the count of vertices to draw
  32133. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32134. */
  32135. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32136. /**
  32137. * Draw a list of indexed primitives
  32138. * @param fillMode defines the primitive to use
  32139. * @param indexStart defines the starting index
  32140. * @param indexCount defines the number of index to draw
  32141. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32142. */
  32143. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32144. /**
  32145. * Draw a list of unindexed primitives
  32146. * @param fillMode defines the primitive to use
  32147. * @param verticesStart defines the index of first vertex to draw
  32148. * @param verticesCount defines the count of vertices to draw
  32149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32150. */
  32151. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32152. private _drawMode;
  32153. /** @hidden */
  32154. protected _reportDrawCall(): void;
  32155. /** @hidden */
  32156. _releaseEffect(effect: Effect): void;
  32157. /** @hidden */
  32158. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32159. /**
  32160. * Create a new effect (used to store vertex/fragment shaders)
  32161. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32162. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32163. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32164. * @param samplers defines an array of string used to represent textures
  32165. * @param defines defines the string containing the defines to use to compile the shaders
  32166. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32167. * @param onCompiled defines a function to call when the effect creation is successful
  32168. * @param onError defines a function to call when the effect creation has failed
  32169. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32170. * @returns the new Effect
  32171. */
  32172. 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;
  32173. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32174. private _compileShader;
  32175. private _compileRawShader;
  32176. /** @hidden */
  32177. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32178. /**
  32179. * Directly creates a webGL program
  32180. * @param pipelineContext defines the pipeline context to attach to
  32181. * @param vertexCode defines the vertex shader code to use
  32182. * @param fragmentCode defines the fragment shader code to use
  32183. * @param context defines the webGL context to use (if not set, the current one will be used)
  32184. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32185. * @returns the new webGL program
  32186. */
  32187. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32188. /**
  32189. * Creates a webGL program
  32190. * @param pipelineContext defines the pipeline context to attach to
  32191. * @param vertexCode defines the vertex shader code to use
  32192. * @param fragmentCode defines the fragment shader code to use
  32193. * @param defines defines the string containing the defines to use to compile the shaders
  32194. * @param context defines the webGL context to use (if not set, the current one will be used)
  32195. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32196. * @returns the new webGL program
  32197. */
  32198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32199. /**
  32200. * Creates a new pipeline context
  32201. * @returns the new pipeline
  32202. */
  32203. createPipelineContext(): IPipelineContext;
  32204. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32205. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32206. /** @hidden */
  32207. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32208. /** @hidden */
  32209. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32210. /** @hidden */
  32211. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32212. /**
  32213. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32214. * @param pipelineContext defines the pipeline context to use
  32215. * @param uniformsNames defines the list of uniform names
  32216. * @returns an array of webGL uniform locations
  32217. */
  32218. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32219. /**
  32220. * Gets the lsit of active attributes for a given webGL program
  32221. * @param pipelineContext defines the pipeline context to use
  32222. * @param attributesNames defines the list of attribute names to get
  32223. * @returns an array of indices indicating the offset of each attribute
  32224. */
  32225. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32226. /**
  32227. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32228. * @param effect defines the effect to activate
  32229. */
  32230. enableEffect(effect: Nullable<Effect>): void;
  32231. /**
  32232. * Set the value of an uniform to a number (int)
  32233. * @param uniform defines the webGL uniform location where to store the value
  32234. * @param value defines the int number to store
  32235. */
  32236. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32237. /**
  32238. * Set the value of an uniform to an array of int32
  32239. * @param uniform defines the webGL uniform location where to store the value
  32240. * @param array defines the array of int32 to store
  32241. */
  32242. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32243. /**
  32244. * Set the value of an uniform to an array of int32 (stored as vec2)
  32245. * @param uniform defines the webGL uniform location where to store the value
  32246. * @param array defines the array of int32 to store
  32247. */
  32248. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32249. /**
  32250. * Set the value of an uniform to an array of int32 (stored as vec3)
  32251. * @param uniform defines the webGL uniform location where to store the value
  32252. * @param array defines the array of int32 to store
  32253. */
  32254. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32255. /**
  32256. * Set the value of an uniform to an array of int32 (stored as vec4)
  32257. * @param uniform defines the webGL uniform location where to store the value
  32258. * @param array defines the array of int32 to store
  32259. */
  32260. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32261. /**
  32262. * Set the value of an uniform to an array of number
  32263. * @param uniform defines the webGL uniform location where to store the value
  32264. * @param array defines the array of number to store
  32265. */
  32266. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32267. /**
  32268. * Set the value of an uniform to an array of number (stored as vec2)
  32269. * @param uniform defines the webGL uniform location where to store the value
  32270. * @param array defines the array of number to store
  32271. */
  32272. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32273. /**
  32274. * Set the value of an uniform to an array of number (stored as vec3)
  32275. * @param uniform defines the webGL uniform location where to store the value
  32276. * @param array defines the array of number to store
  32277. */
  32278. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32279. /**
  32280. * Set the value of an uniform to an array of number (stored as vec4)
  32281. * @param uniform defines the webGL uniform location where to store the value
  32282. * @param array defines the array of number to store
  32283. */
  32284. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32285. /**
  32286. * Set the value of an uniform to an array of float32 (stored as matrices)
  32287. * @param uniform defines the webGL uniform location where to store the value
  32288. * @param matrices defines the array of float32 to store
  32289. */
  32290. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32291. /**
  32292. * Set the value of an uniform to a matrix (3x3)
  32293. * @param uniform defines the webGL uniform location where to store the value
  32294. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32295. */
  32296. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32297. /**
  32298. * Set the value of an uniform to a matrix (2x2)
  32299. * @param uniform defines the webGL uniform location where to store the value
  32300. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32301. */
  32302. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32303. /**
  32304. * Set the value of an uniform to a number (float)
  32305. * @param uniform defines the webGL uniform location where to store the value
  32306. * @param value defines the float number to store
  32307. */
  32308. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32309. /**
  32310. * Set the value of an uniform to a vec2
  32311. * @param uniform defines the webGL uniform location where to store the value
  32312. * @param x defines the 1st component of the value
  32313. * @param y defines the 2nd component of the value
  32314. */
  32315. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32316. /**
  32317. * Set the value of an uniform to a vec3
  32318. * @param uniform defines the webGL uniform location where to store the value
  32319. * @param x defines the 1st component of the value
  32320. * @param y defines the 2nd component of the value
  32321. * @param z defines the 3rd component of the value
  32322. */
  32323. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32324. /**
  32325. * Set the value of an uniform to a vec4
  32326. * @param uniform defines the webGL uniform location where to store the value
  32327. * @param x defines the 1st component of the value
  32328. * @param y defines the 2nd component of the value
  32329. * @param z defines the 3rd component of the value
  32330. * @param w defines the 4th component of the value
  32331. */
  32332. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32333. /**
  32334. * Apply all cached states (depth, culling, stencil and alpha)
  32335. */
  32336. applyStates(): void;
  32337. /**
  32338. * Enable or disable color writing
  32339. * @param enable defines the state to set
  32340. */
  32341. setColorWrite(enable: boolean): void;
  32342. /**
  32343. * Gets a boolean indicating if color writing is enabled
  32344. * @returns the current color writing state
  32345. */
  32346. getColorWrite(): boolean;
  32347. /**
  32348. * Gets the depth culling state manager
  32349. */
  32350. get depthCullingState(): DepthCullingState;
  32351. /**
  32352. * Gets the alpha state manager
  32353. */
  32354. get alphaState(): AlphaState;
  32355. /**
  32356. * Gets the stencil state manager
  32357. */
  32358. get stencilState(): StencilState;
  32359. /**
  32360. * Clears the list of texture accessible through engine.
  32361. * This can help preventing texture load conflict due to name collision.
  32362. */
  32363. clearInternalTexturesCache(): void;
  32364. /**
  32365. * Force the entire cache to be cleared
  32366. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32367. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32368. */
  32369. wipeCaches(bruteForce?: boolean): void;
  32370. /** @hidden */
  32371. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32372. min: number;
  32373. mag: number;
  32374. };
  32375. /** @hidden */
  32376. _createTexture(): WebGLTexture;
  32377. /**
  32378. * Usually called from Texture.ts.
  32379. * Passed information to create a WebGLTexture
  32380. * @param url defines a value which contains one of the following:
  32381. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32382. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32383. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32384. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32385. * @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)
  32386. * @param scene needed for loading to the correct scene
  32387. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32388. * @param onLoad optional callback to be called upon successful completion
  32389. * @param onError optional callback to be called upon failure
  32390. * @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
  32391. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32392. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32393. * @param forcedExtension defines the extension to use to pick the right loader
  32394. * @param mimeType defines an optional mime type
  32395. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32396. */
  32397. 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;
  32398. /**
  32399. * Loads an image as an HTMLImageElement.
  32400. * @param input url string, ArrayBuffer, or Blob to load
  32401. * @param onLoad callback called when the image successfully loads
  32402. * @param onError callback called when the image fails to load
  32403. * @param offlineProvider offline provider for caching
  32404. * @param mimeType optional mime type
  32405. * @returns the HTMLImageElement of the loaded image
  32406. * @hidden
  32407. */
  32408. 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>;
  32409. /**
  32410. * @hidden
  32411. */
  32412. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32413. private _unpackFlipYCached;
  32414. /**
  32415. * In case you are sharing the context with other applications, it might
  32416. * be interested to not cache the unpack flip y state to ensure a consistent
  32417. * value would be set.
  32418. */
  32419. enableUnpackFlipYCached: boolean;
  32420. /** @hidden */
  32421. _unpackFlipY(value: boolean): void;
  32422. /** @hidden */
  32423. _getUnpackAlignement(): number;
  32424. private _getTextureTarget;
  32425. /**
  32426. * Update the sampling mode of a given texture
  32427. * @param samplingMode defines the required sampling mode
  32428. * @param texture defines the texture to update
  32429. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32430. */
  32431. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32432. /**
  32433. * Update the sampling mode of a given texture
  32434. * @param texture defines the texture to update
  32435. * @param wrapU defines the texture wrap mode of the u coordinates
  32436. * @param wrapV defines the texture wrap mode of the v coordinates
  32437. * @param wrapR defines the texture wrap mode of the r coordinates
  32438. */
  32439. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32440. /** @hidden */
  32441. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32442. width: number;
  32443. height: number;
  32444. layers?: number;
  32445. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32446. /** @hidden */
  32447. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32448. /** @hidden */
  32449. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32450. /**
  32451. * Update a portion of an internal texture
  32452. * @param texture defines the texture to update
  32453. * @param imageData defines the data to store into the texture
  32454. * @param xOffset defines the x coordinates of the update rectangle
  32455. * @param yOffset defines the y coordinates of the update rectangle
  32456. * @param width defines the width of the update rectangle
  32457. * @param height defines the height of the update rectangle
  32458. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32459. * @param lod defines the lod level to update (0 by default)
  32460. */
  32461. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32462. /** @hidden */
  32463. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32464. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32465. private _prepareWebGLTexture;
  32466. /** @hidden */
  32467. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32468. private _getDepthStencilBuffer;
  32469. /** @hidden */
  32470. _releaseFramebufferObjects(texture: InternalTexture): void;
  32471. /** @hidden */
  32472. _releaseTexture(texture: InternalTexture): void;
  32473. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32474. protected _setProgram(program: WebGLProgram): void;
  32475. protected _boundUniforms: {
  32476. [key: number]: WebGLUniformLocation;
  32477. };
  32478. /**
  32479. * Binds an effect to the webGL context
  32480. * @param effect defines the effect to bind
  32481. */
  32482. bindSamplers(effect: Effect): void;
  32483. private _activateCurrentTexture;
  32484. /** @hidden */
  32485. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32486. /** @hidden */
  32487. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32488. /**
  32489. * Unbind all textures from the webGL context
  32490. */
  32491. unbindAllTextures(): void;
  32492. /**
  32493. * Sets a texture to the according uniform.
  32494. * @param channel The texture channel
  32495. * @param uniform The uniform to set
  32496. * @param texture The texture to apply
  32497. */
  32498. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32499. private _bindSamplerUniformToChannel;
  32500. private _getTextureWrapMode;
  32501. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32502. /**
  32503. * Sets an array of texture to the webGL context
  32504. * @param channel defines the channel where the texture array must be set
  32505. * @param uniform defines the associated uniform location
  32506. * @param textures defines the array of textures to bind
  32507. */
  32508. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32509. /** @hidden */
  32510. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32511. private _setTextureParameterFloat;
  32512. private _setTextureParameterInteger;
  32513. /**
  32514. * Unbind all vertex attributes from the webGL context
  32515. */
  32516. unbindAllAttributes(): void;
  32517. /**
  32518. * 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
  32519. */
  32520. releaseEffects(): void;
  32521. /**
  32522. * Dispose and release all associated resources
  32523. */
  32524. dispose(): void;
  32525. /**
  32526. * Attach a new callback raised when context lost event is fired
  32527. * @param callback defines the callback to call
  32528. */
  32529. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32530. /**
  32531. * Attach a new callback raised when context restored event is fired
  32532. * @param callback defines the callback to call
  32533. */
  32534. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32535. /**
  32536. * Get the current error code of the webGL context
  32537. * @returns the error code
  32538. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32539. */
  32540. getError(): number;
  32541. private _canRenderToFloatFramebuffer;
  32542. private _canRenderToHalfFloatFramebuffer;
  32543. private _canRenderToFramebuffer;
  32544. /** @hidden */
  32545. _getWebGLTextureType(type: number): number;
  32546. /** @hidden */
  32547. _getInternalFormat(format: number): number;
  32548. /** @hidden */
  32549. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32550. /** @hidden */
  32551. _getRGBAMultiSampleBufferFormat(type: number): number;
  32552. /** @hidden */
  32553. _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;
  32554. /**
  32555. * Loads a file from a url
  32556. * @param url url to load
  32557. * @param onSuccess callback called when the file successfully loads
  32558. * @param onProgress callback called while file is loading (if the server supports this mode)
  32559. * @param offlineProvider defines the offline provider for caching
  32560. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32561. * @param onError callback called when the file fails to load
  32562. * @returns a file request object
  32563. * @hidden
  32564. */
  32565. 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;
  32566. /**
  32567. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32568. * @param x defines the x coordinate of the rectangle where pixels must be read
  32569. * @param y defines the y coordinate of the rectangle where pixels must be read
  32570. * @param width defines the width of the rectangle where pixels must be read
  32571. * @param height defines the height of the rectangle where pixels must be read
  32572. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32573. * @returns a Uint8Array containing RGBA colors
  32574. */
  32575. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32576. private static _isSupported;
  32577. /**
  32578. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32579. * @returns true if the engine can be created
  32580. * @ignorenaming
  32581. */
  32582. static isSupported(): boolean;
  32583. /**
  32584. * Find the next highest power of two.
  32585. * @param x Number to start search from.
  32586. * @return Next highest power of two.
  32587. */
  32588. static CeilingPOT(x: number): number;
  32589. /**
  32590. * Find the next lowest power of two.
  32591. * @param x Number to start search from.
  32592. * @return Next lowest power of two.
  32593. */
  32594. static FloorPOT(x: number): number;
  32595. /**
  32596. * Find the nearest power of two.
  32597. * @param x Number to start search from.
  32598. * @return Next nearest power of two.
  32599. */
  32600. static NearestPOT(x: number): number;
  32601. /**
  32602. * Get the closest exponent of two
  32603. * @param value defines the value to approximate
  32604. * @param max defines the maximum value to return
  32605. * @param mode defines how to define the closest value
  32606. * @returns closest exponent of two of the given value
  32607. */
  32608. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32609. /**
  32610. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32611. * @param func - the function to be called
  32612. * @param requester - the object that will request the next frame. Falls back to window.
  32613. * @returns frame number
  32614. */
  32615. static QueueNewFrame(func: () => void, requester?: any): number;
  32616. /**
  32617. * Gets host document
  32618. * @returns the host document object
  32619. */
  32620. getHostDocument(): Nullable<Document>;
  32621. }
  32622. }
  32623. declare module BABYLON {
  32624. /**
  32625. * Class representing spherical harmonics coefficients to the 3rd degree
  32626. */
  32627. export class SphericalHarmonics {
  32628. /**
  32629. * Defines whether or not the harmonics have been prescaled for rendering.
  32630. */
  32631. preScaled: boolean;
  32632. /**
  32633. * The l0,0 coefficients of the spherical harmonics
  32634. */
  32635. l00: Vector3;
  32636. /**
  32637. * The l1,-1 coefficients of the spherical harmonics
  32638. */
  32639. l1_1: Vector3;
  32640. /**
  32641. * The l1,0 coefficients of the spherical harmonics
  32642. */
  32643. l10: Vector3;
  32644. /**
  32645. * The l1,1 coefficients of the spherical harmonics
  32646. */
  32647. l11: Vector3;
  32648. /**
  32649. * The l2,-2 coefficients of the spherical harmonics
  32650. */
  32651. l2_2: Vector3;
  32652. /**
  32653. * The l2,-1 coefficients of the spherical harmonics
  32654. */
  32655. l2_1: Vector3;
  32656. /**
  32657. * The l2,0 coefficients of the spherical harmonics
  32658. */
  32659. l20: Vector3;
  32660. /**
  32661. * The l2,1 coefficients of the spherical harmonics
  32662. */
  32663. l21: Vector3;
  32664. /**
  32665. * The l2,2 coefficients of the spherical harmonics
  32666. */
  32667. l22: Vector3;
  32668. /**
  32669. * Adds a light to the spherical harmonics
  32670. * @param direction the direction of the light
  32671. * @param color the color of the light
  32672. * @param deltaSolidAngle the delta solid angle of the light
  32673. */
  32674. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32675. /**
  32676. * Scales the spherical harmonics by the given amount
  32677. * @param scale the amount to scale
  32678. */
  32679. scaleInPlace(scale: number): void;
  32680. /**
  32681. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32682. *
  32683. * ```
  32684. * E_lm = A_l * L_lm
  32685. * ```
  32686. *
  32687. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32688. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32689. * the scaling factors are given in equation 9.
  32690. */
  32691. convertIncidentRadianceToIrradiance(): void;
  32692. /**
  32693. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32694. *
  32695. * ```
  32696. * L = (1/pi) * E * rho
  32697. * ```
  32698. *
  32699. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32700. */
  32701. convertIrradianceToLambertianRadiance(): void;
  32702. /**
  32703. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32704. * required operations at run time.
  32705. *
  32706. * This is simply done by scaling back the SH with Ylm constants parameter.
  32707. * The trigonometric part being applied by the shader at run time.
  32708. */
  32709. preScaleForRendering(): void;
  32710. /**
  32711. * Constructs a spherical harmonics from an array.
  32712. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32713. * @returns the spherical harmonics
  32714. */
  32715. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32716. /**
  32717. * Gets the spherical harmonics from polynomial
  32718. * @param polynomial the spherical polynomial
  32719. * @returns the spherical harmonics
  32720. */
  32721. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32722. }
  32723. /**
  32724. * Class representing spherical polynomial coefficients to the 3rd degree
  32725. */
  32726. export class SphericalPolynomial {
  32727. private _harmonics;
  32728. /**
  32729. * The spherical harmonics used to create the polynomials.
  32730. */
  32731. get preScaledHarmonics(): SphericalHarmonics;
  32732. /**
  32733. * The x coefficients of the spherical polynomial
  32734. */
  32735. x: Vector3;
  32736. /**
  32737. * The y coefficients of the spherical polynomial
  32738. */
  32739. y: Vector3;
  32740. /**
  32741. * The z coefficients of the spherical polynomial
  32742. */
  32743. z: Vector3;
  32744. /**
  32745. * The xx coefficients of the spherical polynomial
  32746. */
  32747. xx: Vector3;
  32748. /**
  32749. * The yy coefficients of the spherical polynomial
  32750. */
  32751. yy: Vector3;
  32752. /**
  32753. * The zz coefficients of the spherical polynomial
  32754. */
  32755. zz: Vector3;
  32756. /**
  32757. * The xy coefficients of the spherical polynomial
  32758. */
  32759. xy: Vector3;
  32760. /**
  32761. * The yz coefficients of the spherical polynomial
  32762. */
  32763. yz: Vector3;
  32764. /**
  32765. * The zx coefficients of the spherical polynomial
  32766. */
  32767. zx: Vector3;
  32768. /**
  32769. * Adds an ambient color to the spherical polynomial
  32770. * @param color the color to add
  32771. */
  32772. addAmbient(color: Color3): void;
  32773. /**
  32774. * Scales the spherical polynomial by the given amount
  32775. * @param scale the amount to scale
  32776. */
  32777. scaleInPlace(scale: number): void;
  32778. /**
  32779. * Gets the spherical polynomial from harmonics
  32780. * @param harmonics the spherical harmonics
  32781. * @returns the spherical polynomial
  32782. */
  32783. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32784. /**
  32785. * Constructs a spherical polynomial from an array.
  32786. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32787. * @returns the spherical polynomial
  32788. */
  32789. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32790. }
  32791. }
  32792. declare module BABYLON {
  32793. /**
  32794. * Defines the source of the internal texture
  32795. */
  32796. export enum InternalTextureSource {
  32797. /**
  32798. * The source of the texture data is unknown
  32799. */
  32800. Unknown = 0,
  32801. /**
  32802. * Texture data comes from an URL
  32803. */
  32804. Url = 1,
  32805. /**
  32806. * Texture data is only used for temporary storage
  32807. */
  32808. Temp = 2,
  32809. /**
  32810. * Texture data comes from raw data (ArrayBuffer)
  32811. */
  32812. Raw = 3,
  32813. /**
  32814. * Texture content is dynamic (video or dynamic texture)
  32815. */
  32816. Dynamic = 4,
  32817. /**
  32818. * Texture content is generated by rendering to it
  32819. */
  32820. RenderTarget = 5,
  32821. /**
  32822. * Texture content is part of a multi render target process
  32823. */
  32824. MultiRenderTarget = 6,
  32825. /**
  32826. * Texture data comes from a cube data file
  32827. */
  32828. Cube = 7,
  32829. /**
  32830. * Texture data comes from a raw cube data
  32831. */
  32832. CubeRaw = 8,
  32833. /**
  32834. * Texture data come from a prefiltered cube data file
  32835. */
  32836. CubePrefiltered = 9,
  32837. /**
  32838. * Texture content is raw 3D data
  32839. */
  32840. Raw3D = 10,
  32841. /**
  32842. * Texture content is raw 2D array data
  32843. */
  32844. Raw2DArray = 11,
  32845. /**
  32846. * Texture content is a depth texture
  32847. */
  32848. Depth = 12,
  32849. /**
  32850. * Texture data comes from a raw cube data encoded with RGBD
  32851. */
  32852. CubeRawRGBD = 13
  32853. }
  32854. /**
  32855. * Class used to store data associated with WebGL texture data for the engine
  32856. * This class should not be used directly
  32857. */
  32858. export class InternalTexture {
  32859. /** @hidden */
  32860. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32861. /**
  32862. * Defines if the texture is ready
  32863. */
  32864. isReady: boolean;
  32865. /**
  32866. * Defines if the texture is a cube texture
  32867. */
  32868. isCube: boolean;
  32869. /**
  32870. * Defines if the texture contains 3D data
  32871. */
  32872. is3D: boolean;
  32873. /**
  32874. * Defines if the texture contains 2D array data
  32875. */
  32876. is2DArray: boolean;
  32877. /**
  32878. * Defines if the texture contains multiview data
  32879. */
  32880. isMultiview: boolean;
  32881. /**
  32882. * Gets the URL used to load this texture
  32883. */
  32884. url: string;
  32885. /**
  32886. * Gets the sampling mode of the texture
  32887. */
  32888. samplingMode: number;
  32889. /**
  32890. * Gets a boolean indicating if the texture needs mipmaps generation
  32891. */
  32892. generateMipMaps: boolean;
  32893. /**
  32894. * Gets the number of samples used by the texture (WebGL2+ only)
  32895. */
  32896. samples: number;
  32897. /**
  32898. * Gets the type of the texture (int, float...)
  32899. */
  32900. type: number;
  32901. /**
  32902. * Gets the format of the texture (RGB, RGBA...)
  32903. */
  32904. format: number;
  32905. /**
  32906. * Observable called when the texture is loaded
  32907. */
  32908. onLoadedObservable: Observable<InternalTexture>;
  32909. /**
  32910. * Gets the width of the texture
  32911. */
  32912. width: number;
  32913. /**
  32914. * Gets the height of the texture
  32915. */
  32916. height: number;
  32917. /**
  32918. * Gets the depth of the texture
  32919. */
  32920. depth: number;
  32921. /**
  32922. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32923. */
  32924. baseWidth: number;
  32925. /**
  32926. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32927. */
  32928. baseHeight: number;
  32929. /**
  32930. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32931. */
  32932. baseDepth: number;
  32933. /**
  32934. * Gets a boolean indicating if the texture is inverted on Y axis
  32935. */
  32936. invertY: boolean;
  32937. /** @hidden */
  32938. _invertVScale: boolean;
  32939. /** @hidden */
  32940. _associatedChannel: number;
  32941. /** @hidden */
  32942. _source: InternalTextureSource;
  32943. /** @hidden */
  32944. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32945. /** @hidden */
  32946. _bufferView: Nullable<ArrayBufferView>;
  32947. /** @hidden */
  32948. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32949. /** @hidden */
  32950. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32951. /** @hidden */
  32952. _size: number;
  32953. /** @hidden */
  32954. _extension: string;
  32955. /** @hidden */
  32956. _files: Nullable<string[]>;
  32957. /** @hidden */
  32958. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32959. /** @hidden */
  32960. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32961. /** @hidden */
  32962. _framebuffer: Nullable<WebGLFramebuffer>;
  32963. /** @hidden */
  32964. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32965. /** @hidden */
  32966. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32967. /** @hidden */
  32968. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32969. /** @hidden */
  32970. _attachments: Nullable<number[]>;
  32971. /** @hidden */
  32972. _cachedCoordinatesMode: Nullable<number>;
  32973. /** @hidden */
  32974. _cachedWrapU: Nullable<number>;
  32975. /** @hidden */
  32976. _cachedWrapV: Nullable<number>;
  32977. /** @hidden */
  32978. _cachedWrapR: Nullable<number>;
  32979. /** @hidden */
  32980. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32981. /** @hidden */
  32982. _isDisabled: boolean;
  32983. /** @hidden */
  32984. _compression: Nullable<string>;
  32985. /** @hidden */
  32986. _generateStencilBuffer: boolean;
  32987. /** @hidden */
  32988. _generateDepthBuffer: boolean;
  32989. /** @hidden */
  32990. _comparisonFunction: number;
  32991. /** @hidden */
  32992. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32993. /** @hidden */
  32994. _lodGenerationScale: number;
  32995. /** @hidden */
  32996. _lodGenerationOffset: number;
  32997. /** @hidden */
  32998. _depthStencilTexture: Nullable<InternalTexture>;
  32999. /** @hidden */
  33000. _colorTextureArray: Nullable<WebGLTexture>;
  33001. /** @hidden */
  33002. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33003. /** @hidden */
  33004. _lodTextureHigh: Nullable<BaseTexture>;
  33005. /** @hidden */
  33006. _lodTextureMid: Nullable<BaseTexture>;
  33007. /** @hidden */
  33008. _lodTextureLow: Nullable<BaseTexture>;
  33009. /** @hidden */
  33010. _isRGBD: boolean;
  33011. /** @hidden */
  33012. _linearSpecularLOD: boolean;
  33013. /** @hidden */
  33014. _irradianceTexture: Nullable<BaseTexture>;
  33015. /** @hidden */
  33016. _webGLTexture: Nullable<WebGLTexture>;
  33017. /** @hidden */
  33018. _references: number;
  33019. private _engine;
  33020. /**
  33021. * Gets the Engine the texture belongs to.
  33022. * @returns The babylon engine
  33023. */
  33024. getEngine(): ThinEngine;
  33025. /**
  33026. * Gets the data source type of the texture
  33027. */
  33028. get source(): InternalTextureSource;
  33029. /**
  33030. * Creates a new InternalTexture
  33031. * @param engine defines the engine to use
  33032. * @param source defines the type of data that will be used
  33033. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33034. */
  33035. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33036. /**
  33037. * Increments the number of references (ie. the number of Texture that point to it)
  33038. */
  33039. incrementReferences(): void;
  33040. /**
  33041. * Change the size of the texture (not the size of the content)
  33042. * @param width defines the new width
  33043. * @param height defines the new height
  33044. * @param depth defines the new depth (1 by default)
  33045. */
  33046. updateSize(width: int, height: int, depth?: int): void;
  33047. /** @hidden */
  33048. _rebuild(): void;
  33049. /** @hidden */
  33050. _swapAndDie(target: InternalTexture): void;
  33051. /**
  33052. * Dispose the current allocated resources
  33053. */
  33054. dispose(): void;
  33055. }
  33056. }
  33057. declare module BABYLON {
  33058. /**
  33059. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33061. */
  33062. export class Analyser {
  33063. /**
  33064. * Gets or sets the smoothing
  33065. * @ignorenaming
  33066. */
  33067. SMOOTHING: number;
  33068. /**
  33069. * Gets or sets the FFT table size
  33070. * @ignorenaming
  33071. */
  33072. FFT_SIZE: number;
  33073. /**
  33074. * Gets or sets the bar graph amplitude
  33075. * @ignorenaming
  33076. */
  33077. BARGRAPHAMPLITUDE: number;
  33078. /**
  33079. * Gets or sets the position of the debug canvas
  33080. * @ignorenaming
  33081. */
  33082. DEBUGCANVASPOS: {
  33083. x: number;
  33084. y: number;
  33085. };
  33086. /**
  33087. * Gets or sets the debug canvas size
  33088. * @ignorenaming
  33089. */
  33090. DEBUGCANVASSIZE: {
  33091. width: number;
  33092. height: number;
  33093. };
  33094. private _byteFreqs;
  33095. private _byteTime;
  33096. private _floatFreqs;
  33097. private _webAudioAnalyser;
  33098. private _debugCanvas;
  33099. private _debugCanvasContext;
  33100. private _scene;
  33101. private _registerFunc;
  33102. private _audioEngine;
  33103. /**
  33104. * Creates a new analyser
  33105. * @param scene defines hosting scene
  33106. */
  33107. constructor(scene: Scene);
  33108. /**
  33109. * Get the number of data values you will have to play with for the visualization
  33110. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33111. * @returns a number
  33112. */
  33113. getFrequencyBinCount(): number;
  33114. /**
  33115. * Gets the current frequency data as a byte array
  33116. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33117. * @returns a Uint8Array
  33118. */
  33119. getByteFrequencyData(): Uint8Array;
  33120. /**
  33121. * Gets the current waveform as a byte array
  33122. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33123. * @returns a Uint8Array
  33124. */
  33125. getByteTimeDomainData(): Uint8Array;
  33126. /**
  33127. * Gets the current frequency data as a float array
  33128. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33129. * @returns a Float32Array
  33130. */
  33131. getFloatFrequencyData(): Float32Array;
  33132. /**
  33133. * Renders the debug canvas
  33134. */
  33135. drawDebugCanvas(): void;
  33136. /**
  33137. * Stops rendering the debug canvas and removes it
  33138. */
  33139. stopDebugCanvas(): void;
  33140. /**
  33141. * Connects two audio nodes
  33142. * @param inputAudioNode defines first node to connect
  33143. * @param outputAudioNode defines second node to connect
  33144. */
  33145. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33146. /**
  33147. * Releases all associated resources
  33148. */
  33149. dispose(): void;
  33150. }
  33151. }
  33152. declare module BABYLON {
  33153. /**
  33154. * This represents an audio engine and it is responsible
  33155. * to play, synchronize and analyse sounds throughout the application.
  33156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33157. */
  33158. export interface IAudioEngine extends IDisposable {
  33159. /**
  33160. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33161. */
  33162. readonly canUseWebAudio: boolean;
  33163. /**
  33164. * Gets the current AudioContext if available.
  33165. */
  33166. readonly audioContext: Nullable<AudioContext>;
  33167. /**
  33168. * The master gain node defines the global audio volume of your audio engine.
  33169. */
  33170. readonly masterGain: GainNode;
  33171. /**
  33172. * Gets whether or not mp3 are supported by your browser.
  33173. */
  33174. readonly isMP3supported: boolean;
  33175. /**
  33176. * Gets whether or not ogg are supported by your browser.
  33177. */
  33178. readonly isOGGsupported: boolean;
  33179. /**
  33180. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33181. * @ignoreNaming
  33182. */
  33183. WarnedWebAudioUnsupported: boolean;
  33184. /**
  33185. * Defines if the audio engine relies on a custom unlocked button.
  33186. * In this case, the embedded button will not be displayed.
  33187. */
  33188. useCustomUnlockedButton: boolean;
  33189. /**
  33190. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33191. */
  33192. readonly unlocked: boolean;
  33193. /**
  33194. * Event raised when audio has been unlocked on the browser.
  33195. */
  33196. onAudioUnlockedObservable: Observable<AudioEngine>;
  33197. /**
  33198. * Event raised when audio has been locked on the browser.
  33199. */
  33200. onAudioLockedObservable: Observable<AudioEngine>;
  33201. /**
  33202. * Flags the audio engine in Locked state.
  33203. * This happens due to new browser policies preventing audio to autoplay.
  33204. */
  33205. lock(): void;
  33206. /**
  33207. * Unlocks the audio engine once a user action has been done on the dom.
  33208. * This is helpful to resume play once browser policies have been satisfied.
  33209. */
  33210. unlock(): void;
  33211. /**
  33212. * Gets the global volume sets on the master gain.
  33213. * @returns the global volume if set or -1 otherwise
  33214. */
  33215. getGlobalVolume(): number;
  33216. /**
  33217. * Sets the global volume of your experience (sets on the master gain).
  33218. * @param newVolume Defines the new global volume of the application
  33219. */
  33220. setGlobalVolume(newVolume: number): void;
  33221. /**
  33222. * Connect the audio engine to an audio analyser allowing some amazing
  33223. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33225. * @param analyser The analyser to connect to the engine
  33226. */
  33227. connectToAnalyser(analyser: Analyser): void;
  33228. }
  33229. /**
  33230. * This represents the default audio engine used in babylon.
  33231. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33233. */
  33234. export class AudioEngine implements IAudioEngine {
  33235. private _audioContext;
  33236. private _audioContextInitialized;
  33237. private _muteButton;
  33238. private _hostElement;
  33239. /**
  33240. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33241. */
  33242. canUseWebAudio: boolean;
  33243. /**
  33244. * The master gain node defines the global audio volume of your audio engine.
  33245. */
  33246. masterGain: GainNode;
  33247. /**
  33248. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33249. * @ignoreNaming
  33250. */
  33251. WarnedWebAudioUnsupported: boolean;
  33252. /**
  33253. * Gets whether or not mp3 are supported by your browser.
  33254. */
  33255. isMP3supported: boolean;
  33256. /**
  33257. * Gets whether or not ogg are supported by your browser.
  33258. */
  33259. isOGGsupported: boolean;
  33260. /**
  33261. * Gets whether audio has been unlocked on the device.
  33262. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33263. * a user interaction has happened.
  33264. */
  33265. unlocked: boolean;
  33266. /**
  33267. * Defines if the audio engine relies on a custom unlocked button.
  33268. * In this case, the embedded button will not be displayed.
  33269. */
  33270. useCustomUnlockedButton: boolean;
  33271. /**
  33272. * Event raised when audio has been unlocked on the browser.
  33273. */
  33274. onAudioUnlockedObservable: Observable<AudioEngine>;
  33275. /**
  33276. * Event raised when audio has been locked on the browser.
  33277. */
  33278. onAudioLockedObservable: Observable<AudioEngine>;
  33279. /**
  33280. * Gets the current AudioContext if available.
  33281. */
  33282. get audioContext(): Nullable<AudioContext>;
  33283. private _connectedAnalyser;
  33284. /**
  33285. * Instantiates a new audio engine.
  33286. *
  33287. * There should be only one per page as some browsers restrict the number
  33288. * of audio contexts you can create.
  33289. * @param hostElement defines the host element where to display the mute icon if necessary
  33290. */
  33291. constructor(hostElement?: Nullable<HTMLElement>);
  33292. /**
  33293. * Flags the audio engine in Locked state.
  33294. * This happens due to new browser policies preventing audio to autoplay.
  33295. */
  33296. lock(): void;
  33297. /**
  33298. * Unlocks the audio engine once a user action has been done on the dom.
  33299. * This is helpful to resume play once browser policies have been satisfied.
  33300. */
  33301. unlock(): void;
  33302. private _resumeAudioContext;
  33303. private _initializeAudioContext;
  33304. private _tryToRun;
  33305. private _triggerRunningState;
  33306. private _triggerSuspendedState;
  33307. private _displayMuteButton;
  33308. private _moveButtonToTopLeft;
  33309. private _onResize;
  33310. private _hideMuteButton;
  33311. /**
  33312. * Destroy and release the resources associated with the audio ccontext.
  33313. */
  33314. dispose(): void;
  33315. /**
  33316. * Gets the global volume sets on the master gain.
  33317. * @returns the global volume if set or -1 otherwise
  33318. */
  33319. getGlobalVolume(): number;
  33320. /**
  33321. * Sets the global volume of your experience (sets on the master gain).
  33322. * @param newVolume Defines the new global volume of the application
  33323. */
  33324. setGlobalVolume(newVolume: number): void;
  33325. /**
  33326. * Connect the audio engine to an audio analyser allowing some amazing
  33327. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33329. * @param analyser The analyser to connect to the engine
  33330. */
  33331. connectToAnalyser(analyser: Analyser): void;
  33332. }
  33333. }
  33334. declare module BABYLON {
  33335. /**
  33336. * Interface used to present a loading screen while loading a scene
  33337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33338. */
  33339. export interface ILoadingScreen {
  33340. /**
  33341. * Function called to display the loading screen
  33342. */
  33343. displayLoadingUI: () => void;
  33344. /**
  33345. * Function called to hide the loading screen
  33346. */
  33347. hideLoadingUI: () => void;
  33348. /**
  33349. * Gets or sets the color to use for the background
  33350. */
  33351. loadingUIBackgroundColor: string;
  33352. /**
  33353. * Gets or sets the text to display while loading
  33354. */
  33355. loadingUIText: string;
  33356. }
  33357. /**
  33358. * Class used for the default loading screen
  33359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33360. */
  33361. export class DefaultLoadingScreen implements ILoadingScreen {
  33362. private _renderingCanvas;
  33363. private _loadingText;
  33364. private _loadingDivBackgroundColor;
  33365. private _loadingDiv;
  33366. private _loadingTextDiv;
  33367. /** Gets or sets the logo url to use for the default loading screen */
  33368. static DefaultLogoUrl: string;
  33369. /** Gets or sets the spinner url to use for the default loading screen */
  33370. static DefaultSpinnerUrl: string;
  33371. /**
  33372. * Creates a new default loading screen
  33373. * @param _renderingCanvas defines the canvas used to render the scene
  33374. * @param _loadingText defines the default text to display
  33375. * @param _loadingDivBackgroundColor defines the default background color
  33376. */
  33377. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33378. /**
  33379. * Function called to display the loading screen
  33380. */
  33381. displayLoadingUI(): void;
  33382. /**
  33383. * Function called to hide the loading screen
  33384. */
  33385. hideLoadingUI(): void;
  33386. /**
  33387. * Gets or sets the text to display while loading
  33388. */
  33389. set loadingUIText(text: string);
  33390. get loadingUIText(): string;
  33391. /**
  33392. * Gets or sets the color to use for the background
  33393. */
  33394. get loadingUIBackgroundColor(): string;
  33395. set loadingUIBackgroundColor(color: string);
  33396. private _resizeLoadingUI;
  33397. }
  33398. }
  33399. declare module BABYLON {
  33400. /**
  33401. * Interface for any object that can request an animation frame
  33402. */
  33403. export interface ICustomAnimationFrameRequester {
  33404. /**
  33405. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33406. */
  33407. renderFunction?: Function;
  33408. /**
  33409. * Called to request the next frame to render to
  33410. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33411. */
  33412. requestAnimationFrame: Function;
  33413. /**
  33414. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33415. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33416. */
  33417. requestID?: number;
  33418. }
  33419. }
  33420. declare module BABYLON {
  33421. /**
  33422. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33423. */
  33424. export class PerformanceMonitor {
  33425. private _enabled;
  33426. private _rollingFrameTime;
  33427. private _lastFrameTimeMs;
  33428. /**
  33429. * constructor
  33430. * @param frameSampleSize The number of samples required to saturate the sliding window
  33431. */
  33432. constructor(frameSampleSize?: number);
  33433. /**
  33434. * Samples current frame
  33435. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33436. */
  33437. sampleFrame(timeMs?: number): void;
  33438. /**
  33439. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33440. */
  33441. get averageFrameTime(): number;
  33442. /**
  33443. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33444. */
  33445. get averageFrameTimeVariance(): number;
  33446. /**
  33447. * Returns the frame time of the most recent frame
  33448. */
  33449. get instantaneousFrameTime(): number;
  33450. /**
  33451. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33452. */
  33453. get averageFPS(): number;
  33454. /**
  33455. * Returns the average framerate in frames per second using the most recent frame time
  33456. */
  33457. get instantaneousFPS(): number;
  33458. /**
  33459. * Returns true if enough samples have been taken to completely fill the sliding window
  33460. */
  33461. get isSaturated(): boolean;
  33462. /**
  33463. * Enables contributions to the sliding window sample set
  33464. */
  33465. enable(): void;
  33466. /**
  33467. * Disables contributions to the sliding window sample set
  33468. * Samples will not be interpolated over the disabled period
  33469. */
  33470. disable(): void;
  33471. /**
  33472. * Returns true if sampling is enabled
  33473. */
  33474. get isEnabled(): boolean;
  33475. /**
  33476. * Resets performance monitor
  33477. */
  33478. reset(): void;
  33479. }
  33480. /**
  33481. * RollingAverage
  33482. *
  33483. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33484. */
  33485. export class RollingAverage {
  33486. /**
  33487. * Current average
  33488. */
  33489. average: number;
  33490. /**
  33491. * Current variance
  33492. */
  33493. variance: number;
  33494. protected _samples: Array<number>;
  33495. protected _sampleCount: number;
  33496. protected _pos: number;
  33497. protected _m2: number;
  33498. /**
  33499. * constructor
  33500. * @param length The number of samples required to saturate the sliding window
  33501. */
  33502. constructor(length: number);
  33503. /**
  33504. * Adds a sample to the sample set
  33505. * @param v The sample value
  33506. */
  33507. add(v: number): void;
  33508. /**
  33509. * Returns previously added values or null if outside of history or outside the sliding window domain
  33510. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33511. * @return Value previously recorded with add() or null if outside of range
  33512. */
  33513. history(i: number): number;
  33514. /**
  33515. * Returns true if enough samples have been taken to completely fill the sliding window
  33516. * @return true if sample-set saturated
  33517. */
  33518. isSaturated(): boolean;
  33519. /**
  33520. * Resets the rolling average (equivalent to 0 samples taken so far)
  33521. */
  33522. reset(): void;
  33523. /**
  33524. * Wraps a value around the sample range boundaries
  33525. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33526. * @return Wrapped position in sample range
  33527. */
  33528. protected _wrapPosition(i: number): number;
  33529. }
  33530. }
  33531. declare module BABYLON {
  33532. /**
  33533. * This class is used to track a performance counter which is number based.
  33534. * The user has access to many properties which give statistics of different nature.
  33535. *
  33536. * The implementer can track two kinds of Performance Counter: time and count.
  33537. * 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.
  33538. * 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.
  33539. */
  33540. export class PerfCounter {
  33541. /**
  33542. * Gets or sets a global boolean to turn on and off all the counters
  33543. */
  33544. static Enabled: boolean;
  33545. /**
  33546. * Returns the smallest value ever
  33547. */
  33548. get min(): number;
  33549. /**
  33550. * Returns the biggest value ever
  33551. */
  33552. get max(): number;
  33553. /**
  33554. * Returns the average value since the performance counter is running
  33555. */
  33556. get average(): number;
  33557. /**
  33558. * Returns the average value of the last second the counter was monitored
  33559. */
  33560. get lastSecAverage(): number;
  33561. /**
  33562. * Returns the current value
  33563. */
  33564. get current(): number;
  33565. /**
  33566. * Gets the accumulated total
  33567. */
  33568. get total(): number;
  33569. /**
  33570. * Gets the total value count
  33571. */
  33572. get count(): number;
  33573. /**
  33574. * Creates a new counter
  33575. */
  33576. constructor();
  33577. /**
  33578. * Call this method to start monitoring a new frame.
  33579. * 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.
  33580. */
  33581. fetchNewFrame(): void;
  33582. /**
  33583. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33584. * @param newCount the count value to add to the monitored count
  33585. * @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.
  33586. */
  33587. addCount(newCount: number, fetchResult: boolean): void;
  33588. /**
  33589. * Start monitoring this performance counter
  33590. */
  33591. beginMonitoring(): void;
  33592. /**
  33593. * Compute the time lapsed since the previous beginMonitoring() call.
  33594. * @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
  33595. */
  33596. endMonitoring(newFrame?: boolean): void;
  33597. private _fetchResult;
  33598. private _startMonitoringTime;
  33599. private _min;
  33600. private _max;
  33601. private _average;
  33602. private _current;
  33603. private _totalValueCount;
  33604. private _totalAccumulated;
  33605. private _lastSecAverage;
  33606. private _lastSecAccumulated;
  33607. private _lastSecTime;
  33608. private _lastSecValueCount;
  33609. }
  33610. }
  33611. declare module BABYLON {
  33612. interface ThinEngine {
  33613. /**
  33614. * Sets alpha constants used by some alpha blending modes
  33615. * @param r defines the red component
  33616. * @param g defines the green component
  33617. * @param b defines the blue component
  33618. * @param a defines the alpha component
  33619. */
  33620. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33621. /**
  33622. * Sets the current alpha mode
  33623. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33626. */
  33627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33628. /**
  33629. * Gets the current alpha mode
  33630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33631. * @returns the current alpha mode
  33632. */
  33633. getAlphaMode(): number;
  33634. /**
  33635. * Sets the current alpha equation
  33636. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33637. */
  33638. setAlphaEquation(equation: number): void;
  33639. /**
  33640. * Gets the current alpha equation.
  33641. * @returns the current alpha equation
  33642. */
  33643. getAlphaEquation(): number;
  33644. }
  33645. }
  33646. declare module BABYLON {
  33647. interface ThinEngine {
  33648. /** @hidden */
  33649. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33650. }
  33651. }
  33652. declare module BABYLON {
  33653. /**
  33654. * Defines the interface used by display changed events
  33655. */
  33656. export interface IDisplayChangedEventArgs {
  33657. /** Gets the vrDisplay object (if any) */
  33658. vrDisplay: Nullable<any>;
  33659. /** Gets a boolean indicating if webVR is supported */
  33660. vrSupported: boolean;
  33661. }
  33662. /**
  33663. * Defines the interface used by objects containing a viewport (like a camera)
  33664. */
  33665. interface IViewportOwnerLike {
  33666. /**
  33667. * Gets or sets the viewport
  33668. */
  33669. viewport: IViewportLike;
  33670. }
  33671. /**
  33672. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33673. */
  33674. export class Engine extends ThinEngine {
  33675. /** Defines that alpha blending is disabled */
  33676. static readonly ALPHA_DISABLE: number;
  33677. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33678. static readonly ALPHA_ADD: number;
  33679. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33680. static readonly ALPHA_COMBINE: number;
  33681. /** Defines that alpha blending to DEST - SRC * DEST */
  33682. static readonly ALPHA_SUBTRACT: number;
  33683. /** Defines that alpha blending to SRC * DEST */
  33684. static readonly ALPHA_MULTIPLY: number;
  33685. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33686. static readonly ALPHA_MAXIMIZED: number;
  33687. /** Defines that alpha blending to SRC + DEST */
  33688. static readonly ALPHA_ONEONE: number;
  33689. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33690. static readonly ALPHA_PREMULTIPLIED: number;
  33691. /**
  33692. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33693. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33694. */
  33695. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33696. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33697. static readonly ALPHA_INTERPOLATE: number;
  33698. /**
  33699. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33700. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33701. */
  33702. static readonly ALPHA_SCREENMODE: number;
  33703. /** Defines that the ressource is not delayed*/
  33704. static readonly DELAYLOADSTATE_NONE: number;
  33705. /** Defines that the ressource was successfully delay loaded */
  33706. static readonly DELAYLOADSTATE_LOADED: number;
  33707. /** Defines that the ressource is currently delay loading */
  33708. static readonly DELAYLOADSTATE_LOADING: number;
  33709. /** Defines that the ressource is delayed and has not started loading */
  33710. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33712. static readonly NEVER: number;
  33713. /** 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 */
  33714. static readonly ALWAYS: number;
  33715. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33716. static readonly LESS: number;
  33717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33718. static readonly EQUAL: number;
  33719. /** 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 */
  33720. static readonly LEQUAL: number;
  33721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33722. static readonly GREATER: number;
  33723. /** 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 */
  33724. static readonly GEQUAL: number;
  33725. /** 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 */
  33726. static readonly NOTEQUAL: number;
  33727. /** Passed to stencilOperation to specify that stencil value must be kept */
  33728. static readonly KEEP: number;
  33729. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33730. static readonly REPLACE: number;
  33731. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33732. static readonly INCR: number;
  33733. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33734. static readonly DECR: number;
  33735. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33736. static readonly INVERT: number;
  33737. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33738. static readonly INCR_WRAP: number;
  33739. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33740. static readonly DECR_WRAP: number;
  33741. /** Texture is not repeating outside of 0..1 UVs */
  33742. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33743. /** Texture is repeating outside of 0..1 UVs */
  33744. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33745. /** Texture is repeating and mirrored */
  33746. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33747. /** ALPHA */
  33748. static readonly TEXTUREFORMAT_ALPHA: number;
  33749. /** LUMINANCE */
  33750. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33751. /** LUMINANCE_ALPHA */
  33752. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33753. /** RGB */
  33754. static readonly TEXTUREFORMAT_RGB: number;
  33755. /** RGBA */
  33756. static readonly TEXTUREFORMAT_RGBA: number;
  33757. /** RED */
  33758. static readonly TEXTUREFORMAT_RED: number;
  33759. /** RED (2nd reference) */
  33760. static readonly TEXTUREFORMAT_R: number;
  33761. /** RG */
  33762. static readonly TEXTUREFORMAT_RG: number;
  33763. /** RED_INTEGER */
  33764. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33765. /** RED_INTEGER (2nd reference) */
  33766. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33767. /** RG_INTEGER */
  33768. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33769. /** RGB_INTEGER */
  33770. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33771. /** RGBA_INTEGER */
  33772. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33773. /** UNSIGNED_BYTE */
  33774. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33775. /** UNSIGNED_BYTE (2nd reference) */
  33776. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33777. /** FLOAT */
  33778. static readonly TEXTURETYPE_FLOAT: number;
  33779. /** HALF_FLOAT */
  33780. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33781. /** BYTE */
  33782. static readonly TEXTURETYPE_BYTE: number;
  33783. /** SHORT */
  33784. static readonly TEXTURETYPE_SHORT: number;
  33785. /** UNSIGNED_SHORT */
  33786. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33787. /** INT */
  33788. static readonly TEXTURETYPE_INT: number;
  33789. /** UNSIGNED_INT */
  33790. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33791. /** UNSIGNED_SHORT_4_4_4_4 */
  33792. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33793. /** UNSIGNED_SHORT_5_5_5_1 */
  33794. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33795. /** UNSIGNED_SHORT_5_6_5 */
  33796. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33797. /** UNSIGNED_INT_2_10_10_10_REV */
  33798. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33799. /** UNSIGNED_INT_24_8 */
  33800. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33801. /** UNSIGNED_INT_10F_11F_11F_REV */
  33802. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33803. /** UNSIGNED_INT_5_9_9_9_REV */
  33804. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33805. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33806. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33807. /** nearest is mag = nearest and min = nearest and mip = linear */
  33808. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33809. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33810. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33811. /** Trilinear is mag = linear and min = linear and mip = linear */
  33812. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33813. /** nearest is mag = nearest and min = nearest and mip = linear */
  33814. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33816. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33817. /** Trilinear is mag = linear and min = linear and mip = linear */
  33818. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33819. /** mag = nearest and min = nearest and mip = nearest */
  33820. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33821. /** mag = nearest and min = linear and mip = nearest */
  33822. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33823. /** mag = nearest and min = linear and mip = linear */
  33824. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33825. /** mag = nearest and min = linear and mip = none */
  33826. static readonly TEXTURE_NEAREST_LINEAR: number;
  33827. /** mag = nearest and min = nearest and mip = none */
  33828. static readonly TEXTURE_NEAREST_NEAREST: number;
  33829. /** mag = linear and min = nearest and mip = nearest */
  33830. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33831. /** mag = linear and min = nearest and mip = linear */
  33832. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33833. /** mag = linear and min = linear and mip = none */
  33834. static readonly TEXTURE_LINEAR_LINEAR: number;
  33835. /** mag = linear and min = nearest and mip = none */
  33836. static readonly TEXTURE_LINEAR_NEAREST: number;
  33837. /** Explicit coordinates mode */
  33838. static readonly TEXTURE_EXPLICIT_MODE: number;
  33839. /** Spherical coordinates mode */
  33840. static readonly TEXTURE_SPHERICAL_MODE: number;
  33841. /** Planar coordinates mode */
  33842. static readonly TEXTURE_PLANAR_MODE: number;
  33843. /** Cubic coordinates mode */
  33844. static readonly TEXTURE_CUBIC_MODE: number;
  33845. /** Projection coordinates mode */
  33846. static readonly TEXTURE_PROJECTION_MODE: number;
  33847. /** Skybox coordinates mode */
  33848. static readonly TEXTURE_SKYBOX_MODE: number;
  33849. /** Inverse Cubic coordinates mode */
  33850. static readonly TEXTURE_INVCUBIC_MODE: number;
  33851. /** Equirectangular coordinates mode */
  33852. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33853. /** Equirectangular Fixed coordinates mode */
  33854. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33855. /** Equirectangular Fixed Mirrored coordinates mode */
  33856. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33857. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33858. static readonly SCALEMODE_FLOOR: number;
  33859. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33860. static readonly SCALEMODE_NEAREST: number;
  33861. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33862. static readonly SCALEMODE_CEILING: number;
  33863. /**
  33864. * Returns the current npm package of the sdk
  33865. */
  33866. static get NpmPackage(): string;
  33867. /**
  33868. * Returns the current version of the framework
  33869. */
  33870. static get Version(): string;
  33871. /** Gets the list of created engines */
  33872. static get Instances(): Engine[];
  33873. /**
  33874. * Gets the latest created engine
  33875. */
  33876. static get LastCreatedEngine(): Nullable<Engine>;
  33877. /**
  33878. * Gets the latest created scene
  33879. */
  33880. static get LastCreatedScene(): Nullable<Scene>;
  33881. /**
  33882. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33883. * @param flag defines which part of the materials must be marked as dirty
  33884. * @param predicate defines a predicate used to filter which materials should be affected
  33885. */
  33886. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33887. /**
  33888. * Method called to create the default loading screen.
  33889. * This can be overriden in your own app.
  33890. * @param canvas The rendering canvas element
  33891. * @returns The loading screen
  33892. */
  33893. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33894. /**
  33895. * Method called to create the default rescale post process on each engine.
  33896. */
  33897. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33898. /**
  33899. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33900. **/
  33901. enableOfflineSupport: boolean;
  33902. /**
  33903. * 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)
  33904. **/
  33905. disableManifestCheck: boolean;
  33906. /**
  33907. * Gets the list of created scenes
  33908. */
  33909. scenes: Scene[];
  33910. /**
  33911. * Event raised when a new scene is created
  33912. */
  33913. onNewSceneAddedObservable: Observable<Scene>;
  33914. /**
  33915. * Gets the list of created postprocesses
  33916. */
  33917. postProcesses: PostProcess[];
  33918. /**
  33919. * Gets a boolean indicating if the pointer is currently locked
  33920. */
  33921. isPointerLock: boolean;
  33922. /**
  33923. * Observable event triggered each time the rendering canvas is resized
  33924. */
  33925. onResizeObservable: Observable<Engine>;
  33926. /**
  33927. * Observable event triggered each time the canvas loses focus
  33928. */
  33929. onCanvasBlurObservable: Observable<Engine>;
  33930. /**
  33931. * Observable event triggered each time the canvas gains focus
  33932. */
  33933. onCanvasFocusObservable: Observable<Engine>;
  33934. /**
  33935. * Observable event triggered each time the canvas receives pointerout event
  33936. */
  33937. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33938. /**
  33939. * Observable raised when the engine begins a new frame
  33940. */
  33941. onBeginFrameObservable: Observable<Engine>;
  33942. /**
  33943. * If set, will be used to request the next animation frame for the render loop
  33944. */
  33945. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33946. /**
  33947. * Observable raised when the engine ends the current frame
  33948. */
  33949. onEndFrameObservable: Observable<Engine>;
  33950. /**
  33951. * Observable raised when the engine is about to compile a shader
  33952. */
  33953. onBeforeShaderCompilationObservable: Observable<Engine>;
  33954. /**
  33955. * Observable raised when the engine has jsut compiled a shader
  33956. */
  33957. onAfterShaderCompilationObservable: Observable<Engine>;
  33958. /**
  33959. * Gets the audio engine
  33960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33961. * @ignorenaming
  33962. */
  33963. static audioEngine: IAudioEngine;
  33964. /**
  33965. * Default AudioEngine factory responsible of creating the Audio Engine.
  33966. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33967. */
  33968. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33969. /**
  33970. * Default offline support factory responsible of creating a tool used to store data locally.
  33971. * By default, this will create a Database object if the workload has been embedded.
  33972. */
  33973. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33974. private _loadingScreen;
  33975. private _pointerLockRequested;
  33976. private _rescalePostProcess;
  33977. private _deterministicLockstep;
  33978. private _lockstepMaxSteps;
  33979. private _timeStep;
  33980. protected get _supportsHardwareTextureRescaling(): boolean;
  33981. private _fps;
  33982. private _deltaTime;
  33983. /** @hidden */
  33984. _drawCalls: PerfCounter;
  33985. /** 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 */
  33986. canvasTabIndex: number;
  33987. /**
  33988. * Turn this value on if you want to pause FPS computation when in background
  33989. */
  33990. disablePerformanceMonitorInBackground: boolean;
  33991. private _performanceMonitor;
  33992. /**
  33993. * Gets the performance monitor attached to this engine
  33994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33995. */
  33996. get performanceMonitor(): PerformanceMonitor;
  33997. private _onFocus;
  33998. private _onBlur;
  33999. private _onCanvasPointerOut;
  34000. private _onCanvasBlur;
  34001. private _onCanvasFocus;
  34002. private _onFullscreenChange;
  34003. private _onPointerLockChange;
  34004. /**
  34005. * Gets the HTML element used to attach event listeners
  34006. * @returns a HTML element
  34007. */
  34008. getInputElement(): Nullable<HTMLElement>;
  34009. /**
  34010. * Creates a new engine
  34011. * @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
  34012. * @param antialias defines enable antialiasing (default: false)
  34013. * @param options defines further options to be sent to the getContext() function
  34014. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34015. */
  34016. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34017. /**
  34018. * Gets current aspect ratio
  34019. * @param viewportOwner defines the camera to use to get the aspect ratio
  34020. * @param useScreen defines if screen size must be used (or the current render target if any)
  34021. * @returns a number defining the aspect ratio
  34022. */
  34023. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34024. /**
  34025. * Gets current screen aspect ratio
  34026. * @returns a number defining the aspect ratio
  34027. */
  34028. getScreenAspectRatio(): number;
  34029. /**
  34030. * Gets the client rect of the HTML canvas attached with the current webGL context
  34031. * @returns a client rectanglee
  34032. */
  34033. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34034. /**
  34035. * Gets the client rect of the HTML element used for events
  34036. * @returns a client rectanglee
  34037. */
  34038. getInputElementClientRect(): Nullable<ClientRect>;
  34039. /**
  34040. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34042. * @returns true if engine is in deterministic lock step mode
  34043. */
  34044. isDeterministicLockStep(): boolean;
  34045. /**
  34046. * Gets the max steps when engine is running in deterministic lock step
  34047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34048. * @returns the max steps
  34049. */
  34050. getLockstepMaxSteps(): number;
  34051. /**
  34052. * Returns the time in ms between steps when using deterministic lock step.
  34053. * @returns time step in (ms)
  34054. */
  34055. getTimeStep(): number;
  34056. /**
  34057. * Force the mipmap generation for the given render target texture
  34058. * @param texture defines the render target texture to use
  34059. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34060. */
  34061. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34062. /** States */
  34063. /**
  34064. * Set various states to the webGL context
  34065. * @param culling defines backface culling state
  34066. * @param zOffset defines the value to apply to zOffset (0 by default)
  34067. * @param force defines if states must be applied even if cache is up to date
  34068. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34069. */
  34070. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34071. /**
  34072. * Set the z offset to apply to current rendering
  34073. * @param value defines the offset to apply
  34074. */
  34075. setZOffset(value: number): void;
  34076. /**
  34077. * Gets the current value of the zOffset
  34078. * @returns the current zOffset state
  34079. */
  34080. getZOffset(): number;
  34081. /**
  34082. * Enable or disable depth buffering
  34083. * @param enable defines the state to set
  34084. */
  34085. setDepthBuffer(enable: boolean): void;
  34086. /**
  34087. * Gets a boolean indicating if depth writing is enabled
  34088. * @returns the current depth writing state
  34089. */
  34090. getDepthWrite(): boolean;
  34091. /**
  34092. * Enable or disable depth writing
  34093. * @param enable defines the state to set
  34094. */
  34095. setDepthWrite(enable: boolean): void;
  34096. /**
  34097. * Gets a boolean indicating if stencil buffer is enabled
  34098. * @returns the current stencil buffer state
  34099. */
  34100. getStencilBuffer(): boolean;
  34101. /**
  34102. * Enable or disable the stencil buffer
  34103. * @param enable defines if the stencil buffer must be enabled or disabled
  34104. */
  34105. setStencilBuffer(enable: boolean): void;
  34106. /**
  34107. * Gets the current stencil mask
  34108. * @returns a number defining the new stencil mask to use
  34109. */
  34110. getStencilMask(): number;
  34111. /**
  34112. * Sets the current stencil mask
  34113. * @param mask defines the new stencil mask to use
  34114. */
  34115. setStencilMask(mask: number): void;
  34116. /**
  34117. * Gets the current stencil function
  34118. * @returns a number defining the stencil function to use
  34119. */
  34120. getStencilFunction(): number;
  34121. /**
  34122. * Gets the current stencil reference value
  34123. * @returns a number defining the stencil reference value to use
  34124. */
  34125. getStencilFunctionReference(): number;
  34126. /**
  34127. * Gets the current stencil mask
  34128. * @returns a number defining the stencil mask to use
  34129. */
  34130. getStencilFunctionMask(): number;
  34131. /**
  34132. * Sets the current stencil function
  34133. * @param stencilFunc defines the new stencil function to use
  34134. */
  34135. setStencilFunction(stencilFunc: number): void;
  34136. /**
  34137. * Sets the current stencil reference
  34138. * @param reference defines the new stencil reference to use
  34139. */
  34140. setStencilFunctionReference(reference: number): void;
  34141. /**
  34142. * Sets the current stencil mask
  34143. * @param mask defines the new stencil mask to use
  34144. */
  34145. setStencilFunctionMask(mask: number): void;
  34146. /**
  34147. * Gets the current stencil operation when stencil fails
  34148. * @returns a number defining stencil operation to use when stencil fails
  34149. */
  34150. getStencilOperationFail(): number;
  34151. /**
  34152. * Gets the current stencil operation when depth fails
  34153. * @returns a number defining stencil operation to use when depth fails
  34154. */
  34155. getStencilOperationDepthFail(): number;
  34156. /**
  34157. * Gets the current stencil operation when stencil passes
  34158. * @returns a number defining stencil operation to use when stencil passes
  34159. */
  34160. getStencilOperationPass(): number;
  34161. /**
  34162. * Sets the stencil operation to use when stencil fails
  34163. * @param operation defines the stencil operation to use when stencil fails
  34164. */
  34165. setStencilOperationFail(operation: number): void;
  34166. /**
  34167. * Sets the stencil operation to use when depth fails
  34168. * @param operation defines the stencil operation to use when depth fails
  34169. */
  34170. setStencilOperationDepthFail(operation: number): void;
  34171. /**
  34172. * Sets the stencil operation to use when stencil passes
  34173. * @param operation defines the stencil operation to use when stencil passes
  34174. */
  34175. setStencilOperationPass(operation: number): void;
  34176. /**
  34177. * Sets a boolean indicating if the dithering state is enabled or disabled
  34178. * @param value defines the dithering state
  34179. */
  34180. setDitheringState(value: boolean): void;
  34181. /**
  34182. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34183. * @param value defines the rasterizer state
  34184. */
  34185. setRasterizerState(value: boolean): void;
  34186. /**
  34187. * Gets the current depth function
  34188. * @returns a number defining the depth function
  34189. */
  34190. getDepthFunction(): Nullable<number>;
  34191. /**
  34192. * Sets the current depth function
  34193. * @param depthFunc defines the function to use
  34194. */
  34195. setDepthFunction(depthFunc: number): void;
  34196. /**
  34197. * Sets the current depth function to GREATER
  34198. */
  34199. setDepthFunctionToGreater(): void;
  34200. /**
  34201. * Sets the current depth function to GEQUAL
  34202. */
  34203. setDepthFunctionToGreaterOrEqual(): void;
  34204. /**
  34205. * Sets the current depth function to LESS
  34206. */
  34207. setDepthFunctionToLess(): void;
  34208. /**
  34209. * Sets the current depth function to LEQUAL
  34210. */
  34211. setDepthFunctionToLessOrEqual(): void;
  34212. private _cachedStencilBuffer;
  34213. private _cachedStencilFunction;
  34214. private _cachedStencilMask;
  34215. private _cachedStencilOperationPass;
  34216. private _cachedStencilOperationFail;
  34217. private _cachedStencilOperationDepthFail;
  34218. private _cachedStencilReference;
  34219. /**
  34220. * Caches the the state of the stencil buffer
  34221. */
  34222. cacheStencilState(): void;
  34223. /**
  34224. * Restores the state of the stencil buffer
  34225. */
  34226. restoreStencilState(): void;
  34227. /**
  34228. * Directly set the WebGL Viewport
  34229. * @param x defines the x coordinate of the viewport (in screen space)
  34230. * @param y defines the y coordinate of the viewport (in screen space)
  34231. * @param width defines the width of the viewport (in screen space)
  34232. * @param height defines the height of the viewport (in screen space)
  34233. * @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
  34234. */
  34235. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34236. /**
  34237. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34238. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34239. * @param y defines the y-coordinate of the corner of the clear rectangle
  34240. * @param width defines the width of the clear rectangle
  34241. * @param height defines the height of the clear rectangle
  34242. * @param clearColor defines the clear color
  34243. */
  34244. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34245. /**
  34246. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34247. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34248. * @param y defines the y-coordinate of the corner of the clear rectangle
  34249. * @param width defines the width of the clear rectangle
  34250. * @param height defines the height of the clear rectangle
  34251. */
  34252. enableScissor(x: number, y: number, width: number, height: number): void;
  34253. /**
  34254. * Disable previously set scissor test rectangle
  34255. */
  34256. disableScissor(): void;
  34257. protected _reportDrawCall(): void;
  34258. /**
  34259. * Initializes a webVR display and starts listening to display change events
  34260. * The onVRDisplayChangedObservable will be notified upon these changes
  34261. * @returns The onVRDisplayChangedObservable
  34262. */
  34263. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34264. /** @hidden */
  34265. _prepareVRComponent(): void;
  34266. /** @hidden */
  34267. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34268. /** @hidden */
  34269. _submitVRFrame(): void;
  34270. /**
  34271. * Call this function to leave webVR mode
  34272. * Will do nothing if webVR is not supported or if there is no webVR device
  34273. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34274. */
  34275. disableVR(): void;
  34276. /**
  34277. * Gets a boolean indicating that the system is in VR mode and is presenting
  34278. * @returns true if VR mode is engaged
  34279. */
  34280. isVRPresenting(): boolean;
  34281. /** @hidden */
  34282. _requestVRFrame(): void;
  34283. /** @hidden */
  34284. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34285. /**
  34286. * Gets the source code of the vertex shader associated with a specific webGL program
  34287. * @param program defines the program to use
  34288. * @returns a string containing the source code of the vertex shader associated with the program
  34289. */
  34290. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34291. /**
  34292. * Gets the source code of the fragment shader associated with a specific webGL program
  34293. * @param program defines the program to use
  34294. * @returns a string containing the source code of the fragment shader associated with the program
  34295. */
  34296. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34297. /**
  34298. * Sets a depth stencil texture from a render target to the according uniform.
  34299. * @param channel The texture channel
  34300. * @param uniform The uniform to set
  34301. * @param texture The render target texture containing the depth stencil texture to apply
  34302. */
  34303. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34304. /**
  34305. * Sets a texture to the webGL context from a postprocess
  34306. * @param channel defines the channel to use
  34307. * @param postProcess defines the source postprocess
  34308. */
  34309. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34310. /**
  34311. * Binds the output of the passed in post process to the texture channel specified
  34312. * @param channel The channel the texture should be bound to
  34313. * @param postProcess The post process which's output should be bound
  34314. */
  34315. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34316. protected _rebuildBuffers(): void;
  34317. /** @hidden */
  34318. _renderFrame(): void;
  34319. _renderLoop(): void;
  34320. /** @hidden */
  34321. _renderViews(): boolean;
  34322. /**
  34323. * Toggle full screen mode
  34324. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34325. */
  34326. switchFullscreen(requestPointerLock: boolean): void;
  34327. /**
  34328. * Enters full screen mode
  34329. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34330. */
  34331. enterFullscreen(requestPointerLock: boolean): void;
  34332. /**
  34333. * Exits full screen mode
  34334. */
  34335. exitFullscreen(): void;
  34336. /**
  34337. * Enters Pointerlock mode
  34338. */
  34339. enterPointerlock(): void;
  34340. /**
  34341. * Exits Pointerlock mode
  34342. */
  34343. exitPointerlock(): void;
  34344. /**
  34345. * Begin a new frame
  34346. */
  34347. beginFrame(): void;
  34348. /**
  34349. * Enf the current frame
  34350. */
  34351. endFrame(): void;
  34352. resize(): void;
  34353. /**
  34354. * Force a specific size of the canvas
  34355. * @param width defines the new canvas' width
  34356. * @param height defines the new canvas' height
  34357. */
  34358. setSize(width: number, height: number): void;
  34359. /**
  34360. * Updates a dynamic vertex buffer.
  34361. * @param vertexBuffer the vertex buffer to update
  34362. * @param data the data used to update the vertex buffer
  34363. * @param byteOffset the byte offset of the data
  34364. * @param byteLength the byte length of the data
  34365. */
  34366. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34367. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34369. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34370. _releaseTexture(texture: InternalTexture): void;
  34371. /**
  34372. * @hidden
  34373. * Rescales a texture
  34374. * @param source input texutre
  34375. * @param destination destination texture
  34376. * @param scene scene to use to render the resize
  34377. * @param internalFormat format to use when resizing
  34378. * @param onComplete callback to be called when resize has completed
  34379. */
  34380. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34381. /**
  34382. * Gets the current framerate
  34383. * @returns a number representing the framerate
  34384. */
  34385. getFps(): number;
  34386. /**
  34387. * Gets the time spent between current and previous frame
  34388. * @returns a number representing the delta time in ms
  34389. */
  34390. getDeltaTime(): number;
  34391. private _measureFps;
  34392. /** @hidden */
  34393. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34394. /**
  34395. * Update a dynamic index buffer
  34396. * @param indexBuffer defines the target index buffer
  34397. * @param indices defines the data to update
  34398. * @param offset defines the offset in the target index buffer where update should start
  34399. */
  34400. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34401. /**
  34402. * Updates the sample count of a render target texture
  34403. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34404. * @param texture defines the texture to update
  34405. * @param samples defines the sample count to set
  34406. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34407. */
  34408. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34409. /**
  34410. * Updates a depth texture Comparison Mode and Function.
  34411. * If the comparison Function is equal to 0, the mode will be set to none.
  34412. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34413. * @param texture The texture to set the comparison function for
  34414. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34415. */
  34416. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34417. /**
  34418. * Creates a webGL buffer to use with instanciation
  34419. * @param capacity defines the size of the buffer
  34420. * @returns the webGL buffer
  34421. */
  34422. createInstancesBuffer(capacity: number): DataBuffer;
  34423. /**
  34424. * Delete a webGL buffer used with instanciation
  34425. * @param buffer defines the webGL buffer to delete
  34426. */
  34427. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34428. private _clientWaitAsync;
  34429. /** @hidden */
  34430. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34431. dispose(): void;
  34432. private _disableTouchAction;
  34433. /**
  34434. * Display the loading screen
  34435. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34436. */
  34437. displayLoadingUI(): void;
  34438. /**
  34439. * Hide the loading screen
  34440. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34441. */
  34442. hideLoadingUI(): void;
  34443. /**
  34444. * Gets the current loading screen object
  34445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34446. */
  34447. get loadingScreen(): ILoadingScreen;
  34448. /**
  34449. * Sets the current loading screen object
  34450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34451. */
  34452. set loadingScreen(loadingScreen: ILoadingScreen);
  34453. /**
  34454. * Sets the current loading screen text
  34455. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34456. */
  34457. set loadingUIText(text: string);
  34458. /**
  34459. * Sets the current loading screen background color
  34460. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34461. */
  34462. set loadingUIBackgroundColor(color: string);
  34463. /** Pointerlock and fullscreen */
  34464. /**
  34465. * Ask the browser to promote the current element to pointerlock mode
  34466. * @param element defines the DOM element to promote
  34467. */
  34468. static _RequestPointerlock(element: HTMLElement): void;
  34469. /**
  34470. * Asks the browser to exit pointerlock mode
  34471. */
  34472. static _ExitPointerlock(): void;
  34473. /**
  34474. * Ask the browser to promote the current element to fullscreen rendering mode
  34475. * @param element defines the DOM element to promote
  34476. */
  34477. static _RequestFullscreen(element: HTMLElement): void;
  34478. /**
  34479. * Asks the browser to exit fullscreen mode
  34480. */
  34481. static _ExitFullscreen(): void;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. /**
  34486. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34487. * during the life time of the application.
  34488. */
  34489. export class EngineStore {
  34490. /** Gets the list of created engines */
  34491. static Instances: Engine[];
  34492. /** @hidden */
  34493. static _LastCreatedScene: Nullable<Scene>;
  34494. /**
  34495. * Gets the latest created engine
  34496. */
  34497. static get LastCreatedEngine(): Nullable<Engine>;
  34498. /**
  34499. * Gets the latest created scene
  34500. */
  34501. static get LastCreatedScene(): Nullable<Scene>;
  34502. /**
  34503. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34504. * @ignorenaming
  34505. */
  34506. static UseFallbackTexture: boolean;
  34507. /**
  34508. * Texture content used if a texture cannot loaded
  34509. * @ignorenaming
  34510. */
  34511. static FallbackTexture: string;
  34512. }
  34513. }
  34514. declare module BABYLON {
  34515. /**
  34516. * Helper class that provides a small promise polyfill
  34517. */
  34518. export class PromisePolyfill {
  34519. /**
  34520. * Static function used to check if the polyfill is required
  34521. * If this is the case then the function will inject the polyfill to window.Promise
  34522. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34523. */
  34524. static Apply(force?: boolean): void;
  34525. }
  34526. }
  34527. declare module BABYLON {
  34528. /**
  34529. * Interface for screenshot methods with describe argument called `size` as object with options
  34530. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34531. */
  34532. export interface IScreenshotSize {
  34533. /**
  34534. * number in pixels for canvas height
  34535. */
  34536. height?: number;
  34537. /**
  34538. * multiplier allowing render at a higher or lower resolution
  34539. * If value is defined then height and width will be ignored and taken from camera
  34540. */
  34541. precision?: number;
  34542. /**
  34543. * number in pixels for canvas width
  34544. */
  34545. width?: number;
  34546. }
  34547. }
  34548. declare module BABYLON {
  34549. interface IColor4Like {
  34550. r: float;
  34551. g: float;
  34552. b: float;
  34553. a: float;
  34554. }
  34555. /**
  34556. * Class containing a set of static utilities functions
  34557. */
  34558. export class Tools {
  34559. /**
  34560. * Gets or sets the base URL to use to load assets
  34561. */
  34562. static get BaseUrl(): string;
  34563. static set BaseUrl(value: string);
  34564. /**
  34565. * Enable/Disable Custom HTTP Request Headers globally.
  34566. * default = false
  34567. * @see CustomRequestHeaders
  34568. */
  34569. static UseCustomRequestHeaders: boolean;
  34570. /**
  34571. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34572. * i.e. when loading files, where the server/service expects an Authorization header
  34573. */
  34574. static CustomRequestHeaders: {
  34575. [key: string]: string;
  34576. };
  34577. /**
  34578. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34579. */
  34580. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34581. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34582. /**
  34583. * Default behaviour for cors in the application.
  34584. * It can be a string if the expected behavior is identical in the entire app.
  34585. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34586. */
  34587. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34588. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34589. /**
  34590. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34591. * @ignorenaming
  34592. */
  34593. static get UseFallbackTexture(): boolean;
  34594. static set UseFallbackTexture(value: boolean);
  34595. /**
  34596. * Use this object to register external classes like custom textures or material
  34597. * to allow the laoders to instantiate them
  34598. */
  34599. static get RegisteredExternalClasses(): {
  34600. [key: string]: Object;
  34601. };
  34602. static set RegisteredExternalClasses(classes: {
  34603. [key: string]: Object;
  34604. });
  34605. /**
  34606. * Texture content used if a texture cannot loaded
  34607. * @ignorenaming
  34608. */
  34609. static get fallbackTexture(): string;
  34610. static set fallbackTexture(value: string);
  34611. /**
  34612. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34613. * @param u defines the coordinate on X axis
  34614. * @param v defines the coordinate on Y axis
  34615. * @param width defines the width of the source data
  34616. * @param height defines the height of the source data
  34617. * @param pixels defines the source byte array
  34618. * @param color defines the output color
  34619. */
  34620. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34621. /**
  34622. * Interpolates between a and b via alpha
  34623. * @param a The lower value (returned when alpha = 0)
  34624. * @param b The upper value (returned when alpha = 1)
  34625. * @param alpha The interpolation-factor
  34626. * @return The mixed value
  34627. */
  34628. static Mix(a: number, b: number, alpha: number): number;
  34629. /**
  34630. * Tries to instantiate a new object from a given class name
  34631. * @param className defines the class name to instantiate
  34632. * @returns the new object or null if the system was not able to do the instantiation
  34633. */
  34634. static Instantiate(className: string): any;
  34635. /**
  34636. * Provides a slice function that will work even on IE
  34637. * @param data defines the array to slice
  34638. * @param start defines the start of the data (optional)
  34639. * @param end defines the end of the data (optional)
  34640. * @returns the new sliced array
  34641. */
  34642. static Slice<T>(data: T, start?: number, end?: number): T;
  34643. /**
  34644. * Polyfill for setImmediate
  34645. * @param action defines the action to execute after the current execution block
  34646. */
  34647. static SetImmediate(action: () => void): void;
  34648. /**
  34649. * Function indicating if a number is an exponent of 2
  34650. * @param value defines the value to test
  34651. * @returns true if the value is an exponent of 2
  34652. */
  34653. static IsExponentOfTwo(value: number): boolean;
  34654. private static _tmpFloatArray;
  34655. /**
  34656. * Returns the nearest 32-bit single precision float representation of a Number
  34657. * @param value A Number. If the parameter is of a different type, it will get converted
  34658. * to a number or to NaN if it cannot be converted
  34659. * @returns number
  34660. */
  34661. static FloatRound(value: number): number;
  34662. /**
  34663. * Extracts the filename from a path
  34664. * @param path defines the path to use
  34665. * @returns the filename
  34666. */
  34667. static GetFilename(path: string): string;
  34668. /**
  34669. * Extracts the "folder" part of a path (everything before the filename).
  34670. * @param uri The URI to extract the info from
  34671. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34672. * @returns The "folder" part of the path
  34673. */
  34674. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34675. /**
  34676. * Extracts text content from a DOM element hierarchy
  34677. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34678. */
  34679. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34680. /**
  34681. * Convert an angle in radians to degrees
  34682. * @param angle defines the angle to convert
  34683. * @returns the angle in degrees
  34684. */
  34685. static ToDegrees(angle: number): number;
  34686. /**
  34687. * Convert an angle in degrees to radians
  34688. * @param angle defines the angle to convert
  34689. * @returns the angle in radians
  34690. */
  34691. static ToRadians(angle: number): number;
  34692. /**
  34693. * Returns an array if obj is not an array
  34694. * @param obj defines the object to evaluate as an array
  34695. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34696. * @returns either obj directly if obj is an array or a new array containing obj
  34697. */
  34698. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34699. /**
  34700. * Gets the pointer prefix to use
  34701. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34702. */
  34703. static GetPointerPrefix(): string;
  34704. /**
  34705. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34706. * @param url define the url we are trying
  34707. * @param element define the dom element where to configure the cors policy
  34708. */
  34709. static SetCorsBehavior(url: string | string[], element: {
  34710. crossOrigin: string | null;
  34711. }): void;
  34712. /**
  34713. * Removes unwanted characters from an url
  34714. * @param url defines the url to clean
  34715. * @returns the cleaned url
  34716. */
  34717. static CleanUrl(url: string): string;
  34718. /**
  34719. * Gets or sets a function used to pre-process url before using them to load assets
  34720. */
  34721. static get PreprocessUrl(): (url: string) => string;
  34722. static set PreprocessUrl(processor: (url: string) => string);
  34723. /**
  34724. * Loads an image as an HTMLImageElement.
  34725. * @param input url string, ArrayBuffer, or Blob to load
  34726. * @param onLoad callback called when the image successfully loads
  34727. * @param onError callback called when the image fails to load
  34728. * @param offlineProvider offline provider for caching
  34729. * @param mimeType optional mime type
  34730. * @returns the HTMLImageElement of the loaded image
  34731. */
  34732. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34733. /**
  34734. * Loads a file from a url
  34735. * @param url url string, ArrayBuffer, or Blob to load
  34736. * @param onSuccess callback called when the file successfully loads
  34737. * @param onProgress callback called while file is loading (if the server supports this mode)
  34738. * @param offlineProvider defines the offline provider for caching
  34739. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34740. * @param onError callback called when the file fails to load
  34741. * @returns a file request object
  34742. */
  34743. 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;
  34744. /**
  34745. * Loads a file from a url
  34746. * @param url the file url to load
  34747. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34748. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34749. */
  34750. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34751. /**
  34752. * Load a script (identified by an url). When the url returns, the
  34753. * content of this file is added into a new script element, attached to the DOM (body element)
  34754. * @param scriptUrl defines the url of the script to laod
  34755. * @param onSuccess defines the callback called when the script is loaded
  34756. * @param onError defines the callback to call if an error occurs
  34757. * @param scriptId defines the id of the script element
  34758. */
  34759. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34760. /**
  34761. * Load an asynchronous script (identified by an url). When the url returns, the
  34762. * content of this file is added into a new script element, attached to the DOM (body element)
  34763. * @param scriptUrl defines the url of the script to laod
  34764. * @param scriptId defines the id of the script element
  34765. * @returns a promise request object
  34766. */
  34767. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34768. /**
  34769. * Loads a file from a blob
  34770. * @param fileToLoad defines the blob to use
  34771. * @param callback defines the callback to call when data is loaded
  34772. * @param progressCallback defines the callback to call during loading process
  34773. * @returns a file request object
  34774. */
  34775. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34776. /**
  34777. * Reads a file from a File object
  34778. * @param file defines the file to load
  34779. * @param onSuccess defines the callback to call when data is loaded
  34780. * @param onProgress defines the callback to call during loading process
  34781. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34782. * @param onError defines the callback to call when an error occurs
  34783. * @returns a file request object
  34784. */
  34785. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34786. /**
  34787. * Creates a data url from a given string content
  34788. * @param content defines the content to convert
  34789. * @returns the new data url link
  34790. */
  34791. static FileAsURL(content: string): string;
  34792. /**
  34793. * Format the given number to a specific decimal format
  34794. * @param value defines the number to format
  34795. * @param decimals defines the number of decimals to use
  34796. * @returns the formatted string
  34797. */
  34798. static Format(value: number, decimals?: number): string;
  34799. /**
  34800. * Tries to copy an object by duplicating every property
  34801. * @param source defines the source object
  34802. * @param destination defines the target object
  34803. * @param doNotCopyList defines a list of properties to avoid
  34804. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34805. */
  34806. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34807. /**
  34808. * Gets a boolean indicating if the given object has no own property
  34809. * @param obj defines the object to test
  34810. * @returns true if object has no own property
  34811. */
  34812. static IsEmpty(obj: any): boolean;
  34813. /**
  34814. * Function used to register events at window level
  34815. * @param windowElement defines the Window object to use
  34816. * @param events defines the events to register
  34817. */
  34818. static RegisterTopRootEvents(windowElement: Window, events: {
  34819. name: string;
  34820. handler: Nullable<(e: FocusEvent) => any>;
  34821. }[]): void;
  34822. /**
  34823. * Function used to unregister events from window level
  34824. * @param windowElement defines the Window object to use
  34825. * @param events defines the events to unregister
  34826. */
  34827. static UnregisterTopRootEvents(windowElement: Window, events: {
  34828. name: string;
  34829. handler: Nullable<(e: FocusEvent) => any>;
  34830. }[]): void;
  34831. /**
  34832. * @ignore
  34833. */
  34834. static _ScreenshotCanvas: HTMLCanvasElement;
  34835. /**
  34836. * Dumps the current bound framebuffer
  34837. * @param width defines the rendering width
  34838. * @param height defines the rendering height
  34839. * @param engine defines the hosting engine
  34840. * @param successCallback defines the callback triggered once the data are available
  34841. * @param mimeType defines the mime type of the result
  34842. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34843. */
  34844. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34845. /**
  34846. * Converts the canvas data to blob.
  34847. * This acts as a polyfill for browsers not supporting the to blob function.
  34848. * @param canvas Defines the canvas to extract the data from
  34849. * @param successCallback Defines the callback triggered once the data are available
  34850. * @param mimeType Defines the mime type of the result
  34851. */
  34852. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34853. /**
  34854. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34855. * @param successCallback defines the callback triggered once the data are available
  34856. * @param mimeType defines the mime type of the result
  34857. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34858. */
  34859. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34860. /**
  34861. * Downloads a blob in the browser
  34862. * @param blob defines the blob to download
  34863. * @param fileName defines the name of the downloaded file
  34864. */
  34865. static Download(blob: Blob, fileName: string): void;
  34866. /**
  34867. * Captures a screenshot of the current rendering
  34868. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34869. * @param engine defines the rendering engine
  34870. * @param camera defines the source camera
  34871. * @param size This parameter can be set to a single number or to an object with the
  34872. * following (optional) properties: precision, width, height. If a single number is passed,
  34873. * it will be used for both width and height. If an object is passed, the screenshot size
  34874. * will be derived from the parameters. The precision property is a multiplier allowing
  34875. * rendering at a higher or lower resolution
  34876. * @param successCallback defines the callback receives a single parameter which contains the
  34877. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34878. * src parameter of an <img> to display it
  34879. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34880. * Check your browser for supported MIME types
  34881. */
  34882. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34883. /**
  34884. * Captures a screenshot of the current rendering
  34885. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34886. * @param engine defines the rendering engine
  34887. * @param camera defines the source camera
  34888. * @param size This parameter can be set to a single number or to an object with the
  34889. * following (optional) properties: precision, width, height. If a single number is passed,
  34890. * it will be used for both width and height. If an object is passed, the screenshot size
  34891. * will be derived from the parameters. The precision property is a multiplier allowing
  34892. * rendering at a higher or lower resolution
  34893. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34894. * Check your browser for supported MIME types
  34895. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34896. * to the src parameter of an <img> to display it
  34897. */
  34898. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34899. /**
  34900. * Generates an image screenshot from the specified camera.
  34901. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34902. * @param engine The engine to use for rendering
  34903. * @param camera The camera to use for rendering
  34904. * @param size This parameter can be set to a single number or to an object with the
  34905. * following (optional) properties: precision, width, height. If a single number is passed,
  34906. * it will be used for both width and height. If an object is passed, the screenshot size
  34907. * will be derived from the parameters. The precision property is a multiplier allowing
  34908. * rendering at a higher or lower resolution
  34909. * @param successCallback The callback receives a single parameter which contains the
  34910. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34911. * src parameter of an <img> to display it
  34912. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34913. * Check your browser for supported MIME types
  34914. * @param samples Texture samples (default: 1)
  34915. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34916. * @param fileName A name for for the downloaded file.
  34917. */
  34918. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34919. /**
  34920. * Generates an image screenshot from the specified camera.
  34921. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34922. * @param engine The engine to use for rendering
  34923. * @param camera The camera to use for rendering
  34924. * @param size This parameter can be set to a single number or to an object with the
  34925. * following (optional) properties: precision, width, height. If a single number is passed,
  34926. * it will be used for both width and height. If an object is passed, the screenshot size
  34927. * will be derived from the parameters. The precision property is a multiplier allowing
  34928. * rendering at a higher or lower resolution
  34929. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34930. * Check your browser for supported MIME types
  34931. * @param samples Texture samples (default: 1)
  34932. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34933. * @param fileName A name for for the downloaded file.
  34934. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34935. * to the src parameter of an <img> to display it
  34936. */
  34937. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34938. /**
  34939. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34940. * Be aware Math.random() could cause collisions, but:
  34941. * "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"
  34942. * @returns a pseudo random id
  34943. */
  34944. static RandomId(): string;
  34945. /**
  34946. * Test if the given uri is a base64 string
  34947. * @param uri The uri to test
  34948. * @return True if the uri is a base64 string or false otherwise
  34949. */
  34950. static IsBase64(uri: string): boolean;
  34951. /**
  34952. * Decode the given base64 uri.
  34953. * @param uri The uri to decode
  34954. * @return The decoded base64 data.
  34955. */
  34956. static DecodeBase64(uri: string): ArrayBuffer;
  34957. /**
  34958. * Gets the absolute url.
  34959. * @param url the input url
  34960. * @return the absolute url
  34961. */
  34962. static GetAbsoluteUrl(url: string): string;
  34963. /**
  34964. * No log
  34965. */
  34966. static readonly NoneLogLevel: number;
  34967. /**
  34968. * Only message logs
  34969. */
  34970. static readonly MessageLogLevel: number;
  34971. /**
  34972. * Only warning logs
  34973. */
  34974. static readonly WarningLogLevel: number;
  34975. /**
  34976. * Only error logs
  34977. */
  34978. static readonly ErrorLogLevel: number;
  34979. /**
  34980. * All logs
  34981. */
  34982. static readonly AllLogLevel: number;
  34983. /**
  34984. * Gets a value indicating the number of loading errors
  34985. * @ignorenaming
  34986. */
  34987. static get errorsCount(): number;
  34988. /**
  34989. * Callback called when a new log is added
  34990. */
  34991. static OnNewCacheEntry: (entry: string) => void;
  34992. /**
  34993. * Log a message to the console
  34994. * @param message defines the message to log
  34995. */
  34996. static Log(message: string): void;
  34997. /**
  34998. * Write a warning message to the console
  34999. * @param message defines the message to log
  35000. */
  35001. static Warn(message: string): void;
  35002. /**
  35003. * Write an error message to the console
  35004. * @param message defines the message to log
  35005. */
  35006. static Error(message: string): void;
  35007. /**
  35008. * Gets current log cache (list of logs)
  35009. */
  35010. static get LogCache(): string;
  35011. /**
  35012. * Clears the log cache
  35013. */
  35014. static ClearLogCache(): void;
  35015. /**
  35016. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35017. */
  35018. static set LogLevels(level: number);
  35019. /**
  35020. * Checks if the window object exists
  35021. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35022. */
  35023. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35024. /**
  35025. * No performance log
  35026. */
  35027. static readonly PerformanceNoneLogLevel: number;
  35028. /**
  35029. * Use user marks to log performance
  35030. */
  35031. static readonly PerformanceUserMarkLogLevel: number;
  35032. /**
  35033. * Log performance to the console
  35034. */
  35035. static readonly PerformanceConsoleLogLevel: number;
  35036. private static _performance;
  35037. /**
  35038. * Sets the current performance log level
  35039. */
  35040. static set PerformanceLogLevel(level: number);
  35041. private static _StartPerformanceCounterDisabled;
  35042. private static _EndPerformanceCounterDisabled;
  35043. private static _StartUserMark;
  35044. private static _EndUserMark;
  35045. private static _StartPerformanceConsole;
  35046. private static _EndPerformanceConsole;
  35047. /**
  35048. * Starts a performance counter
  35049. */
  35050. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35051. /**
  35052. * Ends a specific performance coutner
  35053. */
  35054. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35055. /**
  35056. * Gets either window.performance.now() if supported or Date.now() else
  35057. */
  35058. static get Now(): number;
  35059. /**
  35060. * This method will return the name of the class used to create the instance of the given object.
  35061. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35062. * @param object the object to get the class name from
  35063. * @param isType defines if the object is actually a type
  35064. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35065. */
  35066. static GetClassName(object: any, isType?: boolean): string;
  35067. /**
  35068. * Gets the first element of an array satisfying a given predicate
  35069. * @param array defines the array to browse
  35070. * @param predicate defines the predicate to use
  35071. * @returns null if not found or the element
  35072. */
  35073. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35074. /**
  35075. * This method will return the name of the full name of the class, including its owning module (if any).
  35076. * 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).
  35077. * @param object the object to get the class name from
  35078. * @param isType defines if the object is actually a type
  35079. * @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.
  35080. * @ignorenaming
  35081. */
  35082. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35083. /**
  35084. * Returns a promise that resolves after the given amount of time.
  35085. * @param delay Number of milliseconds to delay
  35086. * @returns Promise that resolves after the given amount of time
  35087. */
  35088. static DelayAsync(delay: number): Promise<void>;
  35089. /**
  35090. * Utility function to detect if the current user agent is Safari
  35091. * @returns whether or not the current user agent is safari
  35092. */
  35093. static IsSafari(): boolean;
  35094. }
  35095. /**
  35096. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35097. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35098. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35099. * @param name The name of the class, case should be preserved
  35100. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35101. */
  35102. export function className(name: string, module?: string): (target: Object) => void;
  35103. /**
  35104. * An implementation of a loop for asynchronous functions.
  35105. */
  35106. export class AsyncLoop {
  35107. /**
  35108. * Defines the number of iterations for the loop
  35109. */
  35110. iterations: number;
  35111. /**
  35112. * Defines the current index of the loop.
  35113. */
  35114. index: number;
  35115. private _done;
  35116. private _fn;
  35117. private _successCallback;
  35118. /**
  35119. * Constructor.
  35120. * @param iterations the number of iterations.
  35121. * @param func the function to run each iteration
  35122. * @param successCallback the callback that will be called upon succesful execution
  35123. * @param offset starting offset.
  35124. */
  35125. constructor(
  35126. /**
  35127. * Defines the number of iterations for the loop
  35128. */
  35129. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35130. /**
  35131. * Execute the next iteration. Must be called after the last iteration was finished.
  35132. */
  35133. executeNext(): void;
  35134. /**
  35135. * Break the loop and run the success callback.
  35136. */
  35137. breakLoop(): void;
  35138. /**
  35139. * Create and run an async loop.
  35140. * @param iterations the number of iterations.
  35141. * @param fn the function to run each iteration
  35142. * @param successCallback the callback that will be called upon succesful execution
  35143. * @param offset starting offset.
  35144. * @returns the created async loop object
  35145. */
  35146. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35147. /**
  35148. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35149. * @param iterations total number of iterations
  35150. * @param syncedIterations number of synchronous iterations in each async iteration.
  35151. * @param fn the function to call each iteration.
  35152. * @param callback a success call back that will be called when iterating stops.
  35153. * @param breakFunction a break condition (optional)
  35154. * @param timeout timeout settings for the setTimeout function. default - 0.
  35155. * @returns the created async loop object
  35156. */
  35157. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35158. }
  35159. }
  35160. declare module BABYLON {
  35161. /**
  35162. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35163. * The underlying implementation relies on an associative array to ensure the best performances.
  35164. * The value can be anything including 'null' but except 'undefined'
  35165. */
  35166. export class StringDictionary<T> {
  35167. /**
  35168. * This will clear this dictionary and copy the content from the 'source' one.
  35169. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35170. * @param source the dictionary to take the content from and copy to this dictionary
  35171. */
  35172. copyFrom(source: StringDictionary<T>): void;
  35173. /**
  35174. * Get a value based from its key
  35175. * @param key the given key to get the matching value from
  35176. * @return the value if found, otherwise undefined is returned
  35177. */
  35178. get(key: string): T | undefined;
  35179. /**
  35180. * Get a value from its key or add it if it doesn't exist.
  35181. * This method will ensure you that a given key/data will be present in the dictionary.
  35182. * @param key the given key to get the matching value from
  35183. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35184. * The factory will only be invoked if there's no data for the given key.
  35185. * @return the value corresponding to the key.
  35186. */
  35187. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35188. /**
  35189. * Get a value from its key if present in the dictionary otherwise add it
  35190. * @param key the key to get the value from
  35191. * @param val if there's no such key/value pair in the dictionary add it with this value
  35192. * @return the value corresponding to the key
  35193. */
  35194. getOrAdd(key: string, val: T): T;
  35195. /**
  35196. * Check if there's a given key in the dictionary
  35197. * @param key the key to check for
  35198. * @return true if the key is present, false otherwise
  35199. */
  35200. contains(key: string): boolean;
  35201. /**
  35202. * Add a new key and its corresponding value
  35203. * @param key the key to add
  35204. * @param value the value corresponding to the key
  35205. * @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
  35206. */
  35207. add(key: string, value: T): boolean;
  35208. /**
  35209. * Update a specific value associated to a key
  35210. * @param key defines the key to use
  35211. * @param value defines the value to store
  35212. * @returns true if the value was updated (or false if the key was not found)
  35213. */
  35214. set(key: string, value: T): boolean;
  35215. /**
  35216. * Get the element of the given key and remove it from the dictionary
  35217. * @param key defines the key to search
  35218. * @returns the value associated with the key or null if not found
  35219. */
  35220. getAndRemove(key: string): Nullable<T>;
  35221. /**
  35222. * Remove a key/value from the dictionary.
  35223. * @param key the key to remove
  35224. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35225. */
  35226. remove(key: string): boolean;
  35227. /**
  35228. * Clear the whole content of the dictionary
  35229. */
  35230. clear(): void;
  35231. /**
  35232. * Gets the current count
  35233. */
  35234. get count(): number;
  35235. /**
  35236. * Execute a callback on each key/val of the dictionary.
  35237. * Note that you can remove any element in this dictionary in the callback implementation
  35238. * @param callback the callback to execute on a given key/value pair
  35239. */
  35240. forEach(callback: (key: string, val: T) => void): void;
  35241. /**
  35242. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35243. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35244. * Note that you can remove any element in this dictionary in the callback implementation
  35245. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35246. * @returns the first item
  35247. */
  35248. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35249. private _count;
  35250. private _data;
  35251. }
  35252. }
  35253. declare module BABYLON {
  35254. /** @hidden */
  35255. export interface ICollisionCoordinator {
  35256. createCollider(): Collider;
  35257. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35258. init(scene: Scene): void;
  35259. }
  35260. /** @hidden */
  35261. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35262. private _scene;
  35263. private _scaledPosition;
  35264. private _scaledVelocity;
  35265. private _finalPosition;
  35266. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35267. createCollider(): Collider;
  35268. init(scene: Scene): void;
  35269. private _collideWithWorld;
  35270. }
  35271. }
  35272. declare module BABYLON {
  35273. /**
  35274. * Class used to manage all inputs for the scene.
  35275. */
  35276. export class InputManager {
  35277. /** The distance in pixel that you have to move to prevent some events */
  35278. static DragMovementThreshold: number;
  35279. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35280. static LongPressDelay: number;
  35281. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35282. static DoubleClickDelay: number;
  35283. /** If you need to check double click without raising a single click at first click, enable this flag */
  35284. static ExclusiveDoubleClickMode: boolean;
  35285. private _wheelEventName;
  35286. private _onPointerMove;
  35287. private _onPointerDown;
  35288. private _onPointerUp;
  35289. private _initClickEvent;
  35290. private _initActionManager;
  35291. private _delayedSimpleClick;
  35292. private _delayedSimpleClickTimeout;
  35293. private _previousDelayedSimpleClickTimeout;
  35294. private _meshPickProceed;
  35295. private _previousButtonPressed;
  35296. private _currentPickResult;
  35297. private _previousPickResult;
  35298. private _totalPointersPressed;
  35299. private _doubleClickOccured;
  35300. private _pointerOverMesh;
  35301. private _pickedDownMesh;
  35302. private _pickedUpMesh;
  35303. private _pointerX;
  35304. private _pointerY;
  35305. private _unTranslatedPointerX;
  35306. private _unTranslatedPointerY;
  35307. private _startingPointerPosition;
  35308. private _previousStartingPointerPosition;
  35309. private _startingPointerTime;
  35310. private _previousStartingPointerTime;
  35311. private _pointerCaptures;
  35312. private _onKeyDown;
  35313. private _onKeyUp;
  35314. private _onCanvasFocusObserver;
  35315. private _onCanvasBlurObserver;
  35316. private _scene;
  35317. /**
  35318. * Creates a new InputManager
  35319. * @param scene defines the hosting scene
  35320. */
  35321. constructor(scene: Scene);
  35322. /**
  35323. * Gets the mesh that is currently under the pointer
  35324. */
  35325. get meshUnderPointer(): Nullable<AbstractMesh>;
  35326. /**
  35327. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35328. */
  35329. get unTranslatedPointer(): Vector2;
  35330. /**
  35331. * Gets or sets the current on-screen X position of the pointer
  35332. */
  35333. get pointerX(): number;
  35334. set pointerX(value: number);
  35335. /**
  35336. * Gets or sets the current on-screen Y position of the pointer
  35337. */
  35338. get pointerY(): number;
  35339. set pointerY(value: number);
  35340. private _updatePointerPosition;
  35341. private _processPointerMove;
  35342. private _setRayOnPointerInfo;
  35343. private _checkPrePointerObservable;
  35344. /**
  35345. * Use this method to simulate a pointer move on a mesh
  35346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35349. */
  35350. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35351. /**
  35352. * Use this method to simulate a pointer down on a mesh
  35353. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35354. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35355. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35356. */
  35357. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35358. private _processPointerDown;
  35359. /** @hidden */
  35360. _isPointerSwiping(): boolean;
  35361. /**
  35362. * Use this method to simulate a pointer up on a mesh
  35363. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35364. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35365. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35366. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35367. */
  35368. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35369. private _processPointerUp;
  35370. /**
  35371. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35372. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35373. * @returns true if the pointer was captured
  35374. */
  35375. isPointerCaptured(pointerId?: number): boolean;
  35376. /**
  35377. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35378. * @param attachUp defines if you want to attach events to pointerup
  35379. * @param attachDown defines if you want to attach events to pointerdown
  35380. * @param attachMove defines if you want to attach events to pointermove
  35381. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35382. */
  35383. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35384. /**
  35385. * Detaches all event handlers
  35386. */
  35387. detachControl(): void;
  35388. /**
  35389. * Force the value of meshUnderPointer
  35390. * @param mesh defines the mesh to use
  35391. */
  35392. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35393. /**
  35394. * Gets the mesh under the pointer
  35395. * @returns a Mesh or null if no mesh is under the pointer
  35396. */
  35397. getPointerOverMesh(): Nullable<AbstractMesh>;
  35398. }
  35399. }
  35400. declare module BABYLON {
  35401. /**
  35402. * Helper class used to generate session unique ID
  35403. */
  35404. export class UniqueIdGenerator {
  35405. private static _UniqueIdCounter;
  35406. /**
  35407. * Gets an unique (relatively to the current scene) Id
  35408. */
  35409. static get UniqueId(): number;
  35410. }
  35411. }
  35412. declare module BABYLON {
  35413. /**
  35414. * This class defines the direct association between an animation and a target
  35415. */
  35416. export class TargetedAnimation {
  35417. /**
  35418. * Animation to perform
  35419. */
  35420. animation: Animation;
  35421. /**
  35422. * Target to animate
  35423. */
  35424. target: any;
  35425. /**
  35426. * Serialize the object
  35427. * @returns the JSON object representing the current entity
  35428. */
  35429. serialize(): any;
  35430. }
  35431. /**
  35432. * Use this class to create coordinated animations on multiple targets
  35433. */
  35434. export class AnimationGroup implements IDisposable {
  35435. /** The name of the animation group */
  35436. name: string;
  35437. private _scene;
  35438. private _targetedAnimations;
  35439. private _animatables;
  35440. private _from;
  35441. private _to;
  35442. private _isStarted;
  35443. private _isPaused;
  35444. private _speedRatio;
  35445. private _loopAnimation;
  35446. private _isAdditive;
  35447. /**
  35448. * Gets or sets the unique id of the node
  35449. */
  35450. uniqueId: number;
  35451. /**
  35452. * This observable will notify when one animation have ended
  35453. */
  35454. onAnimationEndObservable: Observable<TargetedAnimation>;
  35455. /**
  35456. * Observer raised when one animation loops
  35457. */
  35458. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35459. /**
  35460. * Observer raised when all animations have looped
  35461. */
  35462. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35463. /**
  35464. * This observable will notify when all animations have ended.
  35465. */
  35466. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35467. /**
  35468. * This observable will notify when all animations have paused.
  35469. */
  35470. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35471. /**
  35472. * This observable will notify when all animations are playing.
  35473. */
  35474. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35475. /**
  35476. * Gets the first frame
  35477. */
  35478. get from(): number;
  35479. /**
  35480. * Gets the last frame
  35481. */
  35482. get to(): number;
  35483. /**
  35484. * Define if the animations are started
  35485. */
  35486. get isStarted(): boolean;
  35487. /**
  35488. * Gets a value indicating that the current group is playing
  35489. */
  35490. get isPlaying(): boolean;
  35491. /**
  35492. * Gets or sets the speed ratio to use for all animations
  35493. */
  35494. get speedRatio(): number;
  35495. /**
  35496. * Gets or sets the speed ratio to use for all animations
  35497. */
  35498. set speedRatio(value: number);
  35499. /**
  35500. * Gets or sets if all animations should loop or not
  35501. */
  35502. get loopAnimation(): boolean;
  35503. set loopAnimation(value: boolean);
  35504. /**
  35505. * Gets or sets if all animations should be evaluated additively
  35506. */
  35507. get isAdditive(): boolean;
  35508. set isAdditive(value: boolean);
  35509. /**
  35510. * Gets the targeted animations for this animation group
  35511. */
  35512. get targetedAnimations(): Array<TargetedAnimation>;
  35513. /**
  35514. * returning the list of animatables controlled by this animation group.
  35515. */
  35516. get animatables(): Array<Animatable>;
  35517. /**
  35518. * Instantiates a new Animation Group.
  35519. * This helps managing several animations at once.
  35520. * @see http://doc.babylonjs.com/how_to/group
  35521. * @param name Defines the name of the group
  35522. * @param scene Defines the scene the group belongs to
  35523. */
  35524. constructor(
  35525. /** The name of the animation group */
  35526. name: string, scene?: Nullable<Scene>);
  35527. /**
  35528. * Add an animation (with its target) in the group
  35529. * @param animation defines the animation we want to add
  35530. * @param target defines the target of the animation
  35531. * @returns the TargetedAnimation object
  35532. */
  35533. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35534. /**
  35535. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35536. * It can add constant keys at begin or end
  35537. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35538. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35539. * @returns the animation group
  35540. */
  35541. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35542. private _animationLoopCount;
  35543. private _animationLoopFlags;
  35544. private _processLoop;
  35545. /**
  35546. * Start all animations on given targets
  35547. * @param loop defines if animations must loop
  35548. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35549. * @param from defines the from key (optional)
  35550. * @param to defines the to key (optional)
  35551. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35552. * @returns the current animation group
  35553. */
  35554. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35555. /**
  35556. * Pause all animations
  35557. * @returns the animation group
  35558. */
  35559. pause(): AnimationGroup;
  35560. /**
  35561. * Play all animations to initial state
  35562. * This function will start() the animations if they were not started or will restart() them if they were paused
  35563. * @param loop defines if animations must loop
  35564. * @returns the animation group
  35565. */
  35566. play(loop?: boolean): AnimationGroup;
  35567. /**
  35568. * Reset all animations to initial state
  35569. * @returns the animation group
  35570. */
  35571. reset(): AnimationGroup;
  35572. /**
  35573. * Restart animations from key 0
  35574. * @returns the animation group
  35575. */
  35576. restart(): AnimationGroup;
  35577. /**
  35578. * Stop all animations
  35579. * @returns the animation group
  35580. */
  35581. stop(): AnimationGroup;
  35582. /**
  35583. * Set animation weight for all animatables
  35584. * @param weight defines the weight to use
  35585. * @return the animationGroup
  35586. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35587. */
  35588. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35589. /**
  35590. * Synchronize and normalize all animatables with a source animatable
  35591. * @param root defines the root animatable to synchronize with
  35592. * @return the animationGroup
  35593. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35594. */
  35595. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35596. /**
  35597. * Goes to a specific frame in this animation group
  35598. * @param frame the frame number to go to
  35599. * @return the animationGroup
  35600. */
  35601. goToFrame(frame: number): AnimationGroup;
  35602. /**
  35603. * Dispose all associated resources
  35604. */
  35605. dispose(): void;
  35606. private _checkAnimationGroupEnded;
  35607. /**
  35608. * Clone the current animation group and returns a copy
  35609. * @param newName defines the name of the new group
  35610. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35611. * @returns the new aniamtion group
  35612. */
  35613. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35614. /**
  35615. * Serializes the animationGroup to an object
  35616. * @returns Serialized object
  35617. */
  35618. serialize(): any;
  35619. /**
  35620. * Returns a new AnimationGroup object parsed from the source provided.
  35621. * @param parsedAnimationGroup defines the source
  35622. * @param scene defines the scene that will receive the animationGroup
  35623. * @returns a new AnimationGroup
  35624. */
  35625. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35626. /**
  35627. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35628. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35629. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35630. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35631. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35632. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35633. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35634. */
  35635. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35636. /**
  35637. * Returns the string "AnimationGroup"
  35638. * @returns "AnimationGroup"
  35639. */
  35640. getClassName(): string;
  35641. /**
  35642. * Creates a detailled string about the object
  35643. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35644. * @returns a string representing the object
  35645. */
  35646. toString(fullDetails?: boolean): string;
  35647. }
  35648. }
  35649. declare module BABYLON {
  35650. /**
  35651. * Define an interface for all classes that will hold resources
  35652. */
  35653. export interface IDisposable {
  35654. /**
  35655. * Releases all held resources
  35656. */
  35657. dispose(): void;
  35658. }
  35659. /** Interface defining initialization parameters for Scene class */
  35660. export interface SceneOptions {
  35661. /**
  35662. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35663. * It will improve performance when the number of geometries becomes important.
  35664. */
  35665. useGeometryUniqueIdsMap?: boolean;
  35666. /**
  35667. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35668. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35669. */
  35670. useMaterialMeshMap?: boolean;
  35671. /**
  35672. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35673. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35674. */
  35675. useClonedMeshMap?: boolean;
  35676. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35677. virtual?: boolean;
  35678. }
  35679. /**
  35680. * Represents a scene to be rendered by the engine.
  35681. * @see http://doc.babylonjs.com/features/scene
  35682. */
  35683. export class Scene extends AbstractScene implements IAnimatable {
  35684. /** The fog is deactivated */
  35685. static readonly FOGMODE_NONE: number;
  35686. /** The fog density is following an exponential function */
  35687. static readonly FOGMODE_EXP: number;
  35688. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35689. static readonly FOGMODE_EXP2: number;
  35690. /** The fog density is following a linear function. */
  35691. static readonly FOGMODE_LINEAR: number;
  35692. /**
  35693. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35694. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35695. */
  35696. static MinDeltaTime: number;
  35697. /**
  35698. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35700. */
  35701. static MaxDeltaTime: number;
  35702. /**
  35703. * Factory used to create the default material.
  35704. * @param name The name of the material to create
  35705. * @param scene The scene to create the material for
  35706. * @returns The default material
  35707. */
  35708. static DefaultMaterialFactory(scene: Scene): Material;
  35709. /**
  35710. * Factory used to create the a collision coordinator.
  35711. * @returns The collision coordinator
  35712. */
  35713. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35714. /** @hidden */
  35715. _inputManager: InputManager;
  35716. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35717. cameraToUseForPointers: Nullable<Camera>;
  35718. /** @hidden */
  35719. readonly _isScene: boolean;
  35720. /** @hidden */
  35721. _blockEntityCollection: boolean;
  35722. /**
  35723. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35724. */
  35725. autoClear: boolean;
  35726. /**
  35727. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35728. */
  35729. autoClearDepthAndStencil: boolean;
  35730. /**
  35731. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35732. */
  35733. clearColor: Color4;
  35734. /**
  35735. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35736. */
  35737. ambientColor: Color3;
  35738. /**
  35739. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35740. * It should only be one of the following (if not the default embedded one):
  35741. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35742. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35743. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35744. * The material properties need to be setup according to the type of texture in use.
  35745. */
  35746. environmentBRDFTexture: BaseTexture;
  35747. /** @hidden */
  35748. protected _environmentTexture: Nullable<BaseTexture>;
  35749. /**
  35750. * Texture used in all pbr material as the reflection texture.
  35751. * As in the majority of the scene they are the same (exception for multi room and so on),
  35752. * this is easier to reference from here than from all the materials.
  35753. */
  35754. get environmentTexture(): Nullable<BaseTexture>;
  35755. /**
  35756. * Texture used in all pbr material as the reflection texture.
  35757. * As in the majority of the scene they are the same (exception for multi room and so on),
  35758. * this is easier to set here than in all the materials.
  35759. */
  35760. set environmentTexture(value: Nullable<BaseTexture>);
  35761. /** @hidden */
  35762. protected _environmentIntensity: number;
  35763. /**
  35764. * Intensity of the environment in all pbr material.
  35765. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35766. * As in the majority of the scene they are the same (exception for multi room and so on),
  35767. * this is easier to reference from here than from all the materials.
  35768. */
  35769. get environmentIntensity(): number;
  35770. /**
  35771. * Intensity of the environment in all pbr material.
  35772. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35773. * As in the majority of the scene they are the same (exception for multi room and so on),
  35774. * this is easier to set here than in all the materials.
  35775. */
  35776. set environmentIntensity(value: number);
  35777. /** @hidden */
  35778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35779. /**
  35780. * Default image processing configuration used either in the rendering
  35781. * Forward main pass or through the imageProcessingPostProcess if present.
  35782. * As in the majority of the scene they are the same (exception for multi camera),
  35783. * this is easier to reference from here than from all the materials and post process.
  35784. *
  35785. * No setter as we it is a shared configuration, you can set the values instead.
  35786. */
  35787. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35788. private _forceWireframe;
  35789. /**
  35790. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35791. */
  35792. set forceWireframe(value: boolean);
  35793. get forceWireframe(): boolean;
  35794. private _skipFrustumClipping;
  35795. /**
  35796. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35797. */
  35798. set skipFrustumClipping(value: boolean);
  35799. get skipFrustumClipping(): boolean;
  35800. private _forcePointsCloud;
  35801. /**
  35802. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35803. */
  35804. set forcePointsCloud(value: boolean);
  35805. get forcePointsCloud(): boolean;
  35806. /**
  35807. * Gets or sets the active clipplane 1
  35808. */
  35809. clipPlane: Nullable<Plane>;
  35810. /**
  35811. * Gets or sets the active clipplane 2
  35812. */
  35813. clipPlane2: Nullable<Plane>;
  35814. /**
  35815. * Gets or sets the active clipplane 3
  35816. */
  35817. clipPlane3: Nullable<Plane>;
  35818. /**
  35819. * Gets or sets the active clipplane 4
  35820. */
  35821. clipPlane4: Nullable<Plane>;
  35822. /**
  35823. * Gets or sets the active clipplane 5
  35824. */
  35825. clipPlane5: Nullable<Plane>;
  35826. /**
  35827. * Gets or sets the active clipplane 6
  35828. */
  35829. clipPlane6: Nullable<Plane>;
  35830. /**
  35831. * Gets or sets a boolean indicating if animations are enabled
  35832. */
  35833. animationsEnabled: boolean;
  35834. private _animationPropertiesOverride;
  35835. /**
  35836. * Gets or sets the animation properties override
  35837. */
  35838. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35839. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35840. /**
  35841. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35842. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35843. */
  35844. useConstantAnimationDeltaTime: boolean;
  35845. /**
  35846. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35847. * Please note that it requires to run a ray cast through the scene on every frame
  35848. */
  35849. constantlyUpdateMeshUnderPointer: boolean;
  35850. /**
  35851. * Defines the HTML cursor to use when hovering over interactive elements
  35852. */
  35853. hoverCursor: string;
  35854. /**
  35855. * Defines the HTML default cursor to use (empty by default)
  35856. */
  35857. defaultCursor: string;
  35858. /**
  35859. * Defines whether cursors are handled by the scene.
  35860. */
  35861. doNotHandleCursors: boolean;
  35862. /**
  35863. * This is used to call preventDefault() on pointer down
  35864. * in order to block unwanted artifacts like system double clicks
  35865. */
  35866. preventDefaultOnPointerDown: boolean;
  35867. /**
  35868. * This is used to call preventDefault() on pointer up
  35869. * in order to block unwanted artifacts like system double clicks
  35870. */
  35871. preventDefaultOnPointerUp: boolean;
  35872. /**
  35873. * Gets or sets user defined metadata
  35874. */
  35875. metadata: any;
  35876. /**
  35877. * For internal use only. Please do not use.
  35878. */
  35879. reservedDataStore: any;
  35880. /**
  35881. * Gets the name of the plugin used to load this scene (null by default)
  35882. */
  35883. loadingPluginName: string;
  35884. /**
  35885. * Use this array to add regular expressions used to disable offline support for specific urls
  35886. */
  35887. disableOfflineSupportExceptionRules: RegExp[];
  35888. /**
  35889. * An event triggered when the scene is disposed.
  35890. */
  35891. onDisposeObservable: Observable<Scene>;
  35892. private _onDisposeObserver;
  35893. /** Sets a function to be executed when this scene is disposed. */
  35894. set onDispose(callback: () => void);
  35895. /**
  35896. * An event triggered before rendering the scene (right after animations and physics)
  35897. */
  35898. onBeforeRenderObservable: Observable<Scene>;
  35899. private _onBeforeRenderObserver;
  35900. /** Sets a function to be executed before rendering this scene */
  35901. set beforeRender(callback: Nullable<() => void>);
  35902. /**
  35903. * An event triggered after rendering the scene
  35904. */
  35905. onAfterRenderObservable: Observable<Scene>;
  35906. /**
  35907. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35908. */
  35909. onAfterRenderCameraObservable: Observable<Camera>;
  35910. private _onAfterRenderObserver;
  35911. /** Sets a function to be executed after rendering this scene */
  35912. set afterRender(callback: Nullable<() => void>);
  35913. /**
  35914. * An event triggered before animating the scene
  35915. */
  35916. onBeforeAnimationsObservable: Observable<Scene>;
  35917. /**
  35918. * An event triggered after animations processing
  35919. */
  35920. onAfterAnimationsObservable: Observable<Scene>;
  35921. /**
  35922. * An event triggered before draw calls are ready to be sent
  35923. */
  35924. onBeforeDrawPhaseObservable: Observable<Scene>;
  35925. /**
  35926. * An event triggered after draw calls have been sent
  35927. */
  35928. onAfterDrawPhaseObservable: Observable<Scene>;
  35929. /**
  35930. * An event triggered when the scene is ready
  35931. */
  35932. onReadyObservable: Observable<Scene>;
  35933. /**
  35934. * An event triggered before rendering a camera
  35935. */
  35936. onBeforeCameraRenderObservable: Observable<Camera>;
  35937. private _onBeforeCameraRenderObserver;
  35938. /** Sets a function to be executed before rendering a camera*/
  35939. set beforeCameraRender(callback: () => void);
  35940. /**
  35941. * An event triggered after rendering a camera
  35942. */
  35943. onAfterCameraRenderObservable: Observable<Camera>;
  35944. private _onAfterCameraRenderObserver;
  35945. /** Sets a function to be executed after rendering a camera*/
  35946. set afterCameraRender(callback: () => void);
  35947. /**
  35948. * An event triggered when active meshes evaluation is about to start
  35949. */
  35950. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35951. /**
  35952. * An event triggered when active meshes evaluation is done
  35953. */
  35954. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35955. /**
  35956. * An event triggered when particles rendering is about to start
  35957. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35958. */
  35959. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35960. /**
  35961. * An event triggered when particles rendering is done
  35962. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35963. */
  35964. onAfterParticlesRenderingObservable: Observable<Scene>;
  35965. /**
  35966. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35967. */
  35968. onDataLoadedObservable: Observable<Scene>;
  35969. /**
  35970. * An event triggered when a camera is created
  35971. */
  35972. onNewCameraAddedObservable: Observable<Camera>;
  35973. /**
  35974. * An event triggered when a camera is removed
  35975. */
  35976. onCameraRemovedObservable: Observable<Camera>;
  35977. /**
  35978. * An event triggered when a light is created
  35979. */
  35980. onNewLightAddedObservable: Observable<Light>;
  35981. /**
  35982. * An event triggered when a light is removed
  35983. */
  35984. onLightRemovedObservable: Observable<Light>;
  35985. /**
  35986. * An event triggered when a geometry is created
  35987. */
  35988. onNewGeometryAddedObservable: Observable<Geometry>;
  35989. /**
  35990. * An event triggered when a geometry is removed
  35991. */
  35992. onGeometryRemovedObservable: Observable<Geometry>;
  35993. /**
  35994. * An event triggered when a transform node is created
  35995. */
  35996. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35997. /**
  35998. * An event triggered when a transform node is removed
  35999. */
  36000. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36001. /**
  36002. * An event triggered when a mesh is created
  36003. */
  36004. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36005. /**
  36006. * An event triggered when a mesh is removed
  36007. */
  36008. onMeshRemovedObservable: Observable<AbstractMesh>;
  36009. /**
  36010. * An event triggered when a skeleton is created
  36011. */
  36012. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36013. /**
  36014. * An event triggered when a skeleton is removed
  36015. */
  36016. onSkeletonRemovedObservable: Observable<Skeleton>;
  36017. /**
  36018. * An event triggered when a material is created
  36019. */
  36020. onNewMaterialAddedObservable: Observable<Material>;
  36021. /**
  36022. * An event triggered when a material is removed
  36023. */
  36024. onMaterialRemovedObservable: Observable<Material>;
  36025. /**
  36026. * An event triggered when a texture is created
  36027. */
  36028. onNewTextureAddedObservable: Observable<BaseTexture>;
  36029. /**
  36030. * An event triggered when a texture is removed
  36031. */
  36032. onTextureRemovedObservable: Observable<BaseTexture>;
  36033. /**
  36034. * An event triggered when render targets are about to be rendered
  36035. * Can happen multiple times per frame.
  36036. */
  36037. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36038. /**
  36039. * An event triggered when render targets were rendered.
  36040. * Can happen multiple times per frame.
  36041. */
  36042. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36043. /**
  36044. * An event triggered before calculating deterministic simulation step
  36045. */
  36046. onBeforeStepObservable: Observable<Scene>;
  36047. /**
  36048. * An event triggered after calculating deterministic simulation step
  36049. */
  36050. onAfterStepObservable: Observable<Scene>;
  36051. /**
  36052. * An event triggered when the activeCamera property is updated
  36053. */
  36054. onActiveCameraChanged: Observable<Scene>;
  36055. /**
  36056. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36057. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36058. * 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)
  36059. */
  36060. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36061. /**
  36062. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36063. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36064. * 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)
  36065. */
  36066. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36067. /**
  36068. * This Observable will when a mesh has been imported into the scene.
  36069. */
  36070. onMeshImportedObservable: Observable<AbstractMesh>;
  36071. /**
  36072. * This Observable will when an animation file has been imported into the scene.
  36073. */
  36074. onAnimationFileImportedObservable: Observable<Scene>;
  36075. /**
  36076. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36077. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36078. */
  36079. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36080. /** @hidden */
  36081. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36082. /**
  36083. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36084. */
  36085. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36086. /**
  36087. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36088. */
  36089. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36090. /**
  36091. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36092. */
  36093. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36094. /** Callback called when a pointer move is detected */
  36095. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36096. /** Callback called when a pointer down is detected */
  36097. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36098. /** Callback called when a pointer up is detected */
  36099. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36100. /** Callback called when a pointer pick is detected */
  36101. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36102. /**
  36103. * 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).
  36104. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36105. */
  36106. onPrePointerObservable: Observable<PointerInfoPre>;
  36107. /**
  36108. * Observable event triggered each time an input event is received from the rendering canvas
  36109. */
  36110. onPointerObservable: Observable<PointerInfo>;
  36111. /**
  36112. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36113. */
  36114. get unTranslatedPointer(): Vector2;
  36115. /**
  36116. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36117. */
  36118. static get DragMovementThreshold(): number;
  36119. static set DragMovementThreshold(value: number);
  36120. /**
  36121. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36122. */
  36123. static get LongPressDelay(): number;
  36124. static set LongPressDelay(value: number);
  36125. /**
  36126. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36127. */
  36128. static get DoubleClickDelay(): number;
  36129. static set DoubleClickDelay(value: number);
  36130. /** If you need to check double click without raising a single click at first click, enable this flag */
  36131. static get ExclusiveDoubleClickMode(): boolean;
  36132. static set ExclusiveDoubleClickMode(value: boolean);
  36133. /** @hidden */
  36134. _mirroredCameraPosition: Nullable<Vector3>;
  36135. /**
  36136. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36137. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36138. */
  36139. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36140. /**
  36141. * Observable event triggered each time an keyboard event is received from the hosting window
  36142. */
  36143. onKeyboardObservable: Observable<KeyboardInfo>;
  36144. private _useRightHandedSystem;
  36145. /**
  36146. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36147. */
  36148. set useRightHandedSystem(value: boolean);
  36149. get useRightHandedSystem(): boolean;
  36150. private _timeAccumulator;
  36151. private _currentStepId;
  36152. private _currentInternalStep;
  36153. /**
  36154. * Sets the step Id used by deterministic lock step
  36155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36156. * @param newStepId defines the step Id
  36157. */
  36158. setStepId(newStepId: number): void;
  36159. /**
  36160. * Gets the step Id used by deterministic lock step
  36161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36162. * @returns the step Id
  36163. */
  36164. getStepId(): number;
  36165. /**
  36166. * Gets the internal step used by deterministic lock step
  36167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36168. * @returns the internal step
  36169. */
  36170. getInternalStep(): number;
  36171. private _fogEnabled;
  36172. /**
  36173. * Gets or sets a boolean indicating if fog is enabled on this scene
  36174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36175. * (Default is true)
  36176. */
  36177. set fogEnabled(value: boolean);
  36178. get fogEnabled(): boolean;
  36179. private _fogMode;
  36180. /**
  36181. * Gets or sets the fog mode to use
  36182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36183. * | mode | value |
  36184. * | --- | --- |
  36185. * | FOGMODE_NONE | 0 |
  36186. * | FOGMODE_EXP | 1 |
  36187. * | FOGMODE_EXP2 | 2 |
  36188. * | FOGMODE_LINEAR | 3 |
  36189. */
  36190. set fogMode(value: number);
  36191. get fogMode(): number;
  36192. /**
  36193. * Gets or sets the fog color to use
  36194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36195. * (Default is Color3(0.2, 0.2, 0.3))
  36196. */
  36197. fogColor: Color3;
  36198. /**
  36199. * Gets or sets the fog density to use
  36200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36201. * (Default is 0.1)
  36202. */
  36203. fogDensity: number;
  36204. /**
  36205. * Gets or sets the fog start distance to use
  36206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36207. * (Default is 0)
  36208. */
  36209. fogStart: number;
  36210. /**
  36211. * Gets or sets the fog end distance to use
  36212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36213. * (Default is 1000)
  36214. */
  36215. fogEnd: number;
  36216. private _shadowsEnabled;
  36217. /**
  36218. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36219. */
  36220. set shadowsEnabled(value: boolean);
  36221. get shadowsEnabled(): boolean;
  36222. private _lightsEnabled;
  36223. /**
  36224. * Gets or sets a boolean indicating if lights are enabled on this scene
  36225. */
  36226. set lightsEnabled(value: boolean);
  36227. get lightsEnabled(): boolean;
  36228. /** All of the active cameras added to this scene. */
  36229. activeCameras: Camera[];
  36230. /** @hidden */
  36231. _activeCamera: Nullable<Camera>;
  36232. /** Gets or sets the current active camera */
  36233. get activeCamera(): Nullable<Camera>;
  36234. set activeCamera(value: Nullable<Camera>);
  36235. private _defaultMaterial;
  36236. /** The default material used on meshes when no material is affected */
  36237. get defaultMaterial(): Material;
  36238. /** The default material used on meshes when no material is affected */
  36239. set defaultMaterial(value: Material);
  36240. private _texturesEnabled;
  36241. /**
  36242. * Gets or sets a boolean indicating if textures are enabled on this scene
  36243. */
  36244. set texturesEnabled(value: boolean);
  36245. get texturesEnabled(): boolean;
  36246. /**
  36247. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36248. */
  36249. physicsEnabled: boolean;
  36250. /**
  36251. * Gets or sets a boolean indicating if particles are enabled on this scene
  36252. */
  36253. particlesEnabled: boolean;
  36254. /**
  36255. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36256. */
  36257. spritesEnabled: boolean;
  36258. private _skeletonsEnabled;
  36259. /**
  36260. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36261. */
  36262. set skeletonsEnabled(value: boolean);
  36263. get skeletonsEnabled(): boolean;
  36264. /**
  36265. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36266. */
  36267. lensFlaresEnabled: boolean;
  36268. /**
  36269. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36271. */
  36272. collisionsEnabled: boolean;
  36273. private _collisionCoordinator;
  36274. /** @hidden */
  36275. get collisionCoordinator(): ICollisionCoordinator;
  36276. /**
  36277. * Defines the gravity applied to this scene (used only for collisions)
  36278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36279. */
  36280. gravity: Vector3;
  36281. /**
  36282. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36283. */
  36284. postProcessesEnabled: boolean;
  36285. /**
  36286. * The list of postprocesses added to the scene
  36287. */
  36288. postProcesses: PostProcess[];
  36289. /**
  36290. * Gets the current postprocess manager
  36291. */
  36292. postProcessManager: PostProcessManager;
  36293. /**
  36294. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36295. */
  36296. renderTargetsEnabled: boolean;
  36297. /**
  36298. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36299. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36300. */
  36301. dumpNextRenderTargets: boolean;
  36302. /**
  36303. * The list of user defined render targets added to the scene
  36304. */
  36305. customRenderTargets: RenderTargetTexture[];
  36306. /**
  36307. * Defines if texture loading must be delayed
  36308. * If true, textures will only be loaded when they need to be rendered
  36309. */
  36310. useDelayedTextureLoading: boolean;
  36311. /**
  36312. * Gets the list of meshes imported to the scene through SceneLoader
  36313. */
  36314. importedMeshesFiles: String[];
  36315. /**
  36316. * Gets or sets a boolean indicating if probes are enabled on this scene
  36317. */
  36318. probesEnabled: boolean;
  36319. /**
  36320. * Gets or sets the current offline provider to use to store scene data
  36321. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36322. */
  36323. offlineProvider: IOfflineProvider;
  36324. /**
  36325. * Gets or sets the action manager associated with the scene
  36326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36327. */
  36328. actionManager: AbstractActionManager;
  36329. private _meshesForIntersections;
  36330. /**
  36331. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36332. */
  36333. proceduralTexturesEnabled: boolean;
  36334. private _engine;
  36335. private _totalVertices;
  36336. /** @hidden */
  36337. _activeIndices: PerfCounter;
  36338. /** @hidden */
  36339. _activeParticles: PerfCounter;
  36340. /** @hidden */
  36341. _activeBones: PerfCounter;
  36342. private _animationRatio;
  36343. /** @hidden */
  36344. _animationTimeLast: number;
  36345. /** @hidden */
  36346. _animationTime: number;
  36347. /**
  36348. * Gets or sets a general scale for animation speed
  36349. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36350. */
  36351. animationTimeScale: number;
  36352. /** @hidden */
  36353. _cachedMaterial: Nullable<Material>;
  36354. /** @hidden */
  36355. _cachedEffect: Nullable<Effect>;
  36356. /** @hidden */
  36357. _cachedVisibility: Nullable<number>;
  36358. private _renderId;
  36359. private _frameId;
  36360. private _executeWhenReadyTimeoutId;
  36361. private _intermediateRendering;
  36362. private _viewUpdateFlag;
  36363. private _projectionUpdateFlag;
  36364. /** @hidden */
  36365. _toBeDisposed: Nullable<IDisposable>[];
  36366. private _activeRequests;
  36367. /** @hidden */
  36368. _pendingData: any[];
  36369. private _isDisposed;
  36370. /**
  36371. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36372. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36373. */
  36374. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36375. private _activeMeshes;
  36376. private _processedMaterials;
  36377. private _renderTargets;
  36378. /** @hidden */
  36379. _activeParticleSystems: SmartArray<IParticleSystem>;
  36380. private _activeSkeletons;
  36381. private _softwareSkinnedMeshes;
  36382. private _renderingManager;
  36383. /** @hidden */
  36384. _activeAnimatables: Animatable[];
  36385. private _transformMatrix;
  36386. private _sceneUbo;
  36387. /** @hidden */
  36388. _viewMatrix: Matrix;
  36389. private _projectionMatrix;
  36390. /** @hidden */
  36391. _forcedViewPosition: Nullable<Vector3>;
  36392. /** @hidden */
  36393. _frustumPlanes: Plane[];
  36394. /**
  36395. * Gets the list of frustum planes (built from the active camera)
  36396. */
  36397. get frustumPlanes(): Plane[];
  36398. /**
  36399. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36400. * This is useful if there are more lights that the maximum simulteanous authorized
  36401. */
  36402. requireLightSorting: boolean;
  36403. /** @hidden */
  36404. readonly useMaterialMeshMap: boolean;
  36405. /** @hidden */
  36406. readonly useClonedMeshMap: boolean;
  36407. private _externalData;
  36408. private _uid;
  36409. /**
  36410. * @hidden
  36411. * Backing store of defined scene components.
  36412. */
  36413. _components: ISceneComponent[];
  36414. /**
  36415. * @hidden
  36416. * Backing store of defined scene components.
  36417. */
  36418. _serializableComponents: ISceneSerializableComponent[];
  36419. /**
  36420. * List of components to register on the next registration step.
  36421. */
  36422. private _transientComponents;
  36423. /**
  36424. * Registers the transient components if needed.
  36425. */
  36426. private _registerTransientComponents;
  36427. /**
  36428. * @hidden
  36429. * Add a component to the scene.
  36430. * Note that the ccomponent could be registered on th next frame if this is called after
  36431. * the register component stage.
  36432. * @param component Defines the component to add to the scene
  36433. */
  36434. _addComponent(component: ISceneComponent): void;
  36435. /**
  36436. * @hidden
  36437. * Gets a component from the scene.
  36438. * @param name defines the name of the component to retrieve
  36439. * @returns the component or null if not present
  36440. */
  36441. _getComponent(name: string): Nullable<ISceneComponent>;
  36442. /**
  36443. * @hidden
  36444. * Defines the actions happening before camera updates.
  36445. */
  36446. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36447. /**
  36448. * @hidden
  36449. * Defines the actions happening before clear the canvas.
  36450. */
  36451. _beforeClearStage: Stage<SimpleStageAction>;
  36452. /**
  36453. * @hidden
  36454. * Defines the actions when collecting render targets for the frame.
  36455. */
  36456. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36457. /**
  36458. * @hidden
  36459. * Defines the actions happening for one camera in the frame.
  36460. */
  36461. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36462. /**
  36463. * @hidden
  36464. * Defines the actions happening during the per mesh ready checks.
  36465. */
  36466. _isReadyForMeshStage: Stage<MeshStageAction>;
  36467. /**
  36468. * @hidden
  36469. * Defines the actions happening before evaluate active mesh checks.
  36470. */
  36471. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36472. /**
  36473. * @hidden
  36474. * Defines the actions happening during the evaluate sub mesh checks.
  36475. */
  36476. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36477. /**
  36478. * @hidden
  36479. * Defines the actions happening during the active mesh stage.
  36480. */
  36481. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36482. /**
  36483. * @hidden
  36484. * Defines the actions happening during the per camera render target step.
  36485. */
  36486. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36487. /**
  36488. * @hidden
  36489. * Defines the actions happening just before the active camera is drawing.
  36490. */
  36491. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36492. /**
  36493. * @hidden
  36494. * Defines the actions happening just before a render target is drawing.
  36495. */
  36496. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36497. /**
  36498. * @hidden
  36499. * Defines the actions happening just before a rendering group is drawing.
  36500. */
  36501. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36502. /**
  36503. * @hidden
  36504. * Defines the actions happening just before a mesh is drawing.
  36505. */
  36506. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36507. /**
  36508. * @hidden
  36509. * Defines the actions happening just after a mesh has been drawn.
  36510. */
  36511. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36512. /**
  36513. * @hidden
  36514. * Defines the actions happening just after a rendering group has been drawn.
  36515. */
  36516. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36517. /**
  36518. * @hidden
  36519. * Defines the actions happening just after the active camera has been drawn.
  36520. */
  36521. _afterCameraDrawStage: Stage<CameraStageAction>;
  36522. /**
  36523. * @hidden
  36524. * Defines the actions happening just after a render target has been drawn.
  36525. */
  36526. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36527. /**
  36528. * @hidden
  36529. * Defines the actions happening just after rendering all cameras and computing intersections.
  36530. */
  36531. _afterRenderStage: Stage<SimpleStageAction>;
  36532. /**
  36533. * @hidden
  36534. * Defines the actions happening when a pointer move event happens.
  36535. */
  36536. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36537. /**
  36538. * @hidden
  36539. * Defines the actions happening when a pointer down event happens.
  36540. */
  36541. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36542. /**
  36543. * @hidden
  36544. * Defines the actions happening when a pointer up event happens.
  36545. */
  36546. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36547. /**
  36548. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36549. */
  36550. private geometriesByUniqueId;
  36551. /**
  36552. * Creates a new Scene
  36553. * @param engine defines the engine to use to render this scene
  36554. * @param options defines the scene options
  36555. */
  36556. constructor(engine: Engine, options?: SceneOptions);
  36557. /**
  36558. * Gets a string idenfifying the name of the class
  36559. * @returns "Scene" string
  36560. */
  36561. getClassName(): string;
  36562. private _defaultMeshCandidates;
  36563. /**
  36564. * @hidden
  36565. */
  36566. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36567. private _defaultSubMeshCandidates;
  36568. /**
  36569. * @hidden
  36570. */
  36571. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36572. /**
  36573. * Sets the default candidate providers for the scene.
  36574. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36575. * and getCollidingSubMeshCandidates to their default function
  36576. */
  36577. setDefaultCandidateProviders(): void;
  36578. /**
  36579. * Gets the mesh that is currently under the pointer
  36580. */
  36581. get meshUnderPointer(): Nullable<AbstractMesh>;
  36582. /**
  36583. * Gets or sets the current on-screen X position of the pointer
  36584. */
  36585. get pointerX(): number;
  36586. set pointerX(value: number);
  36587. /**
  36588. * Gets or sets the current on-screen Y position of the pointer
  36589. */
  36590. get pointerY(): number;
  36591. set pointerY(value: number);
  36592. /**
  36593. * Gets the cached material (ie. the latest rendered one)
  36594. * @returns the cached material
  36595. */
  36596. getCachedMaterial(): Nullable<Material>;
  36597. /**
  36598. * Gets the cached effect (ie. the latest rendered one)
  36599. * @returns the cached effect
  36600. */
  36601. getCachedEffect(): Nullable<Effect>;
  36602. /**
  36603. * Gets the cached visibility state (ie. the latest rendered one)
  36604. * @returns the cached visibility state
  36605. */
  36606. getCachedVisibility(): Nullable<number>;
  36607. /**
  36608. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36609. * @param material defines the current material
  36610. * @param effect defines the current effect
  36611. * @param visibility defines the current visibility state
  36612. * @returns true if one parameter is not cached
  36613. */
  36614. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36615. /**
  36616. * Gets the engine associated with the scene
  36617. * @returns an Engine
  36618. */
  36619. getEngine(): Engine;
  36620. /**
  36621. * Gets the total number of vertices rendered per frame
  36622. * @returns the total number of vertices rendered per frame
  36623. */
  36624. getTotalVertices(): number;
  36625. /**
  36626. * Gets the performance counter for total vertices
  36627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36628. */
  36629. get totalVerticesPerfCounter(): PerfCounter;
  36630. /**
  36631. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36632. * @returns the total number of active indices rendered per frame
  36633. */
  36634. getActiveIndices(): number;
  36635. /**
  36636. * Gets the performance counter for active indices
  36637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36638. */
  36639. get totalActiveIndicesPerfCounter(): PerfCounter;
  36640. /**
  36641. * Gets the total number of active particles rendered per frame
  36642. * @returns the total number of active particles rendered per frame
  36643. */
  36644. getActiveParticles(): number;
  36645. /**
  36646. * Gets the performance counter for active particles
  36647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36648. */
  36649. get activeParticlesPerfCounter(): PerfCounter;
  36650. /**
  36651. * Gets the total number of active bones rendered per frame
  36652. * @returns the total number of active bones rendered per frame
  36653. */
  36654. getActiveBones(): number;
  36655. /**
  36656. * Gets the performance counter for active bones
  36657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36658. */
  36659. get activeBonesPerfCounter(): PerfCounter;
  36660. /**
  36661. * Gets the array of active meshes
  36662. * @returns an array of AbstractMesh
  36663. */
  36664. getActiveMeshes(): SmartArray<AbstractMesh>;
  36665. /**
  36666. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36667. * @returns a number
  36668. */
  36669. getAnimationRatio(): number;
  36670. /**
  36671. * Gets an unique Id for the current render phase
  36672. * @returns a number
  36673. */
  36674. getRenderId(): number;
  36675. /**
  36676. * Gets an unique Id for the current frame
  36677. * @returns a number
  36678. */
  36679. getFrameId(): number;
  36680. /** Call this function if you want to manually increment the render Id*/
  36681. incrementRenderId(): void;
  36682. private _createUbo;
  36683. /**
  36684. * Use this method to simulate a pointer move on a mesh
  36685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36688. * @returns the current scene
  36689. */
  36690. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36691. /**
  36692. * Use this method to simulate a pointer down on a mesh
  36693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36696. * @returns the current scene
  36697. */
  36698. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36699. /**
  36700. * Use this method to simulate a pointer up on a mesh
  36701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36704. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36705. * @returns the current scene
  36706. */
  36707. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36708. /**
  36709. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36710. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36711. * @returns true if the pointer was captured
  36712. */
  36713. isPointerCaptured(pointerId?: number): boolean;
  36714. /**
  36715. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36716. * @param attachUp defines if you want to attach events to pointerup
  36717. * @param attachDown defines if you want to attach events to pointerdown
  36718. * @param attachMove defines if you want to attach events to pointermove
  36719. */
  36720. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36721. /** Detaches all event handlers*/
  36722. detachControl(): void;
  36723. /**
  36724. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36725. * Delay loaded resources are not taking in account
  36726. * @return true if all required resources are ready
  36727. */
  36728. isReady(): boolean;
  36729. /** Resets all cached information relative to material (including effect and visibility) */
  36730. resetCachedMaterial(): void;
  36731. /**
  36732. * Registers a function to be called before every frame render
  36733. * @param func defines the function to register
  36734. */
  36735. registerBeforeRender(func: () => void): void;
  36736. /**
  36737. * Unregisters a function called before every frame render
  36738. * @param func defines the function to unregister
  36739. */
  36740. unregisterBeforeRender(func: () => void): void;
  36741. /**
  36742. * Registers a function to be called after every frame render
  36743. * @param func defines the function to register
  36744. */
  36745. registerAfterRender(func: () => void): void;
  36746. /**
  36747. * Unregisters a function called after every frame render
  36748. * @param func defines the function to unregister
  36749. */
  36750. unregisterAfterRender(func: () => void): void;
  36751. private _executeOnceBeforeRender;
  36752. /**
  36753. * The provided function will run before render once and will be disposed afterwards.
  36754. * A timeout delay can be provided so that the function will be executed in N ms.
  36755. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36756. * @param func The function to be executed.
  36757. * @param timeout optional delay in ms
  36758. */
  36759. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36760. /** @hidden */
  36761. _addPendingData(data: any): void;
  36762. /** @hidden */
  36763. _removePendingData(data: any): void;
  36764. /**
  36765. * Returns the number of items waiting to be loaded
  36766. * @returns the number of items waiting to be loaded
  36767. */
  36768. getWaitingItemsCount(): number;
  36769. /**
  36770. * Returns a boolean indicating if the scene is still loading data
  36771. */
  36772. get isLoading(): boolean;
  36773. /**
  36774. * Registers a function to be executed when the scene is ready
  36775. * @param {Function} func - the function to be executed
  36776. */
  36777. executeWhenReady(func: () => void): void;
  36778. /**
  36779. * Returns a promise that resolves when the scene is ready
  36780. * @returns A promise that resolves when the scene is ready
  36781. */
  36782. whenReadyAsync(): Promise<void>;
  36783. /** @hidden */
  36784. _checkIsReady(): void;
  36785. /**
  36786. * Gets all animatable attached to the scene
  36787. */
  36788. get animatables(): Animatable[];
  36789. /**
  36790. * Resets the last animation time frame.
  36791. * Useful to override when animations start running when loading a scene for the first time.
  36792. */
  36793. resetLastAnimationTimeFrame(): void;
  36794. /**
  36795. * Gets the current view matrix
  36796. * @returns a Matrix
  36797. */
  36798. getViewMatrix(): Matrix;
  36799. /**
  36800. * Gets the current projection matrix
  36801. * @returns a Matrix
  36802. */
  36803. getProjectionMatrix(): Matrix;
  36804. /**
  36805. * Gets the current transform matrix
  36806. * @returns a Matrix made of View * Projection
  36807. */
  36808. getTransformMatrix(): Matrix;
  36809. /**
  36810. * Sets the current transform matrix
  36811. * @param viewL defines the View matrix to use
  36812. * @param projectionL defines the Projection matrix to use
  36813. * @param viewR defines the right View matrix to use (if provided)
  36814. * @param projectionR defines the right Projection matrix to use (if provided)
  36815. */
  36816. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36817. /**
  36818. * Gets the uniform buffer used to store scene data
  36819. * @returns a UniformBuffer
  36820. */
  36821. getSceneUniformBuffer(): UniformBuffer;
  36822. /**
  36823. * Gets an unique (relatively to the current scene) Id
  36824. * @returns an unique number for the scene
  36825. */
  36826. getUniqueId(): number;
  36827. /**
  36828. * Add a mesh to the list of scene's meshes
  36829. * @param newMesh defines the mesh to add
  36830. * @param recursive if all child meshes should also be added to the scene
  36831. */
  36832. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36833. /**
  36834. * Remove a mesh for the list of scene's meshes
  36835. * @param toRemove defines the mesh to remove
  36836. * @param recursive if all child meshes should also be removed from the scene
  36837. * @returns the index where the mesh was in the mesh list
  36838. */
  36839. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36840. /**
  36841. * Add a transform node to the list of scene's transform nodes
  36842. * @param newTransformNode defines the transform node to add
  36843. */
  36844. addTransformNode(newTransformNode: TransformNode): void;
  36845. /**
  36846. * Remove a transform node for the list of scene's transform nodes
  36847. * @param toRemove defines the transform node to remove
  36848. * @returns the index where the transform node was in the transform node list
  36849. */
  36850. removeTransformNode(toRemove: TransformNode): number;
  36851. /**
  36852. * Remove a skeleton for the list of scene's skeletons
  36853. * @param toRemove defines the skeleton to remove
  36854. * @returns the index where the skeleton was in the skeleton list
  36855. */
  36856. removeSkeleton(toRemove: Skeleton): number;
  36857. /**
  36858. * Remove a morph target for the list of scene's morph targets
  36859. * @param toRemove defines the morph target to remove
  36860. * @returns the index where the morph target was in the morph target list
  36861. */
  36862. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36863. /**
  36864. * Remove a light for the list of scene's lights
  36865. * @param toRemove defines the light to remove
  36866. * @returns the index where the light was in the light list
  36867. */
  36868. removeLight(toRemove: Light): number;
  36869. /**
  36870. * Remove a camera for the list of scene's cameras
  36871. * @param toRemove defines the camera to remove
  36872. * @returns the index where the camera was in the camera list
  36873. */
  36874. removeCamera(toRemove: Camera): number;
  36875. /**
  36876. * Remove a particle system for the list of scene's particle systems
  36877. * @param toRemove defines the particle system to remove
  36878. * @returns the index where the particle system was in the particle system list
  36879. */
  36880. removeParticleSystem(toRemove: IParticleSystem): number;
  36881. /**
  36882. * Remove a animation for the list of scene's animations
  36883. * @param toRemove defines the animation to remove
  36884. * @returns the index where the animation was in the animation list
  36885. */
  36886. removeAnimation(toRemove: Animation): number;
  36887. /**
  36888. * Will stop the animation of the given target
  36889. * @param target - the target
  36890. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36891. * @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)
  36892. */
  36893. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36894. /**
  36895. * Removes the given animation group from this scene.
  36896. * @param toRemove The animation group to remove
  36897. * @returns The index of the removed animation group
  36898. */
  36899. removeAnimationGroup(toRemove: AnimationGroup): number;
  36900. /**
  36901. * Removes the given multi-material from this scene.
  36902. * @param toRemove The multi-material to remove
  36903. * @returns The index of the removed multi-material
  36904. */
  36905. removeMultiMaterial(toRemove: MultiMaterial): number;
  36906. /**
  36907. * Removes the given material from this scene.
  36908. * @param toRemove The material to remove
  36909. * @returns The index of the removed material
  36910. */
  36911. removeMaterial(toRemove: Material): number;
  36912. /**
  36913. * Removes the given action manager from this scene.
  36914. * @param toRemove The action manager to remove
  36915. * @returns The index of the removed action manager
  36916. */
  36917. removeActionManager(toRemove: AbstractActionManager): number;
  36918. /**
  36919. * Removes the given texture from this scene.
  36920. * @param toRemove The texture to remove
  36921. * @returns The index of the removed texture
  36922. */
  36923. removeTexture(toRemove: BaseTexture): number;
  36924. /**
  36925. * Adds the given light to this scene
  36926. * @param newLight The light to add
  36927. */
  36928. addLight(newLight: Light): void;
  36929. /**
  36930. * Sorts the list list based on light priorities
  36931. */
  36932. sortLightsByPriority(): void;
  36933. /**
  36934. * Adds the given camera to this scene
  36935. * @param newCamera The camera to add
  36936. */
  36937. addCamera(newCamera: Camera): void;
  36938. /**
  36939. * Adds the given skeleton to this scene
  36940. * @param newSkeleton The skeleton to add
  36941. */
  36942. addSkeleton(newSkeleton: Skeleton): void;
  36943. /**
  36944. * Adds the given particle system to this scene
  36945. * @param newParticleSystem The particle system to add
  36946. */
  36947. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36948. /**
  36949. * Adds the given animation to this scene
  36950. * @param newAnimation The animation to add
  36951. */
  36952. addAnimation(newAnimation: Animation): void;
  36953. /**
  36954. * Adds the given animation group to this scene.
  36955. * @param newAnimationGroup The animation group to add
  36956. */
  36957. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36958. /**
  36959. * Adds the given multi-material to this scene
  36960. * @param newMultiMaterial The multi-material to add
  36961. */
  36962. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36963. /**
  36964. * Adds the given material to this scene
  36965. * @param newMaterial The material to add
  36966. */
  36967. addMaterial(newMaterial: Material): void;
  36968. /**
  36969. * Adds the given morph target to this scene
  36970. * @param newMorphTargetManager The morph target to add
  36971. */
  36972. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36973. /**
  36974. * Adds the given geometry to this scene
  36975. * @param newGeometry The geometry to add
  36976. */
  36977. addGeometry(newGeometry: Geometry): void;
  36978. /**
  36979. * Adds the given action manager to this scene
  36980. * @param newActionManager The action manager to add
  36981. */
  36982. addActionManager(newActionManager: AbstractActionManager): void;
  36983. /**
  36984. * Adds the given texture to this scene.
  36985. * @param newTexture The texture to add
  36986. */
  36987. addTexture(newTexture: BaseTexture): void;
  36988. /**
  36989. * Switch active camera
  36990. * @param newCamera defines the new active camera
  36991. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36992. */
  36993. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36994. /**
  36995. * sets the active camera of the scene using its ID
  36996. * @param id defines the camera's ID
  36997. * @return the new active camera or null if none found.
  36998. */
  36999. setActiveCameraByID(id: string): Nullable<Camera>;
  37000. /**
  37001. * sets the active camera of the scene using its name
  37002. * @param name defines the camera's name
  37003. * @returns the new active camera or null if none found.
  37004. */
  37005. setActiveCameraByName(name: string): Nullable<Camera>;
  37006. /**
  37007. * get an animation group using its name
  37008. * @param name defines the material's name
  37009. * @return the animation group or null if none found.
  37010. */
  37011. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37012. /**
  37013. * Get a material using its unique id
  37014. * @param uniqueId defines the material's unique id
  37015. * @return the material or null if none found.
  37016. */
  37017. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37018. /**
  37019. * get a material using its id
  37020. * @param id defines the material's ID
  37021. * @return the material or null if none found.
  37022. */
  37023. getMaterialByID(id: string): Nullable<Material>;
  37024. /**
  37025. * Gets a the last added material using a given id
  37026. * @param id defines the material's ID
  37027. * @return the last material with the given id or null if none found.
  37028. */
  37029. getLastMaterialByID(id: string): Nullable<Material>;
  37030. /**
  37031. * Gets a material using its name
  37032. * @param name defines the material's name
  37033. * @return the material or null if none found.
  37034. */
  37035. getMaterialByName(name: string): Nullable<Material>;
  37036. /**
  37037. * Get a texture using its unique id
  37038. * @param uniqueId defines the texture's unique id
  37039. * @return the texture or null if none found.
  37040. */
  37041. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37042. /**
  37043. * Gets a camera using its id
  37044. * @param id defines the id to look for
  37045. * @returns the camera or null if not found
  37046. */
  37047. getCameraByID(id: string): Nullable<Camera>;
  37048. /**
  37049. * Gets a camera using its unique id
  37050. * @param uniqueId defines the unique id to look for
  37051. * @returns the camera or null if not found
  37052. */
  37053. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37054. /**
  37055. * Gets a camera using its name
  37056. * @param name defines the camera's name
  37057. * @return the camera or null if none found.
  37058. */
  37059. getCameraByName(name: string): Nullable<Camera>;
  37060. /**
  37061. * Gets a bone using its id
  37062. * @param id defines the bone's id
  37063. * @return the bone or null if not found
  37064. */
  37065. getBoneByID(id: string): Nullable<Bone>;
  37066. /**
  37067. * Gets a bone using its id
  37068. * @param name defines the bone's name
  37069. * @return the bone or null if not found
  37070. */
  37071. getBoneByName(name: string): Nullable<Bone>;
  37072. /**
  37073. * Gets a light node using its name
  37074. * @param name defines the the light's name
  37075. * @return the light or null if none found.
  37076. */
  37077. getLightByName(name: string): Nullable<Light>;
  37078. /**
  37079. * Gets a light node using its id
  37080. * @param id defines the light's id
  37081. * @return the light or null if none found.
  37082. */
  37083. getLightByID(id: string): Nullable<Light>;
  37084. /**
  37085. * Gets a light node using its scene-generated unique ID
  37086. * @param uniqueId defines the light's unique id
  37087. * @return the light or null if none found.
  37088. */
  37089. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37090. /**
  37091. * Gets a particle system by id
  37092. * @param id defines the particle system id
  37093. * @return the corresponding system or null if none found
  37094. */
  37095. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37096. /**
  37097. * Gets a geometry using its ID
  37098. * @param id defines the geometry's id
  37099. * @return the geometry or null if none found.
  37100. */
  37101. getGeometryByID(id: string): Nullable<Geometry>;
  37102. private _getGeometryByUniqueID;
  37103. /**
  37104. * Add a new geometry to this scene
  37105. * @param geometry defines the geometry to be added to the scene.
  37106. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37107. * @return a boolean defining if the geometry was added or not
  37108. */
  37109. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37110. /**
  37111. * Removes an existing geometry
  37112. * @param geometry defines the geometry to be removed from the scene
  37113. * @return a boolean defining if the geometry was removed or not
  37114. */
  37115. removeGeometry(geometry: Geometry): boolean;
  37116. /**
  37117. * Gets the list of geometries attached to the scene
  37118. * @returns an array of Geometry
  37119. */
  37120. getGeometries(): Geometry[];
  37121. /**
  37122. * Gets the first added mesh found of a given ID
  37123. * @param id defines the id to search for
  37124. * @return the mesh found or null if not found at all
  37125. */
  37126. getMeshByID(id: string): Nullable<AbstractMesh>;
  37127. /**
  37128. * Gets a list of meshes using their id
  37129. * @param id defines the id to search for
  37130. * @returns a list of meshes
  37131. */
  37132. getMeshesByID(id: string): Array<AbstractMesh>;
  37133. /**
  37134. * Gets the first added transform node found of a given ID
  37135. * @param id defines the id to search for
  37136. * @return the found transform node or null if not found at all.
  37137. */
  37138. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37139. /**
  37140. * Gets a transform node with its auto-generated unique id
  37141. * @param uniqueId efines the unique id to search for
  37142. * @return the found transform node or null if not found at all.
  37143. */
  37144. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37145. /**
  37146. * Gets a list of transform nodes using their id
  37147. * @param id defines the id to search for
  37148. * @returns a list of transform nodes
  37149. */
  37150. getTransformNodesByID(id: string): Array<TransformNode>;
  37151. /**
  37152. * Gets a mesh with its auto-generated unique id
  37153. * @param uniqueId defines the unique id to search for
  37154. * @return the found mesh or null if not found at all.
  37155. */
  37156. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37157. /**
  37158. * Gets a the last added mesh using a given id
  37159. * @param id defines the id to search for
  37160. * @return the found mesh or null if not found at all.
  37161. */
  37162. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37163. /**
  37164. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37165. * @param id defines the id to search for
  37166. * @return the found node or null if not found at all
  37167. */
  37168. getLastEntryByID(id: string): Nullable<Node>;
  37169. /**
  37170. * Gets a node (Mesh, Camera, Light) using a given id
  37171. * @param id defines the id to search for
  37172. * @return the found node or null if not found at all
  37173. */
  37174. getNodeByID(id: string): Nullable<Node>;
  37175. /**
  37176. * Gets a node (Mesh, Camera, Light) using a given name
  37177. * @param name defines the name to search for
  37178. * @return the found node or null if not found at all.
  37179. */
  37180. getNodeByName(name: string): Nullable<Node>;
  37181. /**
  37182. * Gets a mesh using a given name
  37183. * @param name defines the name to search for
  37184. * @return the found mesh or null if not found at all.
  37185. */
  37186. getMeshByName(name: string): Nullable<AbstractMesh>;
  37187. /**
  37188. * Gets a transform node using a given name
  37189. * @param name defines the name to search for
  37190. * @return the found transform node or null if not found at all.
  37191. */
  37192. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37193. /**
  37194. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37195. * @param id defines the id to search for
  37196. * @return the found skeleton or null if not found at all.
  37197. */
  37198. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37199. /**
  37200. * Gets a skeleton using a given auto generated unique id
  37201. * @param uniqueId defines the unique id to search for
  37202. * @return the found skeleton or null if not found at all.
  37203. */
  37204. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37205. /**
  37206. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37207. * @param id defines the id to search for
  37208. * @return the found skeleton or null if not found at all.
  37209. */
  37210. getSkeletonById(id: string): Nullable<Skeleton>;
  37211. /**
  37212. * Gets a skeleton using a given name
  37213. * @param name defines the name to search for
  37214. * @return the found skeleton or null if not found at all.
  37215. */
  37216. getSkeletonByName(name: string): Nullable<Skeleton>;
  37217. /**
  37218. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37219. * @param id defines the id to search for
  37220. * @return the found morph target manager or null if not found at all.
  37221. */
  37222. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37223. /**
  37224. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37225. * @param id defines the id to search for
  37226. * @return the found morph target or null if not found at all.
  37227. */
  37228. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37229. /**
  37230. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37231. * @param name defines the name to search for
  37232. * @return the found morph target or null if not found at all.
  37233. */
  37234. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37235. /**
  37236. * Gets a boolean indicating if the given mesh is active
  37237. * @param mesh defines the mesh to look for
  37238. * @returns true if the mesh is in the active list
  37239. */
  37240. isActiveMesh(mesh: AbstractMesh): boolean;
  37241. /**
  37242. * Return a unique id as a string which can serve as an identifier for the scene
  37243. */
  37244. get uid(): string;
  37245. /**
  37246. * Add an externaly attached data from its key.
  37247. * This method call will fail and return false, if such key already exists.
  37248. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37249. * @param key the unique key that identifies the data
  37250. * @param data the data object to associate to the key for this Engine instance
  37251. * @return true if no such key were already present and the data was added successfully, false otherwise
  37252. */
  37253. addExternalData<T>(key: string, data: T): boolean;
  37254. /**
  37255. * Get an externaly attached data from its key
  37256. * @param key the unique key that identifies the data
  37257. * @return the associated data, if present (can be null), or undefined if not present
  37258. */
  37259. getExternalData<T>(key: string): Nullable<T>;
  37260. /**
  37261. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37262. * @param key the unique key that identifies the data
  37263. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37264. * @return the associated data, can be null if the factory returned null.
  37265. */
  37266. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37267. /**
  37268. * Remove an externaly attached data from the Engine instance
  37269. * @param key the unique key that identifies the data
  37270. * @return true if the data was successfully removed, false if it doesn't exist
  37271. */
  37272. removeExternalData(key: string): boolean;
  37273. private _evaluateSubMesh;
  37274. /**
  37275. * Clear the processed materials smart array preventing retention point in material dispose.
  37276. */
  37277. freeProcessedMaterials(): void;
  37278. private _preventFreeActiveMeshesAndRenderingGroups;
  37279. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37280. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37281. * when disposing several meshes in a row or a hierarchy of meshes.
  37282. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37283. */
  37284. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37285. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37286. /**
  37287. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37288. */
  37289. freeActiveMeshes(): void;
  37290. /**
  37291. * Clear the info related to rendering groups preventing retention points during dispose.
  37292. */
  37293. freeRenderingGroups(): void;
  37294. /** @hidden */
  37295. _isInIntermediateRendering(): boolean;
  37296. /**
  37297. * Lambda returning the list of potentially active meshes.
  37298. */
  37299. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37300. /**
  37301. * Lambda returning the list of potentially active sub meshes.
  37302. */
  37303. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37304. /**
  37305. * Lambda returning the list of potentially intersecting sub meshes.
  37306. */
  37307. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37308. /**
  37309. * Lambda returning the list of potentially colliding sub meshes.
  37310. */
  37311. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37312. private _activeMeshesFrozen;
  37313. private _skipEvaluateActiveMeshesCompletely;
  37314. /**
  37315. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37316. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37317. * @returns the current scene
  37318. */
  37319. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37320. /**
  37321. * Use this function to restart evaluating active meshes on every frame
  37322. * @returns the current scene
  37323. */
  37324. unfreezeActiveMeshes(): Scene;
  37325. private _evaluateActiveMeshes;
  37326. private _activeMesh;
  37327. /**
  37328. * Update the transform matrix to update from the current active camera
  37329. * @param force defines a boolean used to force the update even if cache is up to date
  37330. */
  37331. updateTransformMatrix(force?: boolean): void;
  37332. private _bindFrameBuffer;
  37333. /** @hidden */
  37334. _allowPostProcessClearColor: boolean;
  37335. /** @hidden */
  37336. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37337. private _processSubCameras;
  37338. private _checkIntersections;
  37339. /** @hidden */
  37340. _advancePhysicsEngineStep(step: number): void;
  37341. /**
  37342. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37343. */
  37344. getDeterministicFrameTime: () => number;
  37345. /** @hidden */
  37346. _animate(): void;
  37347. /** Execute all animations (for a frame) */
  37348. animate(): void;
  37349. /**
  37350. * Render the scene
  37351. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37352. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37353. */
  37354. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37355. /**
  37356. * Freeze all materials
  37357. * A frozen material will not be updatable but should be faster to render
  37358. */
  37359. freezeMaterials(): void;
  37360. /**
  37361. * Unfreeze all materials
  37362. * A frozen material will not be updatable but should be faster to render
  37363. */
  37364. unfreezeMaterials(): void;
  37365. /**
  37366. * Releases all held ressources
  37367. */
  37368. dispose(): void;
  37369. /**
  37370. * Gets if the scene is already disposed
  37371. */
  37372. get isDisposed(): boolean;
  37373. /**
  37374. * Call this function to reduce memory footprint of the scene.
  37375. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37376. */
  37377. clearCachedVertexData(): void;
  37378. /**
  37379. * This function will remove the local cached buffer data from texture.
  37380. * It will save memory but will prevent the texture from being rebuilt
  37381. */
  37382. cleanCachedTextureBuffer(): void;
  37383. /**
  37384. * Get the world extend vectors with an optional filter
  37385. *
  37386. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37387. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37388. */
  37389. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37390. min: Vector3;
  37391. max: Vector3;
  37392. };
  37393. /**
  37394. * Creates a ray that can be used to pick in the scene
  37395. * @param x defines the x coordinate of the origin (on-screen)
  37396. * @param y defines the y coordinate of the origin (on-screen)
  37397. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37398. * @param camera defines the camera to use for the picking
  37399. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37400. * @returns a Ray
  37401. */
  37402. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37403. /**
  37404. * Creates a ray that can be used to pick in the scene
  37405. * @param x defines the x coordinate of the origin (on-screen)
  37406. * @param y defines the y coordinate of the origin (on-screen)
  37407. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37408. * @param result defines the ray where to store the picking ray
  37409. * @param camera defines the camera to use for the picking
  37410. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37411. * @returns the current scene
  37412. */
  37413. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37414. /**
  37415. * Creates a ray that can be used to pick in the scene
  37416. * @param x defines the x coordinate of the origin (on-screen)
  37417. * @param y defines the y coordinate of the origin (on-screen)
  37418. * @param camera defines the camera to use for the picking
  37419. * @returns a Ray
  37420. */
  37421. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37422. /**
  37423. * Creates a ray that can be used to pick in the scene
  37424. * @param x defines the x coordinate of the origin (on-screen)
  37425. * @param y defines the y coordinate of the origin (on-screen)
  37426. * @param result defines the ray where to store the picking ray
  37427. * @param camera defines the camera to use for the picking
  37428. * @returns the current scene
  37429. */
  37430. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37431. /** Launch a ray to try to pick a mesh in the scene
  37432. * @param x position on screen
  37433. * @param y position on screen
  37434. * @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
  37435. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37436. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37438. * @returns a PickingInfo
  37439. */
  37440. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37441. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37442. * @param x position on screen
  37443. * @param y position on screen
  37444. * @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
  37445. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37446. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37447. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37448. */
  37449. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37450. /** Use the given ray to pick a mesh in the scene
  37451. * @param ray The ray to use to pick meshes
  37452. * @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
  37453. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37454. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37455. * @returns a PickingInfo
  37456. */
  37457. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37458. /**
  37459. * Launch a ray to try to pick a mesh in the scene
  37460. * @param x X position on screen
  37461. * @param y Y position on screen
  37462. * @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
  37463. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37464. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37465. * @returns an array of PickingInfo
  37466. */
  37467. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37468. /**
  37469. * Launch a ray to try to pick a mesh in the scene
  37470. * @param ray Ray to use
  37471. * @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
  37472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37473. * @returns an array of PickingInfo
  37474. */
  37475. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37476. /**
  37477. * Force the value of meshUnderPointer
  37478. * @param mesh defines the mesh to use
  37479. */
  37480. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37481. /**
  37482. * Gets the mesh under the pointer
  37483. * @returns a Mesh or null if no mesh is under the pointer
  37484. */
  37485. getPointerOverMesh(): Nullable<AbstractMesh>;
  37486. /** @hidden */
  37487. _rebuildGeometries(): void;
  37488. /** @hidden */
  37489. _rebuildTextures(): void;
  37490. private _getByTags;
  37491. /**
  37492. * Get a list of meshes by tags
  37493. * @param tagsQuery defines the tags query to use
  37494. * @param forEach defines a predicate used to filter results
  37495. * @returns an array of Mesh
  37496. */
  37497. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37498. /**
  37499. * Get a list of cameras by tags
  37500. * @param tagsQuery defines the tags query to use
  37501. * @param forEach defines a predicate used to filter results
  37502. * @returns an array of Camera
  37503. */
  37504. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37505. /**
  37506. * Get a list of lights by tags
  37507. * @param tagsQuery defines the tags query to use
  37508. * @param forEach defines a predicate used to filter results
  37509. * @returns an array of Light
  37510. */
  37511. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37512. /**
  37513. * Get a list of materials by tags
  37514. * @param tagsQuery defines the tags query to use
  37515. * @param forEach defines a predicate used to filter results
  37516. * @returns an array of Material
  37517. */
  37518. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37519. /**
  37520. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37521. * This allowed control for front to back rendering or reversly depending of the special needs.
  37522. *
  37523. * @param renderingGroupId The rendering group id corresponding to its index
  37524. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37525. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37526. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37527. */
  37528. 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;
  37529. /**
  37530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37531. *
  37532. * @param renderingGroupId The rendering group id corresponding to its index
  37533. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37534. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37535. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37536. */
  37537. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37538. /**
  37539. * Gets the current auto clear configuration for one rendering group of the rendering
  37540. * manager.
  37541. * @param index the rendering group index to get the information for
  37542. * @returns The auto clear setup for the requested rendering group
  37543. */
  37544. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37545. private _blockMaterialDirtyMechanism;
  37546. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37547. get blockMaterialDirtyMechanism(): boolean;
  37548. set blockMaterialDirtyMechanism(value: boolean);
  37549. /**
  37550. * Will flag all materials as dirty to trigger new shader compilation
  37551. * @param flag defines the flag used to specify which material part must be marked as dirty
  37552. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37553. */
  37554. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37555. /** @hidden */
  37556. _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;
  37557. /** @hidden */
  37558. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37559. /** @hidden */
  37560. _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;
  37561. /** @hidden */
  37562. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37563. /** @hidden */
  37564. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37565. /** @hidden */
  37566. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37567. }
  37568. }
  37569. declare module BABYLON {
  37570. /**
  37571. * Set of assets to keep when moving a scene into an asset container.
  37572. */
  37573. export class KeepAssets extends AbstractScene {
  37574. }
  37575. /**
  37576. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37577. */
  37578. export class InstantiatedEntries {
  37579. /**
  37580. * List of new root nodes (eg. nodes with no parent)
  37581. */
  37582. rootNodes: TransformNode[];
  37583. /**
  37584. * List of new skeletons
  37585. */
  37586. skeletons: Skeleton[];
  37587. /**
  37588. * List of new animation groups
  37589. */
  37590. animationGroups: AnimationGroup[];
  37591. }
  37592. /**
  37593. * Container with a set of assets that can be added or removed from a scene.
  37594. */
  37595. export class AssetContainer extends AbstractScene {
  37596. private _wasAddedToScene;
  37597. /**
  37598. * The scene the AssetContainer belongs to.
  37599. */
  37600. scene: Scene;
  37601. /**
  37602. * Instantiates an AssetContainer.
  37603. * @param scene The scene the AssetContainer belongs to.
  37604. */
  37605. constructor(scene: Scene);
  37606. /**
  37607. * Instantiate or clone all meshes and add the new ones to the scene.
  37608. * Skeletons and animation groups will all be cloned
  37609. * @param nameFunction defines an optional function used to get new names for clones
  37610. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37611. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37612. */
  37613. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37614. /**
  37615. * Adds all the assets from the container to the scene.
  37616. */
  37617. addAllToScene(): void;
  37618. /**
  37619. * Removes all the assets in the container from the scene
  37620. */
  37621. removeAllFromScene(): void;
  37622. /**
  37623. * Disposes all the assets in the container
  37624. */
  37625. dispose(): void;
  37626. private _moveAssets;
  37627. /**
  37628. * Removes all the assets contained in the scene and adds them to the container.
  37629. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37630. */
  37631. moveAllFromScene(keepAssets?: KeepAssets): void;
  37632. /**
  37633. * 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.
  37634. * @returns the root mesh
  37635. */
  37636. createRootMesh(): Mesh;
  37637. /**
  37638. * Merge animations (direct and animation groups) from this asset container into a scene
  37639. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37640. * @param animatables set of animatables to retarget to a node from the scene
  37641. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37642. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37643. */
  37644. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. /**
  37649. * Defines how the parser contract is defined.
  37650. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37651. */
  37652. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37653. /**
  37654. * Defines how the individual parser contract is defined.
  37655. * These parser can parse an individual asset
  37656. */
  37657. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37658. /**
  37659. * Base class of the scene acting as a container for the different elements composing a scene.
  37660. * This class is dynamically extended by the different components of the scene increasing
  37661. * flexibility and reducing coupling
  37662. */
  37663. export abstract class AbstractScene {
  37664. /**
  37665. * Stores the list of available parsers in the application.
  37666. */
  37667. private static _BabylonFileParsers;
  37668. /**
  37669. * Stores the list of available individual parsers in the application.
  37670. */
  37671. private static _IndividualBabylonFileParsers;
  37672. /**
  37673. * Adds a parser in the list of available ones
  37674. * @param name Defines the name of the parser
  37675. * @param parser Defines the parser to add
  37676. */
  37677. static AddParser(name: string, parser: BabylonFileParser): void;
  37678. /**
  37679. * Gets a general parser from the list of avaialble ones
  37680. * @param name Defines the name of the parser
  37681. * @returns the requested parser or null
  37682. */
  37683. static GetParser(name: string): Nullable<BabylonFileParser>;
  37684. /**
  37685. * Adds n individual parser in the list of available ones
  37686. * @param name Defines the name of the parser
  37687. * @param parser Defines the parser to add
  37688. */
  37689. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37690. /**
  37691. * Gets an individual parser from the list of avaialble ones
  37692. * @param name Defines the name of the parser
  37693. * @returns the requested parser or null
  37694. */
  37695. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37696. /**
  37697. * Parser json data and populate both a scene and its associated container object
  37698. * @param jsonData Defines the data to parse
  37699. * @param scene Defines the scene to parse the data for
  37700. * @param container Defines the container attached to the parsing sequence
  37701. * @param rootUrl Defines the root url of the data
  37702. */
  37703. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37704. /**
  37705. * Gets the list of root nodes (ie. nodes with no parent)
  37706. */
  37707. rootNodes: Node[];
  37708. /** All of the cameras added to this scene
  37709. * @see http://doc.babylonjs.com/babylon101/cameras
  37710. */
  37711. cameras: Camera[];
  37712. /**
  37713. * All of the lights added to this scene
  37714. * @see http://doc.babylonjs.com/babylon101/lights
  37715. */
  37716. lights: Light[];
  37717. /**
  37718. * All of the (abstract) meshes added to this scene
  37719. */
  37720. meshes: AbstractMesh[];
  37721. /**
  37722. * The list of skeletons added to the scene
  37723. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37724. */
  37725. skeletons: Skeleton[];
  37726. /**
  37727. * All of the particle systems added to this scene
  37728. * @see http://doc.babylonjs.com/babylon101/particles
  37729. */
  37730. particleSystems: IParticleSystem[];
  37731. /**
  37732. * Gets a list of Animations associated with the scene
  37733. */
  37734. animations: Animation[];
  37735. /**
  37736. * All of the animation groups added to this scene
  37737. * @see http://doc.babylonjs.com/how_to/group
  37738. */
  37739. animationGroups: AnimationGroup[];
  37740. /**
  37741. * All of the multi-materials added to this scene
  37742. * @see http://doc.babylonjs.com/how_to/multi_materials
  37743. */
  37744. multiMaterials: MultiMaterial[];
  37745. /**
  37746. * All of the materials added to this scene
  37747. * In the context of a Scene, it is not supposed to be modified manually.
  37748. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37749. * Note also that the order of the Material within the array is not significant and might change.
  37750. * @see http://doc.babylonjs.com/babylon101/materials
  37751. */
  37752. materials: Material[];
  37753. /**
  37754. * The list of morph target managers added to the scene
  37755. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37756. */
  37757. morphTargetManagers: MorphTargetManager[];
  37758. /**
  37759. * The list of geometries used in the scene.
  37760. */
  37761. geometries: Geometry[];
  37762. /**
  37763. * All of the tranform nodes added to this scene
  37764. * In the context of a Scene, it is not supposed to be modified manually.
  37765. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37766. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37767. * @see http://doc.babylonjs.com/how_to/transformnode
  37768. */
  37769. transformNodes: TransformNode[];
  37770. /**
  37771. * ActionManagers available on the scene.
  37772. */
  37773. actionManagers: AbstractActionManager[];
  37774. /**
  37775. * Textures to keep.
  37776. */
  37777. textures: BaseTexture[];
  37778. /**
  37779. * Environment texture for the scene
  37780. */
  37781. environmentTexture: Nullable<BaseTexture>;
  37782. /**
  37783. * @returns all meshes, lights, cameras, transformNodes and bones
  37784. */
  37785. getNodes(): Array<Node>;
  37786. }
  37787. }
  37788. declare module BABYLON {
  37789. /**
  37790. * Interface used to define options for Sound class
  37791. */
  37792. export interface ISoundOptions {
  37793. /**
  37794. * Does the sound autoplay once loaded.
  37795. */
  37796. autoplay?: boolean;
  37797. /**
  37798. * Does the sound loop after it finishes playing once.
  37799. */
  37800. loop?: boolean;
  37801. /**
  37802. * Sound's volume
  37803. */
  37804. volume?: number;
  37805. /**
  37806. * Is it a spatial sound?
  37807. */
  37808. spatialSound?: boolean;
  37809. /**
  37810. * Maximum distance to hear that sound
  37811. */
  37812. maxDistance?: number;
  37813. /**
  37814. * Uses user defined attenuation function
  37815. */
  37816. useCustomAttenuation?: boolean;
  37817. /**
  37818. * Define the roll off factor of spatial sounds.
  37819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37820. */
  37821. rolloffFactor?: number;
  37822. /**
  37823. * Define the reference distance the sound should be heard perfectly.
  37824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37825. */
  37826. refDistance?: number;
  37827. /**
  37828. * Define the distance attenuation model the sound will follow.
  37829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37830. */
  37831. distanceModel?: string;
  37832. /**
  37833. * Defines the playback speed (1 by default)
  37834. */
  37835. playbackRate?: number;
  37836. /**
  37837. * Defines if the sound is from a streaming source
  37838. */
  37839. streaming?: boolean;
  37840. /**
  37841. * Defines an optional length (in seconds) inside the sound file
  37842. */
  37843. length?: number;
  37844. /**
  37845. * Defines an optional offset (in seconds) inside the sound file
  37846. */
  37847. offset?: number;
  37848. /**
  37849. * If true, URLs will not be required to state the audio file codec to use.
  37850. */
  37851. skipCodecCheck?: boolean;
  37852. }
  37853. /**
  37854. * Defines a sound that can be played in the application.
  37855. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37857. */
  37858. export class Sound {
  37859. /**
  37860. * The name of the sound in the scene.
  37861. */
  37862. name: string;
  37863. /**
  37864. * Does the sound autoplay once loaded.
  37865. */
  37866. autoplay: boolean;
  37867. /**
  37868. * Does the sound loop after it finishes playing once.
  37869. */
  37870. loop: boolean;
  37871. /**
  37872. * Does the sound use a custom attenuation curve to simulate the falloff
  37873. * happening when the source gets further away from the camera.
  37874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37875. */
  37876. useCustomAttenuation: boolean;
  37877. /**
  37878. * The sound track id this sound belongs to.
  37879. */
  37880. soundTrackId: number;
  37881. /**
  37882. * Is this sound currently played.
  37883. */
  37884. isPlaying: boolean;
  37885. /**
  37886. * Is this sound currently paused.
  37887. */
  37888. isPaused: boolean;
  37889. /**
  37890. * Does this sound enables spatial sound.
  37891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37892. */
  37893. spatialSound: boolean;
  37894. /**
  37895. * Define the reference distance the sound should be heard perfectly.
  37896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37897. */
  37898. refDistance: number;
  37899. /**
  37900. * Define the roll off factor of spatial sounds.
  37901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37902. */
  37903. rolloffFactor: number;
  37904. /**
  37905. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37907. */
  37908. maxDistance: number;
  37909. /**
  37910. * Define the distance attenuation model the sound will follow.
  37911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37912. */
  37913. distanceModel: string;
  37914. /**
  37915. * @hidden
  37916. * Back Compat
  37917. **/
  37918. onended: () => any;
  37919. /**
  37920. * Observable event when the current playing sound finishes.
  37921. */
  37922. onEndedObservable: Observable<Sound>;
  37923. private _panningModel;
  37924. private _playbackRate;
  37925. private _streaming;
  37926. private _startTime;
  37927. private _startOffset;
  37928. private _position;
  37929. /** @hidden */
  37930. _positionInEmitterSpace: boolean;
  37931. private _localDirection;
  37932. private _volume;
  37933. private _isReadyToPlay;
  37934. private _isDirectional;
  37935. private _readyToPlayCallback;
  37936. private _audioBuffer;
  37937. private _soundSource;
  37938. private _streamingSource;
  37939. private _soundPanner;
  37940. private _soundGain;
  37941. private _inputAudioNode;
  37942. private _outputAudioNode;
  37943. private _coneInnerAngle;
  37944. private _coneOuterAngle;
  37945. private _coneOuterGain;
  37946. private _scene;
  37947. private _connectedTransformNode;
  37948. private _customAttenuationFunction;
  37949. private _registerFunc;
  37950. private _isOutputConnected;
  37951. private _htmlAudioElement;
  37952. private _urlType;
  37953. private _length?;
  37954. private _offset?;
  37955. /** @hidden */
  37956. static _SceneComponentInitialization: (scene: Scene) => void;
  37957. /**
  37958. * Create a sound and attach it to a scene
  37959. * @param name Name of your sound
  37960. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37961. * @param scene defines the scene the sound belongs to
  37962. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37963. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37964. */
  37965. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37966. /**
  37967. * Release the sound and its associated resources
  37968. */
  37969. dispose(): void;
  37970. /**
  37971. * Gets if the sounds is ready to be played or not.
  37972. * @returns true if ready, otherwise false
  37973. */
  37974. isReady(): boolean;
  37975. private _soundLoaded;
  37976. /**
  37977. * Sets the data of the sound from an audiobuffer
  37978. * @param audioBuffer The audioBuffer containing the data
  37979. */
  37980. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37981. /**
  37982. * Updates the current sounds options such as maxdistance, loop...
  37983. * @param options A JSON object containing values named as the object properties
  37984. */
  37985. updateOptions(options: ISoundOptions): void;
  37986. private _createSpatialParameters;
  37987. private _updateSpatialParameters;
  37988. /**
  37989. * Switch the panning model to HRTF:
  37990. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37992. */
  37993. switchPanningModelToHRTF(): void;
  37994. /**
  37995. * Switch the panning model to Equal Power:
  37996. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37998. */
  37999. switchPanningModelToEqualPower(): void;
  38000. private _switchPanningModel;
  38001. /**
  38002. * Connect this sound to a sound track audio node like gain...
  38003. * @param soundTrackAudioNode the sound track audio node to connect to
  38004. */
  38005. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38006. /**
  38007. * Transform this sound into a directional source
  38008. * @param coneInnerAngle Size of the inner cone in degree
  38009. * @param coneOuterAngle Size of the outer cone in degree
  38010. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38011. */
  38012. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38013. /**
  38014. * Gets or sets the inner angle for the directional cone.
  38015. */
  38016. get directionalConeInnerAngle(): number;
  38017. /**
  38018. * Gets or sets the inner angle for the directional cone.
  38019. */
  38020. set directionalConeInnerAngle(value: number);
  38021. /**
  38022. * Gets or sets the outer angle for the directional cone.
  38023. */
  38024. get directionalConeOuterAngle(): number;
  38025. /**
  38026. * Gets or sets the outer angle for the directional cone.
  38027. */
  38028. set directionalConeOuterAngle(value: number);
  38029. /**
  38030. * Sets the position of the emitter if spatial sound is enabled
  38031. * @param newPosition Defines the new posisiton
  38032. */
  38033. setPosition(newPosition: Vector3): void;
  38034. /**
  38035. * Sets the local direction of the emitter if spatial sound is enabled
  38036. * @param newLocalDirection Defines the new local direction
  38037. */
  38038. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38039. private _updateDirection;
  38040. /** @hidden */
  38041. updateDistanceFromListener(): void;
  38042. /**
  38043. * Sets a new custom attenuation function for the sound.
  38044. * @param callback Defines the function used for the attenuation
  38045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38046. */
  38047. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38048. /**
  38049. * Play the sound
  38050. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38051. * @param offset (optional) Start the sound at a specific time in seconds
  38052. * @param length (optional) Sound duration (in seconds)
  38053. */
  38054. play(time?: number, offset?: number, length?: number): void;
  38055. private _onended;
  38056. /**
  38057. * Stop the sound
  38058. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38059. */
  38060. stop(time?: number): void;
  38061. /**
  38062. * Put the sound in pause
  38063. */
  38064. pause(): void;
  38065. /**
  38066. * Sets a dedicated volume for this sounds
  38067. * @param newVolume Define the new volume of the sound
  38068. * @param time Define time for gradual change to new volume
  38069. */
  38070. setVolume(newVolume: number, time?: number): void;
  38071. /**
  38072. * Set the sound play back rate
  38073. * @param newPlaybackRate Define the playback rate the sound should be played at
  38074. */
  38075. setPlaybackRate(newPlaybackRate: number): void;
  38076. /**
  38077. * Gets the volume of the sound.
  38078. * @returns the volume of the sound
  38079. */
  38080. getVolume(): number;
  38081. /**
  38082. * Attach the sound to a dedicated mesh
  38083. * @param transformNode The transform node to connect the sound with
  38084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38085. */
  38086. attachToMesh(transformNode: TransformNode): void;
  38087. /**
  38088. * Detach the sound from the previously attached mesh
  38089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38090. */
  38091. detachFromMesh(): void;
  38092. private _onRegisterAfterWorldMatrixUpdate;
  38093. /**
  38094. * Clone the current sound in the scene.
  38095. * @returns the new sound clone
  38096. */
  38097. clone(): Nullable<Sound>;
  38098. /**
  38099. * Gets the current underlying audio buffer containing the data
  38100. * @returns the audio buffer
  38101. */
  38102. getAudioBuffer(): Nullable<AudioBuffer>;
  38103. /**
  38104. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38105. * @returns the source node
  38106. */
  38107. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38108. /**
  38109. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38110. * @returns the gain node
  38111. */
  38112. getSoundGain(): Nullable<GainNode>;
  38113. /**
  38114. * Serializes the Sound in a JSON representation
  38115. * @returns the JSON representation of the sound
  38116. */
  38117. serialize(): any;
  38118. /**
  38119. * Parse a JSON representation of a sound to innstantiate in a given scene
  38120. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38121. * @param scene Define the scene the new parsed sound should be created in
  38122. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38123. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38124. * @returns the newly parsed sound
  38125. */
  38126. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38127. }
  38128. }
  38129. declare module BABYLON {
  38130. /**
  38131. * This defines an action helpful to play a defined sound on a triggered action.
  38132. */
  38133. export class PlaySoundAction extends Action {
  38134. private _sound;
  38135. /**
  38136. * Instantiate the action
  38137. * @param triggerOptions defines the trigger options
  38138. * @param sound defines the sound to play
  38139. * @param condition defines the trigger related conditions
  38140. */
  38141. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38142. /** @hidden */
  38143. _prepare(): void;
  38144. /**
  38145. * Execute the action and play the sound.
  38146. */
  38147. execute(): void;
  38148. /**
  38149. * Serializes the actions and its related information.
  38150. * @param parent defines the object to serialize in
  38151. * @returns the serialized object
  38152. */
  38153. serialize(parent: any): any;
  38154. }
  38155. /**
  38156. * This defines an action helpful to stop a defined sound on a triggered action.
  38157. */
  38158. export class StopSoundAction extends Action {
  38159. private _sound;
  38160. /**
  38161. * Instantiate the action
  38162. * @param triggerOptions defines the trigger options
  38163. * @param sound defines the sound to stop
  38164. * @param condition defines the trigger related conditions
  38165. */
  38166. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38167. /** @hidden */
  38168. _prepare(): void;
  38169. /**
  38170. * Execute the action and stop the sound.
  38171. */
  38172. execute(): void;
  38173. /**
  38174. * Serializes the actions and its related information.
  38175. * @param parent defines the object to serialize in
  38176. * @returns the serialized object
  38177. */
  38178. serialize(parent: any): any;
  38179. }
  38180. }
  38181. declare module BABYLON {
  38182. /**
  38183. * This defines an action responsible to change the value of a property
  38184. * by interpolating between its current value and the newly set one once triggered.
  38185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38186. */
  38187. export class InterpolateValueAction extends Action {
  38188. /**
  38189. * Defines the path of the property where the value should be interpolated
  38190. */
  38191. propertyPath: string;
  38192. /**
  38193. * Defines the target value at the end of the interpolation.
  38194. */
  38195. value: any;
  38196. /**
  38197. * Defines the time it will take for the property to interpolate to the value.
  38198. */
  38199. duration: number;
  38200. /**
  38201. * Defines if the other scene animations should be stopped when the action has been triggered
  38202. */
  38203. stopOtherAnimations?: boolean;
  38204. /**
  38205. * Defines a callback raised once the interpolation animation has been done.
  38206. */
  38207. onInterpolationDone?: () => void;
  38208. /**
  38209. * Observable triggered once the interpolation animation has been done.
  38210. */
  38211. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38212. private _target;
  38213. private _effectiveTarget;
  38214. private _property;
  38215. /**
  38216. * Instantiate the action
  38217. * @param triggerOptions defines the trigger options
  38218. * @param target defines the object containing the value to interpolate
  38219. * @param propertyPath defines the path to the property in the target object
  38220. * @param value defines the target value at the end of the interpolation
  38221. * @param duration deines the time it will take for the property to interpolate to the value.
  38222. * @param condition defines the trigger related conditions
  38223. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38224. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38225. */
  38226. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38227. /** @hidden */
  38228. _prepare(): void;
  38229. /**
  38230. * Execute the action starts the value interpolation.
  38231. */
  38232. execute(): void;
  38233. /**
  38234. * Serializes the actions and its related information.
  38235. * @param parent defines the object to serialize in
  38236. * @returns the serialized object
  38237. */
  38238. serialize(parent: any): any;
  38239. }
  38240. }
  38241. declare module BABYLON {
  38242. /**
  38243. * Options allowed during the creation of a sound track.
  38244. */
  38245. export interface ISoundTrackOptions {
  38246. /**
  38247. * The volume the sound track should take during creation
  38248. */
  38249. volume?: number;
  38250. /**
  38251. * Define if the sound track is the main sound track of the scene
  38252. */
  38253. mainTrack?: boolean;
  38254. }
  38255. /**
  38256. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38257. * It will be also used in a future release to apply effects on a specific track.
  38258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38259. */
  38260. export class SoundTrack {
  38261. /**
  38262. * The unique identifier of the sound track in the scene.
  38263. */
  38264. id: number;
  38265. /**
  38266. * The list of sounds included in the sound track.
  38267. */
  38268. soundCollection: Array<Sound>;
  38269. private _outputAudioNode;
  38270. private _scene;
  38271. private _connectedAnalyser;
  38272. private _options;
  38273. private _isInitialized;
  38274. /**
  38275. * Creates a new sound track.
  38276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38277. * @param scene Define the scene the sound track belongs to
  38278. * @param options
  38279. */
  38280. constructor(scene: Scene, options?: ISoundTrackOptions);
  38281. private _initializeSoundTrackAudioGraph;
  38282. /**
  38283. * Release the sound track and its associated resources
  38284. */
  38285. dispose(): void;
  38286. /**
  38287. * Adds a sound to this sound track
  38288. * @param sound define the cound to add
  38289. * @ignoreNaming
  38290. */
  38291. AddSound(sound: Sound): void;
  38292. /**
  38293. * Removes a sound to this sound track
  38294. * @param sound define the cound to remove
  38295. * @ignoreNaming
  38296. */
  38297. RemoveSound(sound: Sound): void;
  38298. /**
  38299. * Set a global volume for the full sound track.
  38300. * @param newVolume Define the new volume of the sound track
  38301. */
  38302. setVolume(newVolume: number): void;
  38303. /**
  38304. * Switch the panning model to HRTF:
  38305. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38307. */
  38308. switchPanningModelToHRTF(): void;
  38309. /**
  38310. * Switch the panning model to Equal Power:
  38311. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38313. */
  38314. switchPanningModelToEqualPower(): void;
  38315. /**
  38316. * Connect the sound track to an audio analyser allowing some amazing
  38317. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38319. * @param analyser The analyser to connect to the engine
  38320. */
  38321. connectToAnalyser(analyser: Analyser): void;
  38322. }
  38323. }
  38324. declare module BABYLON {
  38325. interface AbstractScene {
  38326. /**
  38327. * The list of sounds used in the scene.
  38328. */
  38329. sounds: Nullable<Array<Sound>>;
  38330. }
  38331. interface Scene {
  38332. /**
  38333. * @hidden
  38334. * Backing field
  38335. */
  38336. _mainSoundTrack: SoundTrack;
  38337. /**
  38338. * The main sound track played by the scene.
  38339. * It cotains your primary collection of sounds.
  38340. */
  38341. mainSoundTrack: SoundTrack;
  38342. /**
  38343. * The list of sound tracks added to the scene
  38344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38345. */
  38346. soundTracks: Nullable<Array<SoundTrack>>;
  38347. /**
  38348. * Gets a sound using a given name
  38349. * @param name defines the name to search for
  38350. * @return the found sound or null if not found at all.
  38351. */
  38352. getSoundByName(name: string): Nullable<Sound>;
  38353. /**
  38354. * Gets or sets if audio support is enabled
  38355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38356. */
  38357. audioEnabled: boolean;
  38358. /**
  38359. * Gets or sets if audio will be output to headphones
  38360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38361. */
  38362. headphone: boolean;
  38363. /**
  38364. * Gets or sets custom audio listener position provider
  38365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38366. */
  38367. audioListenerPositionProvider: Nullable<() => Vector3>;
  38368. /**
  38369. * Gets or sets a refresh rate when using 3D audio positioning
  38370. */
  38371. audioPositioningRefreshRate: number;
  38372. }
  38373. /**
  38374. * Defines the sound scene component responsible to manage any sounds
  38375. * in a given scene.
  38376. */
  38377. export class AudioSceneComponent implements ISceneSerializableComponent {
  38378. /**
  38379. * The component name helpfull to identify the component in the list of scene components.
  38380. */
  38381. readonly name: string;
  38382. /**
  38383. * The scene the component belongs to.
  38384. */
  38385. scene: Scene;
  38386. private _audioEnabled;
  38387. /**
  38388. * Gets whether audio is enabled or not.
  38389. * Please use related enable/disable method to switch state.
  38390. */
  38391. get audioEnabled(): boolean;
  38392. private _headphone;
  38393. /**
  38394. * Gets whether audio is outputing to headphone or not.
  38395. * Please use the according Switch methods to change output.
  38396. */
  38397. get headphone(): boolean;
  38398. /**
  38399. * Gets or sets a refresh rate when using 3D audio positioning
  38400. */
  38401. audioPositioningRefreshRate: number;
  38402. private _audioListenerPositionProvider;
  38403. /**
  38404. * Gets the current audio listener position provider
  38405. */
  38406. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38407. /**
  38408. * Sets a custom listener position for all sounds in the scene
  38409. * By default, this is the position of the first active camera
  38410. */
  38411. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38412. /**
  38413. * Creates a new instance of the component for the given scene
  38414. * @param scene Defines the scene to register the component in
  38415. */
  38416. constructor(scene: Scene);
  38417. /**
  38418. * Registers the component in a given scene
  38419. */
  38420. register(): void;
  38421. /**
  38422. * Rebuilds the elements related to this component in case of
  38423. * context lost for instance.
  38424. */
  38425. rebuild(): void;
  38426. /**
  38427. * Serializes the component data to the specified json object
  38428. * @param serializationObject The object to serialize to
  38429. */
  38430. serialize(serializationObject: any): void;
  38431. /**
  38432. * Adds all the elements from the container to the scene
  38433. * @param container the container holding the elements
  38434. */
  38435. addFromContainer(container: AbstractScene): void;
  38436. /**
  38437. * Removes all the elements in the container from the scene
  38438. * @param container contains the elements to remove
  38439. * @param dispose if the removed element should be disposed (default: false)
  38440. */
  38441. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38442. /**
  38443. * Disposes the component and the associated ressources.
  38444. */
  38445. dispose(): void;
  38446. /**
  38447. * Disables audio in the associated scene.
  38448. */
  38449. disableAudio(): void;
  38450. /**
  38451. * Enables audio in the associated scene.
  38452. */
  38453. enableAudio(): void;
  38454. /**
  38455. * Switch audio to headphone output.
  38456. */
  38457. switchAudioModeForHeadphones(): void;
  38458. /**
  38459. * Switch audio to normal speakers.
  38460. */
  38461. switchAudioModeForNormalSpeakers(): void;
  38462. private _cachedCameraDirection;
  38463. private _cachedCameraPosition;
  38464. private _lastCheck;
  38465. private _afterRender;
  38466. }
  38467. }
  38468. declare module BABYLON {
  38469. /**
  38470. * Wraps one or more Sound objects and selects one with random weight for playback.
  38471. */
  38472. export class WeightedSound {
  38473. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38474. loop: boolean;
  38475. private _coneInnerAngle;
  38476. private _coneOuterAngle;
  38477. private _volume;
  38478. /** A Sound is currently playing. */
  38479. isPlaying: boolean;
  38480. /** A Sound is currently paused. */
  38481. isPaused: boolean;
  38482. private _sounds;
  38483. private _weights;
  38484. private _currentIndex?;
  38485. /**
  38486. * Creates a new WeightedSound from the list of sounds given.
  38487. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38488. * @param sounds Array of Sounds that will be selected from.
  38489. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38490. */
  38491. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38492. /**
  38493. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38494. */
  38495. get directionalConeInnerAngle(): number;
  38496. /**
  38497. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38498. */
  38499. set directionalConeInnerAngle(value: number);
  38500. /**
  38501. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38502. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38503. */
  38504. get directionalConeOuterAngle(): number;
  38505. /**
  38506. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38507. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38508. */
  38509. set directionalConeOuterAngle(value: number);
  38510. /**
  38511. * Playback volume.
  38512. */
  38513. get volume(): number;
  38514. /**
  38515. * Playback volume.
  38516. */
  38517. set volume(value: number);
  38518. private _onended;
  38519. /**
  38520. * Suspend playback
  38521. */
  38522. pause(): void;
  38523. /**
  38524. * Stop playback
  38525. */
  38526. stop(): void;
  38527. /**
  38528. * Start playback.
  38529. * @param startOffset Position the clip head at a specific time in seconds.
  38530. */
  38531. play(startOffset?: number): void;
  38532. }
  38533. }
  38534. declare module BABYLON {
  38535. /**
  38536. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38537. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38538. */
  38539. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38540. /**
  38541. * Gets the name of the behavior.
  38542. */
  38543. get name(): string;
  38544. /**
  38545. * The easing function used by animations
  38546. */
  38547. static EasingFunction: BackEase;
  38548. /**
  38549. * The easing mode used by animations
  38550. */
  38551. static EasingMode: number;
  38552. /**
  38553. * The duration of the animation, in milliseconds
  38554. */
  38555. transitionDuration: number;
  38556. /**
  38557. * Length of the distance animated by the transition when lower radius is reached
  38558. */
  38559. lowerRadiusTransitionRange: number;
  38560. /**
  38561. * Length of the distance animated by the transition when upper radius is reached
  38562. */
  38563. upperRadiusTransitionRange: number;
  38564. private _autoTransitionRange;
  38565. /**
  38566. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38567. */
  38568. get autoTransitionRange(): boolean;
  38569. /**
  38570. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38571. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38572. */
  38573. set autoTransitionRange(value: boolean);
  38574. private _attachedCamera;
  38575. private _onAfterCheckInputsObserver;
  38576. private _onMeshTargetChangedObserver;
  38577. /**
  38578. * Initializes the behavior.
  38579. */
  38580. init(): void;
  38581. /**
  38582. * Attaches the behavior to its arc rotate camera.
  38583. * @param camera Defines the camera to attach the behavior to
  38584. */
  38585. attach(camera: ArcRotateCamera): void;
  38586. /**
  38587. * Detaches the behavior from its current arc rotate camera.
  38588. */
  38589. detach(): void;
  38590. private _radiusIsAnimating;
  38591. private _radiusBounceTransition;
  38592. private _animatables;
  38593. private _cachedWheelPrecision;
  38594. /**
  38595. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38596. * @param radiusLimit The limit to check against.
  38597. * @return Bool to indicate if at limit.
  38598. */
  38599. private _isRadiusAtLimit;
  38600. /**
  38601. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38602. * @param radiusDelta The delta by which to animate to. Can be negative.
  38603. */
  38604. private _applyBoundRadiusAnimation;
  38605. /**
  38606. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38607. */
  38608. protected _clearAnimationLocks(): void;
  38609. /**
  38610. * Stops and removes all animations that have been applied to the camera
  38611. */
  38612. stopAllAnimations(): void;
  38613. }
  38614. }
  38615. declare module BABYLON {
  38616. /**
  38617. * 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.
  38618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38619. */
  38620. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38621. /**
  38622. * Gets the name of the behavior.
  38623. */
  38624. get name(): string;
  38625. private _mode;
  38626. private _radiusScale;
  38627. private _positionScale;
  38628. private _defaultElevation;
  38629. private _elevationReturnTime;
  38630. private _elevationReturnWaitTime;
  38631. private _zoomStopsAnimation;
  38632. private _framingTime;
  38633. /**
  38634. * The easing function used by animations
  38635. */
  38636. static EasingFunction: ExponentialEase;
  38637. /**
  38638. * The easing mode used by animations
  38639. */
  38640. static EasingMode: number;
  38641. /**
  38642. * Sets the current mode used by the behavior
  38643. */
  38644. set mode(mode: number);
  38645. /**
  38646. * Gets current mode used by the behavior.
  38647. */
  38648. get mode(): number;
  38649. /**
  38650. * Sets the scale applied to the radius (1 by default)
  38651. */
  38652. set radiusScale(radius: number);
  38653. /**
  38654. * Gets the scale applied to the radius
  38655. */
  38656. get radiusScale(): number;
  38657. /**
  38658. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38659. */
  38660. set positionScale(scale: number);
  38661. /**
  38662. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38663. */
  38664. get positionScale(): number;
  38665. /**
  38666. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38667. * behaviour is triggered, in radians.
  38668. */
  38669. set defaultElevation(elevation: number);
  38670. /**
  38671. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38672. * behaviour is triggered, in radians.
  38673. */
  38674. get defaultElevation(): number;
  38675. /**
  38676. * Sets the time (in milliseconds) taken to return to the default beta position.
  38677. * Negative value indicates camera should not return to default.
  38678. */
  38679. set elevationReturnTime(speed: number);
  38680. /**
  38681. * Gets the time (in milliseconds) taken to return to the default beta position.
  38682. * Negative value indicates camera should not return to default.
  38683. */
  38684. get elevationReturnTime(): number;
  38685. /**
  38686. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38687. */
  38688. set elevationReturnWaitTime(time: number);
  38689. /**
  38690. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38691. */
  38692. get elevationReturnWaitTime(): number;
  38693. /**
  38694. * Sets the flag that indicates if user zooming should stop animation.
  38695. */
  38696. set zoomStopsAnimation(flag: boolean);
  38697. /**
  38698. * Gets the flag that indicates if user zooming should stop animation.
  38699. */
  38700. get zoomStopsAnimation(): boolean;
  38701. /**
  38702. * Sets the transition time when framing the mesh, in milliseconds
  38703. */
  38704. set framingTime(time: number);
  38705. /**
  38706. * Gets the transition time when framing the mesh, in milliseconds
  38707. */
  38708. get framingTime(): number;
  38709. /**
  38710. * Define if the behavior should automatically change the configured
  38711. * camera limits and sensibilities.
  38712. */
  38713. autoCorrectCameraLimitsAndSensibility: boolean;
  38714. private _onPrePointerObservableObserver;
  38715. private _onAfterCheckInputsObserver;
  38716. private _onMeshTargetChangedObserver;
  38717. private _attachedCamera;
  38718. private _isPointerDown;
  38719. private _lastInteractionTime;
  38720. /**
  38721. * Initializes the behavior.
  38722. */
  38723. init(): void;
  38724. /**
  38725. * Attaches the behavior to its arc rotate camera.
  38726. * @param camera Defines the camera to attach the behavior to
  38727. */
  38728. attach(camera: ArcRotateCamera): void;
  38729. /**
  38730. * Detaches the behavior from its current arc rotate camera.
  38731. */
  38732. detach(): void;
  38733. private _animatables;
  38734. private _betaIsAnimating;
  38735. private _betaTransition;
  38736. private _radiusTransition;
  38737. private _vectorTransition;
  38738. /**
  38739. * Targets the given mesh and updates zoom level accordingly.
  38740. * @param mesh The mesh to target.
  38741. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38742. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38743. */
  38744. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38745. /**
  38746. * Targets the given mesh with its children and updates zoom level accordingly.
  38747. * @param mesh The mesh to target.
  38748. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38749. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38750. */
  38751. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38752. /**
  38753. * Targets the given meshes with their children and updates zoom level accordingly.
  38754. * @param meshes The mesh to target.
  38755. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38756. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38757. */
  38758. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38759. /**
  38760. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38761. * @param minimumWorld Determines the smaller position of the bounding box extend
  38762. * @param maximumWorld Determines the bigger position of the bounding box extend
  38763. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38764. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38765. */
  38766. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38767. /**
  38768. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38769. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38770. * frustum width.
  38771. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38772. * to fully enclose the mesh in the viewing frustum.
  38773. */
  38774. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38775. /**
  38776. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38777. * is automatically returned to its default position (expected to be above ground plane).
  38778. */
  38779. private _maintainCameraAboveGround;
  38780. /**
  38781. * Returns the frustum slope based on the canvas ratio and camera FOV
  38782. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38783. */
  38784. private _getFrustumSlope;
  38785. /**
  38786. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38787. */
  38788. private _clearAnimationLocks;
  38789. /**
  38790. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38791. */
  38792. private _applyUserInteraction;
  38793. /**
  38794. * Stops and removes all animations that have been applied to the camera
  38795. */
  38796. stopAllAnimations(): void;
  38797. /**
  38798. * Gets a value indicating if the user is moving the camera
  38799. */
  38800. get isUserIsMoving(): boolean;
  38801. /**
  38802. * The camera can move all the way towards the mesh.
  38803. */
  38804. static IgnoreBoundsSizeMode: number;
  38805. /**
  38806. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38807. */
  38808. static FitFrustumSidesMode: number;
  38809. }
  38810. }
  38811. declare module BABYLON {
  38812. /**
  38813. * Base class for Camera Pointer Inputs.
  38814. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38815. * for example usage.
  38816. */
  38817. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. abstract camera: Camera;
  38822. /**
  38823. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38824. */
  38825. protected _altKey: boolean;
  38826. protected _ctrlKey: boolean;
  38827. protected _metaKey: boolean;
  38828. protected _shiftKey: boolean;
  38829. /**
  38830. * Which mouse buttons were pressed at time of last mouse event.
  38831. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38832. */
  38833. protected _buttonsPressed: number;
  38834. /**
  38835. * Defines the buttons associated with the input to handle camera move.
  38836. */
  38837. buttons: number[];
  38838. /**
  38839. * Attach the input controls to a specific dom element to get the input from.
  38840. * @param element Defines the element the controls should be listened from
  38841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38842. */
  38843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38844. /**
  38845. * Detach the current controls from the specified dom element.
  38846. * @param element Defines the element to stop listening the inputs from
  38847. */
  38848. detachControl(element: Nullable<HTMLElement>): void;
  38849. /**
  38850. * Gets the class name of the current input.
  38851. * @returns the class name
  38852. */
  38853. getClassName(): string;
  38854. /**
  38855. * Get the friendly name associated with the input class.
  38856. * @returns the input friendly name
  38857. */
  38858. getSimpleName(): string;
  38859. /**
  38860. * Called on pointer POINTERDOUBLETAP event.
  38861. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38862. */
  38863. protected onDoubleTap(type: string): void;
  38864. /**
  38865. * Called on pointer POINTERMOVE event if only a single touch is active.
  38866. * Override this method to provide functionality.
  38867. */
  38868. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38869. /**
  38870. * Called on pointer POINTERMOVE event if multiple touches are active.
  38871. * Override this method to provide functionality.
  38872. */
  38873. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38874. /**
  38875. * Called on JS contextmenu event.
  38876. * Override this method to provide functionality.
  38877. */
  38878. protected onContextMenu(evt: PointerEvent): void;
  38879. /**
  38880. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38881. * press.
  38882. * Override this method to provide functionality.
  38883. */
  38884. protected onButtonDown(evt: PointerEvent): void;
  38885. /**
  38886. * Called each time a new POINTERUP event occurs. Ie, for each button
  38887. * release.
  38888. * Override this method to provide functionality.
  38889. */
  38890. protected onButtonUp(evt: PointerEvent): void;
  38891. /**
  38892. * Called when window becomes inactive.
  38893. * Override this method to provide functionality.
  38894. */
  38895. protected onLostFocus(): void;
  38896. private _pointerInput;
  38897. private _observer;
  38898. private _onLostFocus;
  38899. private pointA;
  38900. private pointB;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * Manage the pointers inputs to control an arc rotate camera.
  38906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38907. */
  38908. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38909. /**
  38910. * Defines the camera the input is attached to.
  38911. */
  38912. camera: ArcRotateCamera;
  38913. /**
  38914. * Gets the class name of the current input.
  38915. * @returns the class name
  38916. */
  38917. getClassName(): string;
  38918. /**
  38919. * Defines the buttons associated with the input to handle camera move.
  38920. */
  38921. buttons: number[];
  38922. /**
  38923. * Defines the pointer angular sensibility along the X axis or how fast is
  38924. * the camera rotating.
  38925. */
  38926. angularSensibilityX: number;
  38927. /**
  38928. * Defines the pointer angular sensibility along the Y axis or how fast is
  38929. * the camera rotating.
  38930. */
  38931. angularSensibilityY: number;
  38932. /**
  38933. * Defines the pointer pinch precision or how fast is the camera zooming.
  38934. */
  38935. pinchPrecision: number;
  38936. /**
  38937. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38938. * from 0.
  38939. * It defines the percentage of current camera.radius to use as delta when
  38940. * pinch zoom is used.
  38941. */
  38942. pinchDeltaPercentage: number;
  38943. /**
  38944. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38945. * that any object in the plane at the camera's target point will scale
  38946. * perfectly with finger motion.
  38947. * Overrides pinchDeltaPercentage and pinchPrecision.
  38948. */
  38949. useNaturalPinchZoom: boolean;
  38950. /**
  38951. * Defines the pointer panning sensibility or how fast is the camera moving.
  38952. */
  38953. panningSensibility: number;
  38954. /**
  38955. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38956. */
  38957. multiTouchPanning: boolean;
  38958. /**
  38959. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38960. * zoom (pinch) through multitouch.
  38961. */
  38962. multiTouchPanAndZoom: boolean;
  38963. /**
  38964. * Revers pinch action direction.
  38965. */
  38966. pinchInwards: boolean;
  38967. private _isPanClick;
  38968. private _twoFingerActivityCount;
  38969. private _isPinching;
  38970. /**
  38971. * Called on pointer POINTERMOVE event if only a single touch is active.
  38972. */
  38973. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38974. /**
  38975. * Called on pointer POINTERDOUBLETAP event.
  38976. */
  38977. protected onDoubleTap(type: string): void;
  38978. /**
  38979. * Called on pointer POINTERMOVE event if multiple touches are active.
  38980. */
  38981. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38982. /**
  38983. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38984. * press.
  38985. */
  38986. protected onButtonDown(evt: PointerEvent): void;
  38987. /**
  38988. * Called each time a new POINTERUP event occurs. Ie, for each button
  38989. * release.
  38990. */
  38991. protected onButtonUp(evt: PointerEvent): void;
  38992. /**
  38993. * Called when window becomes inactive.
  38994. */
  38995. protected onLostFocus(): void;
  38996. }
  38997. }
  38998. declare module BABYLON {
  38999. /**
  39000. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39002. */
  39003. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39004. /**
  39005. * Defines the camera the input is attached to.
  39006. */
  39007. camera: ArcRotateCamera;
  39008. /**
  39009. * Defines the list of key codes associated with the up action (increase alpha)
  39010. */
  39011. keysUp: number[];
  39012. /**
  39013. * Defines the list of key codes associated with the down action (decrease alpha)
  39014. */
  39015. keysDown: number[];
  39016. /**
  39017. * Defines the list of key codes associated with the left action (increase beta)
  39018. */
  39019. keysLeft: number[];
  39020. /**
  39021. * Defines the list of key codes associated with the right action (decrease beta)
  39022. */
  39023. keysRight: number[];
  39024. /**
  39025. * Defines the list of key codes associated with the reset action.
  39026. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39027. */
  39028. keysReset: number[];
  39029. /**
  39030. * Defines the panning sensibility of the inputs.
  39031. * (How fast is the camera panning)
  39032. */
  39033. panningSensibility: number;
  39034. /**
  39035. * Defines the zooming sensibility of the inputs.
  39036. * (How fast is the camera zooming)
  39037. */
  39038. zoomingSensibility: number;
  39039. /**
  39040. * Defines whether maintaining the alt key down switch the movement mode from
  39041. * orientation to zoom.
  39042. */
  39043. useAltToZoom: boolean;
  39044. /**
  39045. * Rotation speed of the camera
  39046. */
  39047. angularSpeed: number;
  39048. private _keys;
  39049. private _ctrlPressed;
  39050. private _altPressed;
  39051. private _onCanvasBlurObserver;
  39052. private _onKeyboardObserver;
  39053. private _engine;
  39054. private _scene;
  39055. /**
  39056. * Attach the input controls to a specific dom element to get the input from.
  39057. * @param element Defines the element the controls should be listened from
  39058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39059. */
  39060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39061. /**
  39062. * Detach the current controls from the specified dom element.
  39063. * @param element Defines the element to stop listening the inputs from
  39064. */
  39065. detachControl(element: Nullable<HTMLElement>): void;
  39066. /**
  39067. * Update the current camera state depending on the inputs that have been used this frame.
  39068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39069. */
  39070. checkInputs(): void;
  39071. /**
  39072. * Gets the class name of the current intput.
  39073. * @returns the class name
  39074. */
  39075. getClassName(): string;
  39076. /**
  39077. * Get the friendly name associated with the input class.
  39078. * @returns the input friendly name
  39079. */
  39080. getSimpleName(): string;
  39081. }
  39082. }
  39083. declare module BABYLON {
  39084. /**
  39085. * Manage the mouse wheel inputs to control an arc rotate camera.
  39086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39087. */
  39088. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39089. /**
  39090. * Defines the camera the input is attached to.
  39091. */
  39092. camera: ArcRotateCamera;
  39093. /**
  39094. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39095. */
  39096. wheelPrecision: number;
  39097. /**
  39098. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39099. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39100. */
  39101. wheelDeltaPercentage: number;
  39102. private _wheel;
  39103. private _observer;
  39104. private computeDeltaFromMouseWheelLegacyEvent;
  39105. /**
  39106. * Attach the input controls to a specific dom element to get the input from.
  39107. * @param element Defines the element the controls should be listened from
  39108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39109. */
  39110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39111. /**
  39112. * Detach the current controls from the specified dom element.
  39113. * @param element Defines the element to stop listening the inputs from
  39114. */
  39115. detachControl(element: Nullable<HTMLElement>): void;
  39116. /**
  39117. * Gets the class name of the current intput.
  39118. * @returns the class name
  39119. */
  39120. getClassName(): string;
  39121. /**
  39122. * Get the friendly name associated with the input class.
  39123. * @returns the input friendly name
  39124. */
  39125. getSimpleName(): string;
  39126. }
  39127. }
  39128. declare module BABYLON {
  39129. /**
  39130. * Default Inputs manager for the ArcRotateCamera.
  39131. * It groups all the default supported inputs for ease of use.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39135. /**
  39136. * Instantiates a new ArcRotateCameraInputsManager.
  39137. * @param camera Defines the camera the inputs belong to
  39138. */
  39139. constructor(camera: ArcRotateCamera);
  39140. /**
  39141. * Add mouse wheel input support to the input manager.
  39142. * @returns the current input manager
  39143. */
  39144. addMouseWheel(): ArcRotateCameraInputsManager;
  39145. /**
  39146. * Add pointers input support to the input manager.
  39147. * @returns the current input manager
  39148. */
  39149. addPointers(): ArcRotateCameraInputsManager;
  39150. /**
  39151. * Add keyboard input support to the input manager.
  39152. * @returns the current input manager
  39153. */
  39154. addKeyboard(): ArcRotateCameraInputsManager;
  39155. }
  39156. }
  39157. declare module BABYLON {
  39158. /**
  39159. * This represents an orbital type of camera.
  39160. *
  39161. * 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.
  39162. * 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.
  39163. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39164. */
  39165. export class ArcRotateCamera extends TargetCamera {
  39166. /**
  39167. * Defines the rotation angle of the camera along the longitudinal axis.
  39168. */
  39169. alpha: number;
  39170. /**
  39171. * Defines the rotation angle of the camera along the latitudinal axis.
  39172. */
  39173. beta: number;
  39174. /**
  39175. * Defines the radius of the camera from it s target point.
  39176. */
  39177. radius: number;
  39178. protected _target: Vector3;
  39179. protected _targetHost: Nullable<AbstractMesh>;
  39180. /**
  39181. * Defines the target point of the camera.
  39182. * The camera looks towards it form the radius distance.
  39183. */
  39184. get target(): Vector3;
  39185. set target(value: Vector3);
  39186. /**
  39187. * Define the current local position of the camera in the scene
  39188. */
  39189. get position(): Vector3;
  39190. set position(newPosition: Vector3);
  39191. protected _upVector: Vector3;
  39192. protected _upToYMatrix: Matrix;
  39193. protected _YToUpMatrix: Matrix;
  39194. /**
  39195. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39196. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39197. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39198. */
  39199. set upVector(vec: Vector3);
  39200. get upVector(): Vector3;
  39201. /**
  39202. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39203. */
  39204. setMatUp(): void;
  39205. /**
  39206. * Current inertia value on the longitudinal axis.
  39207. * The bigger this number the longer it will take for the camera to stop.
  39208. */
  39209. inertialAlphaOffset: number;
  39210. /**
  39211. * Current inertia value on the latitudinal axis.
  39212. * The bigger this number the longer it will take for the camera to stop.
  39213. */
  39214. inertialBetaOffset: number;
  39215. /**
  39216. * Current inertia value on the radius axis.
  39217. * The bigger this number the longer it will take for the camera to stop.
  39218. */
  39219. inertialRadiusOffset: number;
  39220. /**
  39221. * Minimum allowed angle on the longitudinal axis.
  39222. * This can help limiting how the Camera is able to move in the scene.
  39223. */
  39224. lowerAlphaLimit: Nullable<number>;
  39225. /**
  39226. * Maximum allowed angle on the longitudinal axis.
  39227. * This can help limiting how the Camera is able to move in the scene.
  39228. */
  39229. upperAlphaLimit: Nullable<number>;
  39230. /**
  39231. * Minimum allowed angle on the latitudinal axis.
  39232. * This can help limiting how the Camera is able to move in the scene.
  39233. */
  39234. lowerBetaLimit: number;
  39235. /**
  39236. * Maximum allowed angle on the latitudinal axis.
  39237. * This can help limiting how the Camera is able to move in the scene.
  39238. */
  39239. upperBetaLimit: number;
  39240. /**
  39241. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39242. * This can help limiting how the Camera is able to move in the scene.
  39243. */
  39244. lowerRadiusLimit: Nullable<number>;
  39245. /**
  39246. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39247. * This can help limiting how the Camera is able to move in the scene.
  39248. */
  39249. upperRadiusLimit: Nullable<number>;
  39250. /**
  39251. * Defines the current inertia value used during panning of the camera along the X axis.
  39252. */
  39253. inertialPanningX: number;
  39254. /**
  39255. * Defines the current inertia value used during panning of the camera along the Y axis.
  39256. */
  39257. inertialPanningY: number;
  39258. /**
  39259. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39260. * Basically if your fingers moves away from more than this distance you will be considered
  39261. * in pinch mode.
  39262. */
  39263. pinchToPanMaxDistance: number;
  39264. /**
  39265. * Defines the maximum distance the camera can pan.
  39266. * This could help keeping the cammera always in your scene.
  39267. */
  39268. panningDistanceLimit: Nullable<number>;
  39269. /**
  39270. * Defines the target of the camera before paning.
  39271. */
  39272. panningOriginTarget: Vector3;
  39273. /**
  39274. * Defines the value of the inertia used during panning.
  39275. * 0 would mean stop inertia and one would mean no decelleration at all.
  39276. */
  39277. panningInertia: number;
  39278. /**
  39279. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39280. */
  39281. get angularSensibilityX(): number;
  39282. set angularSensibilityX(value: number);
  39283. /**
  39284. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39285. */
  39286. get angularSensibilityY(): number;
  39287. set angularSensibilityY(value: number);
  39288. /**
  39289. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39290. */
  39291. get pinchPrecision(): number;
  39292. set pinchPrecision(value: number);
  39293. /**
  39294. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39295. * It will be used instead of pinchDeltaPrecision if different from 0.
  39296. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39297. */
  39298. get pinchDeltaPercentage(): number;
  39299. set pinchDeltaPercentage(value: number);
  39300. /**
  39301. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39302. * and pinch delta percentage.
  39303. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39304. * that any object in the plane at the camera's target point will scale
  39305. * perfectly with finger motion.
  39306. */
  39307. get useNaturalPinchZoom(): boolean;
  39308. set useNaturalPinchZoom(value: boolean);
  39309. /**
  39310. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39311. */
  39312. get panningSensibility(): number;
  39313. set panningSensibility(value: number);
  39314. /**
  39315. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39316. */
  39317. get keysUp(): number[];
  39318. set keysUp(value: number[]);
  39319. /**
  39320. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39321. */
  39322. get keysDown(): number[];
  39323. set keysDown(value: number[]);
  39324. /**
  39325. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39326. */
  39327. get keysLeft(): number[];
  39328. set keysLeft(value: number[]);
  39329. /**
  39330. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39331. */
  39332. get keysRight(): number[];
  39333. set keysRight(value: number[]);
  39334. /**
  39335. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39336. */
  39337. get wheelPrecision(): number;
  39338. set wheelPrecision(value: number);
  39339. /**
  39340. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39341. * It will be used instead of pinchDeltaPrecision if different from 0.
  39342. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39343. */
  39344. get wheelDeltaPercentage(): number;
  39345. set wheelDeltaPercentage(value: number);
  39346. /**
  39347. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39348. */
  39349. zoomOnFactor: number;
  39350. /**
  39351. * Defines a screen offset for the camera position.
  39352. */
  39353. targetScreenOffset: Vector2;
  39354. /**
  39355. * Allows the camera to be completely reversed.
  39356. * If false the camera can not arrive upside down.
  39357. */
  39358. allowUpsideDown: boolean;
  39359. /**
  39360. * Define if double tap/click is used to restore the previously saved state of the camera.
  39361. */
  39362. useInputToRestoreState: boolean;
  39363. /** @hidden */
  39364. _viewMatrix: Matrix;
  39365. /** @hidden */
  39366. _useCtrlForPanning: boolean;
  39367. /** @hidden */
  39368. _panningMouseButton: number;
  39369. /**
  39370. * Defines the input associated to the camera.
  39371. */
  39372. inputs: ArcRotateCameraInputsManager;
  39373. /** @hidden */
  39374. _reset: () => void;
  39375. /**
  39376. * Defines the allowed panning axis.
  39377. */
  39378. panningAxis: Vector3;
  39379. protected _localDirection: Vector3;
  39380. protected _transformedDirection: Vector3;
  39381. private _bouncingBehavior;
  39382. /**
  39383. * Gets the bouncing behavior of the camera if it has been enabled.
  39384. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39385. */
  39386. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39387. /**
  39388. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39389. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39390. */
  39391. get useBouncingBehavior(): boolean;
  39392. set useBouncingBehavior(value: boolean);
  39393. private _framingBehavior;
  39394. /**
  39395. * Gets the framing behavior of the camera if it has been enabled.
  39396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39397. */
  39398. get framingBehavior(): Nullable<FramingBehavior>;
  39399. /**
  39400. * Defines if the framing behavior of the camera is enabled on the camera.
  39401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39402. */
  39403. get useFramingBehavior(): boolean;
  39404. set useFramingBehavior(value: boolean);
  39405. private _autoRotationBehavior;
  39406. /**
  39407. * Gets the auto rotation behavior of the camera if it has been enabled.
  39408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39409. */
  39410. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39411. /**
  39412. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39414. */
  39415. get useAutoRotationBehavior(): boolean;
  39416. set useAutoRotationBehavior(value: boolean);
  39417. /**
  39418. * Observable triggered when the mesh target has been changed on the camera.
  39419. */
  39420. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39421. /**
  39422. * Event raised when the camera is colliding with a mesh.
  39423. */
  39424. onCollide: (collidedMesh: AbstractMesh) => void;
  39425. /**
  39426. * Defines whether the camera should check collision with the objects oh the scene.
  39427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39428. */
  39429. checkCollisions: boolean;
  39430. /**
  39431. * Defines the collision radius of the camera.
  39432. * This simulates a sphere around the camera.
  39433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39434. */
  39435. collisionRadius: Vector3;
  39436. protected _collider: Collider;
  39437. protected _previousPosition: Vector3;
  39438. protected _collisionVelocity: Vector3;
  39439. protected _newPosition: Vector3;
  39440. protected _previousAlpha: number;
  39441. protected _previousBeta: number;
  39442. protected _previousRadius: number;
  39443. protected _collisionTriggered: boolean;
  39444. protected _targetBoundingCenter: Nullable<Vector3>;
  39445. private _computationVector;
  39446. /**
  39447. * Instantiates a new ArcRotateCamera in a given scene
  39448. * @param name Defines the name of the camera
  39449. * @param alpha Defines the camera rotation along the logitudinal axis
  39450. * @param beta Defines the camera rotation along the latitudinal axis
  39451. * @param radius Defines the camera distance from its target
  39452. * @param target Defines the camera target
  39453. * @param scene Defines the scene the camera belongs to
  39454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39455. */
  39456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39457. /** @hidden */
  39458. _initCache(): void;
  39459. /** @hidden */
  39460. _updateCache(ignoreParentClass?: boolean): void;
  39461. protected _getTargetPosition(): Vector3;
  39462. private _storedAlpha;
  39463. private _storedBeta;
  39464. private _storedRadius;
  39465. private _storedTarget;
  39466. private _storedTargetScreenOffset;
  39467. /**
  39468. * Stores the current state of the camera (alpha, beta, radius and target)
  39469. * @returns the camera itself
  39470. */
  39471. storeState(): Camera;
  39472. /**
  39473. * @hidden
  39474. * Restored camera state. You must call storeState() first
  39475. */
  39476. _restoreStateValues(): boolean;
  39477. /** @hidden */
  39478. _isSynchronizedViewMatrix(): boolean;
  39479. /**
  39480. * Attached controls to the current camera.
  39481. * @param element Defines the element the controls should be listened from
  39482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39483. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39484. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39485. */
  39486. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39487. /**
  39488. * Detach the current controls from the camera.
  39489. * The camera will stop reacting to inputs.
  39490. * @param element Defines the element to stop listening the inputs from
  39491. */
  39492. detachControl(element: HTMLElement): void;
  39493. /** @hidden */
  39494. _checkInputs(): void;
  39495. protected _checkLimits(): void;
  39496. /**
  39497. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39498. */
  39499. rebuildAnglesAndRadius(): void;
  39500. /**
  39501. * Use a position to define the current camera related information like alpha, beta and radius
  39502. * @param position Defines the position to set the camera at
  39503. */
  39504. setPosition(position: Vector3): void;
  39505. /**
  39506. * Defines the target the camera should look at.
  39507. * This will automatically adapt alpha beta and radius to fit within the new target.
  39508. * @param target Defines the new target as a Vector or a mesh
  39509. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39510. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39511. */
  39512. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39513. /** @hidden */
  39514. _getViewMatrix(): Matrix;
  39515. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39516. /**
  39517. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39518. * @param meshes Defines the mesh to zoom on
  39519. * @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)
  39520. */
  39521. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39522. /**
  39523. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39524. * The target will be changed but the radius
  39525. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39526. * @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)
  39527. */
  39528. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39529. min: Vector3;
  39530. max: Vector3;
  39531. distance: number;
  39532. }, doNotUpdateMaxZ?: boolean): void;
  39533. /**
  39534. * @override
  39535. * Override Camera.createRigCamera
  39536. */
  39537. createRigCamera(name: string, cameraIndex: number): Camera;
  39538. /**
  39539. * @hidden
  39540. * @override
  39541. * Override Camera._updateRigCameras
  39542. */
  39543. _updateRigCameras(): void;
  39544. /**
  39545. * Destroy the camera and release the current resources hold by it.
  39546. */
  39547. dispose(): void;
  39548. /**
  39549. * Gets the current object class name.
  39550. * @return the class name
  39551. */
  39552. getClassName(): string;
  39553. }
  39554. }
  39555. declare module BABYLON {
  39556. /**
  39557. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39559. */
  39560. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39561. /**
  39562. * Gets the name of the behavior.
  39563. */
  39564. get name(): string;
  39565. private _zoomStopsAnimation;
  39566. private _idleRotationSpeed;
  39567. private _idleRotationWaitTime;
  39568. private _idleRotationSpinupTime;
  39569. /**
  39570. * Sets the flag that indicates if user zooming should stop animation.
  39571. */
  39572. set zoomStopsAnimation(flag: boolean);
  39573. /**
  39574. * Gets the flag that indicates if user zooming should stop animation.
  39575. */
  39576. get zoomStopsAnimation(): boolean;
  39577. /**
  39578. * Sets the default speed at which the camera rotates around the model.
  39579. */
  39580. set idleRotationSpeed(speed: number);
  39581. /**
  39582. * Gets the default speed at which the camera rotates around the model.
  39583. */
  39584. get idleRotationSpeed(): number;
  39585. /**
  39586. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39587. */
  39588. set idleRotationWaitTime(time: number);
  39589. /**
  39590. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39591. */
  39592. get idleRotationWaitTime(): number;
  39593. /**
  39594. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39595. */
  39596. set idleRotationSpinupTime(time: number);
  39597. /**
  39598. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39599. */
  39600. get idleRotationSpinupTime(): number;
  39601. /**
  39602. * Gets a value indicating if the camera is currently rotating because of this behavior
  39603. */
  39604. get rotationInProgress(): boolean;
  39605. private _onPrePointerObservableObserver;
  39606. private _onAfterCheckInputsObserver;
  39607. private _attachedCamera;
  39608. private _isPointerDown;
  39609. private _lastFrameTime;
  39610. private _lastInteractionTime;
  39611. private _cameraRotationSpeed;
  39612. /**
  39613. * Initializes the behavior.
  39614. */
  39615. init(): void;
  39616. /**
  39617. * Attaches the behavior to its arc rotate camera.
  39618. * @param camera Defines the camera to attach the behavior to
  39619. */
  39620. attach(camera: ArcRotateCamera): void;
  39621. /**
  39622. * Detaches the behavior from its current arc rotate camera.
  39623. */
  39624. detach(): void;
  39625. /**
  39626. * Returns true if user is scrolling.
  39627. * @return true if user is scrolling.
  39628. */
  39629. private _userIsZooming;
  39630. private _lastFrameRadius;
  39631. private _shouldAnimationStopForInteraction;
  39632. /**
  39633. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39634. */
  39635. private _applyUserInteraction;
  39636. private _userIsMoving;
  39637. }
  39638. }
  39639. declare module BABYLON {
  39640. /**
  39641. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39642. */
  39643. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39644. private ui;
  39645. /**
  39646. * The name of the behavior
  39647. */
  39648. name: string;
  39649. /**
  39650. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39651. */
  39652. distanceAwayFromFace: number;
  39653. /**
  39654. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39655. */
  39656. distanceAwayFromBottomOfFace: number;
  39657. private _faceVectors;
  39658. private _target;
  39659. private _scene;
  39660. private _onRenderObserver;
  39661. private _tmpMatrix;
  39662. private _tmpVector;
  39663. /**
  39664. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39665. * @param ui The transform node that should be attched to the mesh
  39666. */
  39667. constructor(ui: TransformNode);
  39668. /**
  39669. * Initializes the behavior
  39670. */
  39671. init(): void;
  39672. private _closestFace;
  39673. private _zeroVector;
  39674. private _lookAtTmpMatrix;
  39675. private _lookAtToRef;
  39676. /**
  39677. * Attaches the AttachToBoxBehavior to the passed in mesh
  39678. * @param target The mesh that the specified node will be attached to
  39679. */
  39680. attach(target: Mesh): void;
  39681. /**
  39682. * Detaches the behavior from the mesh
  39683. */
  39684. detach(): void;
  39685. }
  39686. }
  39687. declare module BABYLON {
  39688. /**
  39689. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39690. */
  39691. export class FadeInOutBehavior implements Behavior<Mesh> {
  39692. /**
  39693. * Time in milliseconds to delay before fading in (Default: 0)
  39694. */
  39695. delay: number;
  39696. /**
  39697. * Time in milliseconds for the mesh to fade in (Default: 300)
  39698. */
  39699. fadeInTime: number;
  39700. private _millisecondsPerFrame;
  39701. private _hovered;
  39702. private _hoverValue;
  39703. private _ownerNode;
  39704. /**
  39705. * Instatiates the FadeInOutBehavior
  39706. */
  39707. constructor();
  39708. /**
  39709. * The name of the behavior
  39710. */
  39711. get name(): string;
  39712. /**
  39713. * Initializes the behavior
  39714. */
  39715. init(): void;
  39716. /**
  39717. * Attaches the fade behavior on the passed in mesh
  39718. * @param ownerNode The mesh that will be faded in/out once attached
  39719. */
  39720. attach(ownerNode: Mesh): void;
  39721. /**
  39722. * Detaches the behavior from the mesh
  39723. */
  39724. detach(): void;
  39725. /**
  39726. * Triggers the mesh to begin fading in or out
  39727. * @param value if the object should fade in or out (true to fade in)
  39728. */
  39729. fadeIn(value: boolean): void;
  39730. private _update;
  39731. private _setAllVisibility;
  39732. }
  39733. }
  39734. declare module BABYLON {
  39735. /**
  39736. * Class containing a set of static utilities functions for managing Pivots
  39737. * @hidden
  39738. */
  39739. export class PivotTools {
  39740. private static _PivotCached;
  39741. private static _OldPivotPoint;
  39742. private static _PivotTranslation;
  39743. private static _PivotTmpVector;
  39744. /** @hidden */
  39745. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39746. /** @hidden */
  39747. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39748. }
  39749. }
  39750. declare module BABYLON {
  39751. /**
  39752. * Class containing static functions to help procedurally build meshes
  39753. */
  39754. export class PlaneBuilder {
  39755. /**
  39756. * Creates a plane mesh
  39757. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39758. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39759. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39761. * * 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
  39762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39763. * @param name defines the name of the mesh
  39764. * @param options defines the options used to create the mesh
  39765. * @param scene defines the hosting scene
  39766. * @returns the plane mesh
  39767. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39768. */
  39769. static CreatePlane(name: string, options: {
  39770. size?: number;
  39771. width?: number;
  39772. height?: number;
  39773. sideOrientation?: number;
  39774. frontUVs?: Vector4;
  39775. backUVs?: Vector4;
  39776. updatable?: boolean;
  39777. sourcePlane?: Plane;
  39778. }, scene?: Nullable<Scene>): Mesh;
  39779. }
  39780. }
  39781. declare module BABYLON {
  39782. /**
  39783. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39784. */
  39785. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39786. private static _AnyMouseID;
  39787. /**
  39788. * Abstract mesh the behavior is set on
  39789. */
  39790. attachedNode: AbstractMesh;
  39791. private _dragPlane;
  39792. private _scene;
  39793. private _pointerObserver;
  39794. private _beforeRenderObserver;
  39795. private static _planeScene;
  39796. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39797. /**
  39798. * 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)
  39799. */
  39800. maxDragAngle: number;
  39801. /**
  39802. * @hidden
  39803. */
  39804. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39805. /**
  39806. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39807. */
  39808. currentDraggingPointerID: number;
  39809. /**
  39810. * The last position where the pointer hit the drag plane in world space
  39811. */
  39812. lastDragPosition: Vector3;
  39813. /**
  39814. * If the behavior is currently in a dragging state
  39815. */
  39816. dragging: boolean;
  39817. /**
  39818. * 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)
  39819. */
  39820. dragDeltaRatio: number;
  39821. /**
  39822. * If the drag plane orientation should be updated during the dragging (Default: true)
  39823. */
  39824. updateDragPlane: boolean;
  39825. private _debugMode;
  39826. private _moving;
  39827. /**
  39828. * Fires each time the attached mesh is dragged with the pointer
  39829. * * delta between last drag position and current drag position in world space
  39830. * * dragDistance along the drag axis
  39831. * * dragPlaneNormal normal of the current drag plane used during the drag
  39832. * * dragPlanePoint in world space where the drag intersects the drag plane
  39833. */
  39834. onDragObservable: Observable<{
  39835. delta: Vector3;
  39836. dragPlanePoint: Vector3;
  39837. dragPlaneNormal: Vector3;
  39838. dragDistance: number;
  39839. pointerId: number;
  39840. }>;
  39841. /**
  39842. * Fires each time a drag begins (eg. mouse down on mesh)
  39843. */
  39844. onDragStartObservable: Observable<{
  39845. dragPlanePoint: Vector3;
  39846. pointerId: number;
  39847. }>;
  39848. /**
  39849. * Fires each time a drag ends (eg. mouse release after drag)
  39850. */
  39851. onDragEndObservable: Observable<{
  39852. dragPlanePoint: Vector3;
  39853. pointerId: number;
  39854. }>;
  39855. /**
  39856. * If the attached mesh should be moved when dragged
  39857. */
  39858. moveAttached: boolean;
  39859. /**
  39860. * If the drag behavior will react to drag events (Default: true)
  39861. */
  39862. enabled: boolean;
  39863. /**
  39864. * If pointer events should start and release the drag (Default: true)
  39865. */
  39866. startAndReleaseDragOnPointerEvents: boolean;
  39867. /**
  39868. * If camera controls should be detached during the drag
  39869. */
  39870. detachCameraControls: boolean;
  39871. /**
  39872. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39873. */
  39874. useObjectOrientationForDragging: boolean;
  39875. private _options;
  39876. /**
  39877. * Gets the options used by the behavior
  39878. */
  39879. get options(): {
  39880. dragAxis?: Vector3;
  39881. dragPlaneNormal?: Vector3;
  39882. };
  39883. /**
  39884. * Sets the options used by the behavior
  39885. */
  39886. set options(options: {
  39887. dragAxis?: Vector3;
  39888. dragPlaneNormal?: Vector3;
  39889. });
  39890. /**
  39891. * Creates a pointer drag behavior that can be attached to a mesh
  39892. * @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)
  39893. */
  39894. constructor(options?: {
  39895. dragAxis?: Vector3;
  39896. dragPlaneNormal?: Vector3;
  39897. });
  39898. /**
  39899. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39900. */
  39901. validateDrag: (targetPosition: Vector3) => boolean;
  39902. /**
  39903. * The name of the behavior
  39904. */
  39905. get name(): string;
  39906. /**
  39907. * Initializes the behavior
  39908. */
  39909. init(): void;
  39910. private _tmpVector;
  39911. private _alternatePickedPoint;
  39912. private _worldDragAxis;
  39913. private _targetPosition;
  39914. private _attachedElement;
  39915. /**
  39916. * Attaches the drag behavior the passed in mesh
  39917. * @param ownerNode The mesh that will be dragged around once attached
  39918. * @param predicate Predicate to use for pick filtering
  39919. */
  39920. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39921. /**
  39922. * Force relase the drag action by code.
  39923. */
  39924. releaseDrag(): void;
  39925. private _startDragRay;
  39926. private _lastPointerRay;
  39927. /**
  39928. * Simulates the start of a pointer drag event on the behavior
  39929. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39930. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39931. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39932. */
  39933. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39934. private _startDrag;
  39935. private _dragDelta;
  39936. private _moveDrag;
  39937. private _pickWithRayOnDragPlane;
  39938. private _pointA;
  39939. private _pointB;
  39940. private _pointC;
  39941. private _lineA;
  39942. private _lineB;
  39943. private _localAxis;
  39944. private _lookAt;
  39945. private _updateDragPlanePosition;
  39946. /**
  39947. * Detaches the behavior from the mesh
  39948. */
  39949. detach(): void;
  39950. }
  39951. }
  39952. declare module BABYLON {
  39953. /**
  39954. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39955. */
  39956. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39957. private _dragBehaviorA;
  39958. private _dragBehaviorB;
  39959. private _startDistance;
  39960. private _initialScale;
  39961. private _targetScale;
  39962. private _ownerNode;
  39963. private _sceneRenderObserver;
  39964. /**
  39965. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39966. */
  39967. constructor();
  39968. /**
  39969. * The name of the behavior
  39970. */
  39971. get name(): string;
  39972. /**
  39973. * Initializes the behavior
  39974. */
  39975. init(): void;
  39976. private _getCurrentDistance;
  39977. /**
  39978. * Attaches the scale behavior the passed in mesh
  39979. * @param ownerNode The mesh that will be scaled around once attached
  39980. */
  39981. attach(ownerNode: Mesh): void;
  39982. /**
  39983. * Detaches the behavior from the mesh
  39984. */
  39985. detach(): void;
  39986. }
  39987. }
  39988. declare module BABYLON {
  39989. /**
  39990. * 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
  39991. */
  39992. export class SixDofDragBehavior implements Behavior<Mesh> {
  39993. private static _virtualScene;
  39994. private _ownerNode;
  39995. private _sceneRenderObserver;
  39996. private _scene;
  39997. private _targetPosition;
  39998. private _virtualOriginMesh;
  39999. private _virtualDragMesh;
  40000. private _pointerObserver;
  40001. private _moving;
  40002. private _startingOrientation;
  40003. private _attachedElement;
  40004. /**
  40005. * 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)
  40006. */
  40007. private zDragFactor;
  40008. /**
  40009. * If the object should rotate to face the drag origin
  40010. */
  40011. rotateDraggedObject: boolean;
  40012. /**
  40013. * If the behavior is currently in a dragging state
  40014. */
  40015. dragging: boolean;
  40016. /**
  40017. * 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)
  40018. */
  40019. dragDeltaRatio: number;
  40020. /**
  40021. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40022. */
  40023. currentDraggingPointerID: number;
  40024. /**
  40025. * If camera controls should be detached during the drag
  40026. */
  40027. detachCameraControls: boolean;
  40028. /**
  40029. * Fires each time a drag starts
  40030. */
  40031. onDragStartObservable: Observable<{}>;
  40032. /**
  40033. * Fires each time a drag ends (eg. mouse release after drag)
  40034. */
  40035. onDragEndObservable: Observable<{}>;
  40036. /**
  40037. * 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
  40038. */
  40039. constructor();
  40040. /**
  40041. * The name of the behavior
  40042. */
  40043. get name(): string;
  40044. /**
  40045. * Initializes the behavior
  40046. */
  40047. init(): void;
  40048. /**
  40049. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40050. */
  40051. private get _pointerCamera();
  40052. /**
  40053. * Attaches the scale behavior the passed in mesh
  40054. * @param ownerNode The mesh that will be scaled around once attached
  40055. */
  40056. attach(ownerNode: Mesh): void;
  40057. /**
  40058. * Detaches the behavior from the mesh
  40059. */
  40060. detach(): void;
  40061. }
  40062. }
  40063. declare module BABYLON {
  40064. /**
  40065. * Class used to apply inverse kinematics to bones
  40066. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40067. */
  40068. export class BoneIKController {
  40069. private static _tmpVecs;
  40070. private static _tmpQuat;
  40071. private static _tmpMats;
  40072. /**
  40073. * Gets or sets the target mesh
  40074. */
  40075. targetMesh: AbstractMesh;
  40076. /** Gets or sets the mesh used as pole */
  40077. poleTargetMesh: AbstractMesh;
  40078. /**
  40079. * Gets or sets the bone used as pole
  40080. */
  40081. poleTargetBone: Nullable<Bone>;
  40082. /**
  40083. * Gets or sets the target position
  40084. */
  40085. targetPosition: Vector3;
  40086. /**
  40087. * Gets or sets the pole target position
  40088. */
  40089. poleTargetPosition: Vector3;
  40090. /**
  40091. * Gets or sets the pole target local offset
  40092. */
  40093. poleTargetLocalOffset: Vector3;
  40094. /**
  40095. * Gets or sets the pole angle
  40096. */
  40097. poleAngle: number;
  40098. /**
  40099. * Gets or sets the mesh associated with the controller
  40100. */
  40101. mesh: AbstractMesh;
  40102. /**
  40103. * 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)
  40104. */
  40105. slerpAmount: number;
  40106. private _bone1Quat;
  40107. private _bone1Mat;
  40108. private _bone2Ang;
  40109. private _bone1;
  40110. private _bone2;
  40111. private _bone1Length;
  40112. private _bone2Length;
  40113. private _maxAngle;
  40114. private _maxReach;
  40115. private _rightHandedSystem;
  40116. private _bendAxis;
  40117. private _slerping;
  40118. private _adjustRoll;
  40119. /**
  40120. * Gets or sets maximum allowed angle
  40121. */
  40122. get maxAngle(): number;
  40123. set maxAngle(value: number);
  40124. /**
  40125. * Creates a new BoneIKController
  40126. * @param mesh defines the mesh to control
  40127. * @param bone defines the bone to control
  40128. * @param options defines options to set up the controller
  40129. */
  40130. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40131. targetMesh?: AbstractMesh;
  40132. poleTargetMesh?: AbstractMesh;
  40133. poleTargetBone?: Bone;
  40134. poleTargetLocalOffset?: Vector3;
  40135. poleAngle?: number;
  40136. bendAxis?: Vector3;
  40137. maxAngle?: number;
  40138. slerpAmount?: number;
  40139. });
  40140. private _setMaxAngle;
  40141. /**
  40142. * Force the controller to update the bones
  40143. */
  40144. update(): void;
  40145. }
  40146. }
  40147. declare module BABYLON {
  40148. /**
  40149. * Class used to make a bone look toward a point in space
  40150. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40151. */
  40152. export class BoneLookController {
  40153. private static _tmpVecs;
  40154. private static _tmpQuat;
  40155. private static _tmpMats;
  40156. /**
  40157. * The target Vector3 that the bone will look at
  40158. */
  40159. target: Vector3;
  40160. /**
  40161. * The mesh that the bone is attached to
  40162. */
  40163. mesh: AbstractMesh;
  40164. /**
  40165. * The bone that will be looking to the target
  40166. */
  40167. bone: Bone;
  40168. /**
  40169. * The up axis of the coordinate system that is used when the bone is rotated
  40170. */
  40171. upAxis: Vector3;
  40172. /**
  40173. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40174. */
  40175. upAxisSpace: Space;
  40176. /**
  40177. * Used to make an adjustment to the yaw of the bone
  40178. */
  40179. adjustYaw: number;
  40180. /**
  40181. * Used to make an adjustment to the pitch of the bone
  40182. */
  40183. adjustPitch: number;
  40184. /**
  40185. * Used to make an adjustment to the roll of the bone
  40186. */
  40187. adjustRoll: number;
  40188. /**
  40189. * 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)
  40190. */
  40191. slerpAmount: number;
  40192. private _minYaw;
  40193. private _maxYaw;
  40194. private _minPitch;
  40195. private _maxPitch;
  40196. private _minYawSin;
  40197. private _minYawCos;
  40198. private _maxYawSin;
  40199. private _maxYawCos;
  40200. private _midYawConstraint;
  40201. private _minPitchTan;
  40202. private _maxPitchTan;
  40203. private _boneQuat;
  40204. private _slerping;
  40205. private _transformYawPitch;
  40206. private _transformYawPitchInv;
  40207. private _firstFrameSkipped;
  40208. private _yawRange;
  40209. private _fowardAxis;
  40210. /**
  40211. * Gets or sets the minimum yaw angle that the bone can look to
  40212. */
  40213. get minYaw(): number;
  40214. set minYaw(value: number);
  40215. /**
  40216. * Gets or sets the maximum yaw angle that the bone can look to
  40217. */
  40218. get maxYaw(): number;
  40219. set maxYaw(value: number);
  40220. /**
  40221. * Gets or sets the minimum pitch angle that the bone can look to
  40222. */
  40223. get minPitch(): number;
  40224. set minPitch(value: number);
  40225. /**
  40226. * Gets or sets the maximum pitch angle that the bone can look to
  40227. */
  40228. get maxPitch(): number;
  40229. set maxPitch(value: number);
  40230. /**
  40231. * Create a BoneLookController
  40232. * @param mesh the mesh that the bone belongs to
  40233. * @param bone the bone that will be looking to the target
  40234. * @param target the target Vector3 to look at
  40235. * @param options optional settings:
  40236. * * maxYaw: the maximum angle the bone will yaw to
  40237. * * minYaw: the minimum angle the bone will yaw to
  40238. * * maxPitch: the maximum angle the bone will pitch to
  40239. * * minPitch: the minimum angle the bone will yaw to
  40240. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40241. * * upAxis: the up axis of the coordinate system
  40242. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40243. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40244. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40245. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40246. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40247. * * adjustRoll: used to make an adjustment to the roll of the bone
  40248. **/
  40249. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40250. maxYaw?: number;
  40251. minYaw?: number;
  40252. maxPitch?: number;
  40253. minPitch?: number;
  40254. slerpAmount?: number;
  40255. upAxis?: Vector3;
  40256. upAxisSpace?: Space;
  40257. yawAxis?: Vector3;
  40258. pitchAxis?: Vector3;
  40259. adjustYaw?: number;
  40260. adjustPitch?: number;
  40261. adjustRoll?: number;
  40262. });
  40263. /**
  40264. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40265. */
  40266. update(): void;
  40267. private _getAngleDiff;
  40268. private _getAngleBetween;
  40269. private _isAngleBetween;
  40270. }
  40271. }
  40272. declare module BABYLON {
  40273. /**
  40274. * Manage the gamepad inputs to control an arc rotate camera.
  40275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40276. */
  40277. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40278. /**
  40279. * Defines the camera the input is attached to.
  40280. */
  40281. camera: ArcRotateCamera;
  40282. /**
  40283. * Defines the gamepad the input is gathering event from.
  40284. */
  40285. gamepad: Nullable<Gamepad>;
  40286. /**
  40287. * Defines the gamepad rotation sensiblity.
  40288. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40289. */
  40290. gamepadRotationSensibility: number;
  40291. /**
  40292. * Defines the gamepad move sensiblity.
  40293. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40294. */
  40295. gamepadMoveSensibility: number;
  40296. private _yAxisScale;
  40297. /**
  40298. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40299. */
  40300. get invertYAxis(): boolean;
  40301. set invertYAxis(value: boolean);
  40302. private _onGamepadConnectedObserver;
  40303. private _onGamepadDisconnectedObserver;
  40304. /**
  40305. * Attach the input controls to a specific dom element to get the input from.
  40306. * @param element Defines the element the controls should be listened from
  40307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40308. */
  40309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40310. /**
  40311. * Detach the current controls from the specified dom element.
  40312. * @param element Defines the element to stop listening the inputs from
  40313. */
  40314. detachControl(element: Nullable<HTMLElement>): void;
  40315. /**
  40316. * Update the current camera state depending on the inputs that have been used this frame.
  40317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40318. */
  40319. checkInputs(): void;
  40320. /**
  40321. * Gets the class name of the current intput.
  40322. * @returns the class name
  40323. */
  40324. getClassName(): string;
  40325. /**
  40326. * Get the friendly name associated with the input class.
  40327. * @returns the input friendly name
  40328. */
  40329. getSimpleName(): string;
  40330. }
  40331. }
  40332. declare module BABYLON {
  40333. interface ArcRotateCameraInputsManager {
  40334. /**
  40335. * Add orientation input support to the input manager.
  40336. * @returns the current input manager
  40337. */
  40338. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40339. }
  40340. /**
  40341. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40343. */
  40344. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40345. /**
  40346. * Defines the camera the input is attached to.
  40347. */
  40348. camera: ArcRotateCamera;
  40349. /**
  40350. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40351. */
  40352. alphaCorrection: number;
  40353. /**
  40354. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40355. */
  40356. gammaCorrection: number;
  40357. private _alpha;
  40358. private _gamma;
  40359. private _dirty;
  40360. private _deviceOrientationHandler;
  40361. /**
  40362. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40363. */
  40364. constructor();
  40365. /**
  40366. * Attach the input controls to a specific dom element to get the input from.
  40367. * @param element Defines the element the controls should be listened from
  40368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40369. */
  40370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40371. /** @hidden */
  40372. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40373. /**
  40374. * Update the current camera state depending on the inputs that have been used this frame.
  40375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40376. */
  40377. checkInputs(): void;
  40378. /**
  40379. * Detach the current controls from the specified dom element.
  40380. * @param element Defines the element to stop listening the inputs from
  40381. */
  40382. detachControl(element: Nullable<HTMLElement>): void;
  40383. /**
  40384. * Gets the class name of the current intput.
  40385. * @returns the class name
  40386. */
  40387. getClassName(): string;
  40388. /**
  40389. * Get the friendly name associated with the input class.
  40390. * @returns the input friendly name
  40391. */
  40392. getSimpleName(): string;
  40393. }
  40394. }
  40395. declare module BABYLON {
  40396. /**
  40397. * Listen to mouse events to control the camera.
  40398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40399. */
  40400. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40401. /**
  40402. * Defines the camera the input is attached to.
  40403. */
  40404. camera: FlyCamera;
  40405. /**
  40406. * Defines if touch is enabled. (Default is true.)
  40407. */
  40408. touchEnabled: boolean;
  40409. /**
  40410. * Defines the buttons associated with the input to handle camera rotation.
  40411. */
  40412. buttons: number[];
  40413. /**
  40414. * Assign buttons for Yaw control.
  40415. */
  40416. buttonsYaw: number[];
  40417. /**
  40418. * Assign buttons for Pitch control.
  40419. */
  40420. buttonsPitch: number[];
  40421. /**
  40422. * Assign buttons for Roll control.
  40423. */
  40424. buttonsRoll: number[];
  40425. /**
  40426. * Detect if any button is being pressed while mouse is moved.
  40427. * -1 = Mouse locked.
  40428. * 0 = Left button.
  40429. * 1 = Middle Button.
  40430. * 2 = Right Button.
  40431. */
  40432. activeButton: number;
  40433. /**
  40434. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40435. * Higher values reduce its sensitivity.
  40436. */
  40437. angularSensibility: number;
  40438. private _mousemoveCallback;
  40439. private _observer;
  40440. private _rollObserver;
  40441. private previousPosition;
  40442. private noPreventDefault;
  40443. private element;
  40444. /**
  40445. * Listen to mouse events to control the camera.
  40446. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40448. */
  40449. constructor(touchEnabled?: boolean);
  40450. /**
  40451. * Attach the mouse control to the HTML DOM element.
  40452. * @param element Defines the element that listens to the input events.
  40453. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40454. */
  40455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40456. /**
  40457. * Detach the current controls from the specified dom element.
  40458. * @param element Defines the element to stop listening the inputs from
  40459. */
  40460. detachControl(element: Nullable<HTMLElement>): void;
  40461. /**
  40462. * Gets the class name of the current input.
  40463. * @returns the class name.
  40464. */
  40465. getClassName(): string;
  40466. /**
  40467. * Get the friendly name associated with the input class.
  40468. * @returns the input's friendly name.
  40469. */
  40470. getSimpleName(): string;
  40471. private _pointerInput;
  40472. private _onMouseMove;
  40473. /**
  40474. * Rotate camera by mouse offset.
  40475. */
  40476. private rotateCamera;
  40477. }
  40478. }
  40479. declare module BABYLON {
  40480. /**
  40481. * Default Inputs manager for the FlyCamera.
  40482. * It groups all the default supported inputs for ease of use.
  40483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40484. */
  40485. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40486. /**
  40487. * Instantiates a new FlyCameraInputsManager.
  40488. * @param camera Defines the camera the inputs belong to.
  40489. */
  40490. constructor(camera: FlyCamera);
  40491. /**
  40492. * Add keyboard input support to the input manager.
  40493. * @returns the new FlyCameraKeyboardMoveInput().
  40494. */
  40495. addKeyboard(): FlyCameraInputsManager;
  40496. /**
  40497. * Add mouse input support to the input manager.
  40498. * @param touchEnabled Enable touch screen support.
  40499. * @returns the new FlyCameraMouseInput().
  40500. */
  40501. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40502. }
  40503. }
  40504. declare module BABYLON {
  40505. /**
  40506. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40507. * such as in a 3D Space Shooter or a Flight Simulator.
  40508. */
  40509. export class FlyCamera extends TargetCamera {
  40510. /**
  40511. * Define the collision ellipsoid of the camera.
  40512. * This is helpful for simulating a camera body, like a player's body.
  40513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40514. */
  40515. ellipsoid: Vector3;
  40516. /**
  40517. * Define an offset for the position of the ellipsoid around the camera.
  40518. * This can be helpful if the camera is attached away from the player's body center,
  40519. * such as at its head.
  40520. */
  40521. ellipsoidOffset: Vector3;
  40522. /**
  40523. * Enable or disable collisions of the camera with the rest of the scene objects.
  40524. */
  40525. checkCollisions: boolean;
  40526. /**
  40527. * Enable or disable gravity on the camera.
  40528. */
  40529. applyGravity: boolean;
  40530. /**
  40531. * Define the current direction the camera is moving to.
  40532. */
  40533. cameraDirection: Vector3;
  40534. /**
  40535. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40536. * This overrides and empties cameraRotation.
  40537. */
  40538. rotationQuaternion: Quaternion;
  40539. /**
  40540. * Track Roll to maintain the wanted Rolling when looking around.
  40541. */
  40542. _trackRoll: number;
  40543. /**
  40544. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40545. */
  40546. rollCorrect: number;
  40547. /**
  40548. * Mimic a banked turn, Rolling the camera when Yawing.
  40549. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40550. */
  40551. bankedTurn: boolean;
  40552. /**
  40553. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40554. */
  40555. bankedTurnLimit: number;
  40556. /**
  40557. * Value of 0 disables the banked Roll.
  40558. * Value of 1 is equal to the Yaw angle in radians.
  40559. */
  40560. bankedTurnMultiplier: number;
  40561. /**
  40562. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40563. */
  40564. inputs: FlyCameraInputsManager;
  40565. /**
  40566. * Gets the input sensibility for mouse input.
  40567. * Higher values reduce sensitivity.
  40568. */
  40569. get angularSensibility(): number;
  40570. /**
  40571. * Sets the input sensibility for a mouse input.
  40572. * Higher values reduce sensitivity.
  40573. */
  40574. set angularSensibility(value: number);
  40575. /**
  40576. * Get the keys for camera movement forward.
  40577. */
  40578. get keysForward(): number[];
  40579. /**
  40580. * Set the keys for camera movement forward.
  40581. */
  40582. set keysForward(value: number[]);
  40583. /**
  40584. * Get the keys for camera movement backward.
  40585. */
  40586. get keysBackward(): number[];
  40587. set keysBackward(value: number[]);
  40588. /**
  40589. * Get the keys for camera movement up.
  40590. */
  40591. get keysUp(): number[];
  40592. /**
  40593. * Set the keys for camera movement up.
  40594. */
  40595. set keysUp(value: number[]);
  40596. /**
  40597. * Get the keys for camera movement down.
  40598. */
  40599. get keysDown(): number[];
  40600. /**
  40601. * Set the keys for camera movement down.
  40602. */
  40603. set keysDown(value: number[]);
  40604. /**
  40605. * Get the keys for camera movement left.
  40606. */
  40607. get keysLeft(): number[];
  40608. /**
  40609. * Set the keys for camera movement left.
  40610. */
  40611. set keysLeft(value: number[]);
  40612. /**
  40613. * Set the keys for camera movement right.
  40614. */
  40615. get keysRight(): number[];
  40616. /**
  40617. * Set the keys for camera movement right.
  40618. */
  40619. set keysRight(value: number[]);
  40620. /**
  40621. * Event raised when the camera collides with a mesh in the scene.
  40622. */
  40623. onCollide: (collidedMesh: AbstractMesh) => void;
  40624. private _collider;
  40625. private _needMoveForGravity;
  40626. private _oldPosition;
  40627. private _diffPosition;
  40628. private _newPosition;
  40629. /** @hidden */
  40630. _localDirection: Vector3;
  40631. /** @hidden */
  40632. _transformedDirection: Vector3;
  40633. /**
  40634. * Instantiates a FlyCamera.
  40635. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40636. * such as in a 3D Space Shooter or a Flight Simulator.
  40637. * @param name Define the name of the camera in the scene.
  40638. * @param position Define the starting position of the camera in the scene.
  40639. * @param scene Define the scene the camera belongs to.
  40640. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40641. */
  40642. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40643. /**
  40644. * Attach a control to the HTML DOM element.
  40645. * @param element Defines the element that listens to the input events.
  40646. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40647. */
  40648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40649. /**
  40650. * Detach a control from the HTML DOM element.
  40651. * The camera will stop reacting to that input.
  40652. * @param element Defines the element that listens to the input events.
  40653. */
  40654. detachControl(element: HTMLElement): void;
  40655. private _collisionMask;
  40656. /**
  40657. * Get the mask that the camera ignores in collision events.
  40658. */
  40659. get collisionMask(): number;
  40660. /**
  40661. * Set the mask that the camera ignores in collision events.
  40662. */
  40663. set collisionMask(mask: number);
  40664. /** @hidden */
  40665. _collideWithWorld(displacement: Vector3): void;
  40666. /** @hidden */
  40667. private _onCollisionPositionChange;
  40668. /** @hidden */
  40669. _checkInputs(): void;
  40670. /** @hidden */
  40671. _decideIfNeedsToMove(): boolean;
  40672. /** @hidden */
  40673. _updatePosition(): void;
  40674. /**
  40675. * Restore the Roll to its target value at the rate specified.
  40676. * @param rate - Higher means slower restoring.
  40677. * @hidden
  40678. */
  40679. restoreRoll(rate: number): void;
  40680. /**
  40681. * Destroy the camera and release the current resources held by it.
  40682. */
  40683. dispose(): void;
  40684. /**
  40685. * Get the current object class name.
  40686. * @returns the class name.
  40687. */
  40688. getClassName(): string;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Listen to keyboard events to control the camera.
  40694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40695. */
  40696. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40697. /**
  40698. * Defines the camera the input is attached to.
  40699. */
  40700. camera: FlyCamera;
  40701. /**
  40702. * The list of keyboard keys used to control the forward move of the camera.
  40703. */
  40704. keysForward: number[];
  40705. /**
  40706. * The list of keyboard keys used to control the backward move of the camera.
  40707. */
  40708. keysBackward: number[];
  40709. /**
  40710. * The list of keyboard keys used to control the forward move of the camera.
  40711. */
  40712. keysUp: number[];
  40713. /**
  40714. * The list of keyboard keys used to control the backward move of the camera.
  40715. */
  40716. keysDown: number[];
  40717. /**
  40718. * The list of keyboard keys used to control the right strafe move of the camera.
  40719. */
  40720. keysRight: number[];
  40721. /**
  40722. * The list of keyboard keys used to control the left strafe move of the camera.
  40723. */
  40724. keysLeft: number[];
  40725. private _keys;
  40726. private _onCanvasBlurObserver;
  40727. private _onKeyboardObserver;
  40728. private _engine;
  40729. private _scene;
  40730. /**
  40731. * Attach the input controls to a specific dom element to get the input from.
  40732. * @param element Defines the element the controls should be listened from
  40733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40734. */
  40735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40736. /**
  40737. * Detach the current controls from the specified dom element.
  40738. * @param element Defines the element to stop listening the inputs from
  40739. */
  40740. detachControl(element: Nullable<HTMLElement>): void;
  40741. /**
  40742. * Gets the class name of the current intput.
  40743. * @returns the class name
  40744. */
  40745. getClassName(): string;
  40746. /** @hidden */
  40747. _onLostFocus(e: FocusEvent): void;
  40748. /**
  40749. * Get the friendly name associated with the input class.
  40750. * @returns the input friendly name
  40751. */
  40752. getSimpleName(): string;
  40753. /**
  40754. * Update the current camera state depending on the inputs that have been used this frame.
  40755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40756. */
  40757. checkInputs(): void;
  40758. }
  40759. }
  40760. declare module BABYLON {
  40761. /**
  40762. * Manage the mouse wheel inputs to control a follow camera.
  40763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40764. */
  40765. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40766. /**
  40767. * Defines the camera the input is attached to.
  40768. */
  40769. camera: FollowCamera;
  40770. /**
  40771. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40772. */
  40773. axisControlRadius: boolean;
  40774. /**
  40775. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40776. */
  40777. axisControlHeight: boolean;
  40778. /**
  40779. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40780. */
  40781. axisControlRotation: boolean;
  40782. /**
  40783. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40784. * relation to mouseWheel events.
  40785. */
  40786. wheelPrecision: number;
  40787. /**
  40788. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40789. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40790. */
  40791. wheelDeltaPercentage: number;
  40792. private _wheel;
  40793. private _observer;
  40794. /**
  40795. * Attach the input controls to a specific dom element to get the input from.
  40796. * @param element Defines the element the controls should be listened from
  40797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40798. */
  40799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40800. /**
  40801. * Detach the current controls from the specified dom element.
  40802. * @param element Defines the element to stop listening the inputs from
  40803. */
  40804. detachControl(element: Nullable<HTMLElement>): void;
  40805. /**
  40806. * Gets the class name of the current intput.
  40807. * @returns the class name
  40808. */
  40809. getClassName(): string;
  40810. /**
  40811. * Get the friendly name associated with the input class.
  40812. * @returns the input friendly name
  40813. */
  40814. getSimpleName(): string;
  40815. }
  40816. }
  40817. declare module BABYLON {
  40818. /**
  40819. * Manage the pointers inputs to control an follow camera.
  40820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40821. */
  40822. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40823. /**
  40824. * Defines the camera the input is attached to.
  40825. */
  40826. camera: FollowCamera;
  40827. /**
  40828. * Gets the class name of the current input.
  40829. * @returns the class name
  40830. */
  40831. getClassName(): string;
  40832. /**
  40833. * Defines the pointer angular sensibility along the X axis or how fast is
  40834. * the camera rotating.
  40835. * A negative number will reverse the axis direction.
  40836. */
  40837. angularSensibilityX: number;
  40838. /**
  40839. * Defines the pointer angular sensibility along the Y axis or how fast is
  40840. * the camera rotating.
  40841. * A negative number will reverse the axis direction.
  40842. */
  40843. angularSensibilityY: number;
  40844. /**
  40845. * Defines the pointer pinch precision or how fast is the camera zooming.
  40846. * A negative number will reverse the axis direction.
  40847. */
  40848. pinchPrecision: number;
  40849. /**
  40850. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40851. * from 0.
  40852. * It defines the percentage of current camera.radius to use as delta when
  40853. * pinch zoom is used.
  40854. */
  40855. pinchDeltaPercentage: number;
  40856. /**
  40857. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40858. */
  40859. axisXControlRadius: boolean;
  40860. /**
  40861. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40862. */
  40863. axisXControlHeight: boolean;
  40864. /**
  40865. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40866. */
  40867. axisXControlRotation: boolean;
  40868. /**
  40869. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40870. */
  40871. axisYControlRadius: boolean;
  40872. /**
  40873. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40874. */
  40875. axisYControlHeight: boolean;
  40876. /**
  40877. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40878. */
  40879. axisYControlRotation: boolean;
  40880. /**
  40881. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40882. */
  40883. axisPinchControlRadius: boolean;
  40884. /**
  40885. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40886. */
  40887. axisPinchControlHeight: boolean;
  40888. /**
  40889. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40890. */
  40891. axisPinchControlRotation: boolean;
  40892. /**
  40893. * Log error messages if basic misconfiguration has occurred.
  40894. */
  40895. warningEnable: boolean;
  40896. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40897. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40898. private _warningCounter;
  40899. private _warning;
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * Default Inputs manager for the FollowCamera.
  40905. * It groups all the default supported inputs for ease of use.
  40906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40907. */
  40908. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40909. /**
  40910. * Instantiates a new FollowCameraInputsManager.
  40911. * @param camera Defines the camera the inputs belong to
  40912. */
  40913. constructor(camera: FollowCamera);
  40914. /**
  40915. * Add keyboard input support to the input manager.
  40916. * @returns the current input manager
  40917. */
  40918. addKeyboard(): FollowCameraInputsManager;
  40919. /**
  40920. * Add mouse wheel input support to the input manager.
  40921. * @returns the current input manager
  40922. */
  40923. addMouseWheel(): FollowCameraInputsManager;
  40924. /**
  40925. * Add pointers input support to the input manager.
  40926. * @returns the current input manager
  40927. */
  40928. addPointers(): FollowCameraInputsManager;
  40929. /**
  40930. * Add orientation input support to the input manager.
  40931. * @returns the current input manager
  40932. */
  40933. addVRDeviceOrientation(): FollowCameraInputsManager;
  40934. }
  40935. }
  40936. declare module BABYLON {
  40937. /**
  40938. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40939. * an arc rotate version arcFollowCamera are available.
  40940. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40941. */
  40942. export class FollowCamera extends TargetCamera {
  40943. /**
  40944. * Distance the follow camera should follow an object at
  40945. */
  40946. radius: number;
  40947. /**
  40948. * Minimum allowed distance of the camera to the axis of rotation
  40949. * (The camera can not get closer).
  40950. * This can help limiting how the Camera is able to move in the scene.
  40951. */
  40952. lowerRadiusLimit: Nullable<number>;
  40953. /**
  40954. * Maximum allowed distance of the camera to the axis of rotation
  40955. * (The camera can not get further).
  40956. * This can help limiting how the Camera is able to move in the scene.
  40957. */
  40958. upperRadiusLimit: Nullable<number>;
  40959. /**
  40960. * Define a rotation offset between the camera and the object it follows
  40961. */
  40962. rotationOffset: number;
  40963. /**
  40964. * Minimum allowed angle to camera position relative to target object.
  40965. * This can help limiting how the Camera is able to move in the scene.
  40966. */
  40967. lowerRotationOffsetLimit: Nullable<number>;
  40968. /**
  40969. * Maximum allowed angle to camera position relative to target object.
  40970. * This can help limiting how the Camera is able to move in the scene.
  40971. */
  40972. upperRotationOffsetLimit: Nullable<number>;
  40973. /**
  40974. * Define a height offset between the camera and the object it follows.
  40975. * It can help following an object from the top (like a car chaing a plane)
  40976. */
  40977. heightOffset: number;
  40978. /**
  40979. * Minimum allowed height of camera position relative to target object.
  40980. * This can help limiting how the Camera is able to move in the scene.
  40981. */
  40982. lowerHeightOffsetLimit: Nullable<number>;
  40983. /**
  40984. * Maximum allowed height of camera position relative to target object.
  40985. * This can help limiting how the Camera is able to move in the scene.
  40986. */
  40987. upperHeightOffsetLimit: Nullable<number>;
  40988. /**
  40989. * Define how fast the camera can accelerate to follow it s target.
  40990. */
  40991. cameraAcceleration: number;
  40992. /**
  40993. * Define the speed limit of the camera following an object.
  40994. */
  40995. maxCameraSpeed: number;
  40996. /**
  40997. * Define the target of the camera.
  40998. */
  40999. lockedTarget: Nullable<AbstractMesh>;
  41000. /**
  41001. * Defines the input associated with the camera.
  41002. */
  41003. inputs: FollowCameraInputsManager;
  41004. /**
  41005. * Instantiates the follow camera.
  41006. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41007. * @param name Define the name of the camera in the scene
  41008. * @param position Define the position of the camera
  41009. * @param scene Define the scene the camera belong to
  41010. * @param lockedTarget Define the target of the camera
  41011. */
  41012. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41013. private _follow;
  41014. /**
  41015. * Attached controls to the current camera.
  41016. * @param element Defines the element the controls should be listened from
  41017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41018. */
  41019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41020. /**
  41021. * Detach the current controls from the camera.
  41022. * The camera will stop reacting to inputs.
  41023. * @param element Defines the element to stop listening the inputs from
  41024. */
  41025. detachControl(element: HTMLElement): void;
  41026. /** @hidden */
  41027. _checkInputs(): void;
  41028. private _checkLimits;
  41029. /**
  41030. * Gets the camera class name.
  41031. * @returns the class name
  41032. */
  41033. getClassName(): string;
  41034. }
  41035. /**
  41036. * Arc Rotate version of the follow camera.
  41037. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41039. */
  41040. export class ArcFollowCamera extends TargetCamera {
  41041. /** The longitudinal angle of the camera */
  41042. alpha: number;
  41043. /** The latitudinal angle of the camera */
  41044. beta: number;
  41045. /** The radius of the camera from its target */
  41046. radius: number;
  41047. /** Define the camera target (the messh it should follow) */
  41048. target: Nullable<AbstractMesh>;
  41049. private _cartesianCoordinates;
  41050. /**
  41051. * Instantiates a new ArcFollowCamera
  41052. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41053. * @param name Define the name of the camera
  41054. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41055. * @param beta Define the rotation angle of the camera around the elevation axis
  41056. * @param radius Define the radius of the camera from its target point
  41057. * @param target Define the target of the camera
  41058. * @param scene Define the scene the camera belongs to
  41059. */
  41060. constructor(name: string,
  41061. /** The longitudinal angle of the camera */
  41062. alpha: number,
  41063. /** The latitudinal angle of the camera */
  41064. beta: number,
  41065. /** The radius of the camera from its target */
  41066. radius: number,
  41067. /** Define the camera target (the messh it should follow) */
  41068. target: Nullable<AbstractMesh>, scene: Scene);
  41069. private _follow;
  41070. /** @hidden */
  41071. _checkInputs(): void;
  41072. /**
  41073. * Returns the class name of the object.
  41074. * It is mostly used internally for serialization purposes.
  41075. */
  41076. getClassName(): string;
  41077. }
  41078. }
  41079. declare module BABYLON {
  41080. /**
  41081. * Manage the keyboard inputs to control the movement of a follow camera.
  41082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41083. */
  41084. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41085. /**
  41086. * Defines the camera the input is attached to.
  41087. */
  41088. camera: FollowCamera;
  41089. /**
  41090. * Defines the list of key codes associated with the up action (increase heightOffset)
  41091. */
  41092. keysHeightOffsetIncr: number[];
  41093. /**
  41094. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41095. */
  41096. keysHeightOffsetDecr: number[];
  41097. /**
  41098. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41099. */
  41100. keysHeightOffsetModifierAlt: boolean;
  41101. /**
  41102. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41103. */
  41104. keysHeightOffsetModifierCtrl: boolean;
  41105. /**
  41106. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41107. */
  41108. keysHeightOffsetModifierShift: boolean;
  41109. /**
  41110. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41111. */
  41112. keysRotationOffsetIncr: number[];
  41113. /**
  41114. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41115. */
  41116. keysRotationOffsetDecr: number[];
  41117. /**
  41118. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41119. */
  41120. keysRotationOffsetModifierAlt: boolean;
  41121. /**
  41122. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41123. */
  41124. keysRotationOffsetModifierCtrl: boolean;
  41125. /**
  41126. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41127. */
  41128. keysRotationOffsetModifierShift: boolean;
  41129. /**
  41130. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41131. */
  41132. keysRadiusIncr: number[];
  41133. /**
  41134. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41135. */
  41136. keysRadiusDecr: number[];
  41137. /**
  41138. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41139. */
  41140. keysRadiusModifierAlt: boolean;
  41141. /**
  41142. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41143. */
  41144. keysRadiusModifierCtrl: boolean;
  41145. /**
  41146. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41147. */
  41148. keysRadiusModifierShift: boolean;
  41149. /**
  41150. * Defines the rate of change of heightOffset.
  41151. */
  41152. heightSensibility: number;
  41153. /**
  41154. * Defines the rate of change of rotationOffset.
  41155. */
  41156. rotationSensibility: number;
  41157. /**
  41158. * Defines the rate of change of radius.
  41159. */
  41160. radiusSensibility: number;
  41161. private _keys;
  41162. private _ctrlPressed;
  41163. private _altPressed;
  41164. private _shiftPressed;
  41165. private _onCanvasBlurObserver;
  41166. private _onKeyboardObserver;
  41167. private _engine;
  41168. private _scene;
  41169. /**
  41170. * Attach the input controls to a specific dom element to get the input from.
  41171. * @param element Defines the element the controls should be listened from
  41172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41173. */
  41174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41175. /**
  41176. * Detach the current controls from the specified dom element.
  41177. * @param element Defines the element to stop listening the inputs from
  41178. */
  41179. detachControl(element: Nullable<HTMLElement>): void;
  41180. /**
  41181. * Update the current camera state depending on the inputs that have been used this frame.
  41182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41183. */
  41184. checkInputs(): void;
  41185. /**
  41186. * Gets the class name of the current input.
  41187. * @returns the class name
  41188. */
  41189. getClassName(): string;
  41190. /**
  41191. * Get the friendly name associated with the input class.
  41192. * @returns the input friendly name
  41193. */
  41194. getSimpleName(): string;
  41195. /**
  41196. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41197. * allow modification of the heightOffset value.
  41198. */
  41199. private _modifierHeightOffset;
  41200. /**
  41201. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41202. * allow modification of the rotationOffset value.
  41203. */
  41204. private _modifierRotationOffset;
  41205. /**
  41206. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41207. * allow modification of the radius value.
  41208. */
  41209. private _modifierRadius;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. interface FreeCameraInputsManager {
  41214. /**
  41215. * @hidden
  41216. */
  41217. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41218. /**
  41219. * Add orientation input support to the input manager.
  41220. * @returns the current input manager
  41221. */
  41222. addDeviceOrientation(): FreeCameraInputsManager;
  41223. }
  41224. /**
  41225. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41226. * Screen rotation is taken into account.
  41227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41228. */
  41229. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41230. private _camera;
  41231. private _screenOrientationAngle;
  41232. private _constantTranform;
  41233. private _screenQuaternion;
  41234. private _alpha;
  41235. private _beta;
  41236. private _gamma;
  41237. /**
  41238. * Can be used to detect if a device orientation sensor is available on a device
  41239. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41240. * @returns a promise that will resolve on orientation change
  41241. */
  41242. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41243. /**
  41244. * @hidden
  41245. */
  41246. _onDeviceOrientationChangedObservable: Observable<void>;
  41247. /**
  41248. * Instantiates a new input
  41249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41250. */
  41251. constructor();
  41252. /**
  41253. * Define the camera controlled by the input.
  41254. */
  41255. get camera(): FreeCamera;
  41256. set camera(camera: FreeCamera);
  41257. /**
  41258. * Attach the input controls to a specific dom element to get the input from.
  41259. * @param element Defines the element the controls should be listened from
  41260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41261. */
  41262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41263. private _orientationChanged;
  41264. private _deviceOrientation;
  41265. /**
  41266. * Detach the current controls from the specified dom element.
  41267. * @param element Defines the element to stop listening the inputs from
  41268. */
  41269. detachControl(element: Nullable<HTMLElement>): void;
  41270. /**
  41271. * Update the current camera state depending on the inputs that have been used this frame.
  41272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41273. */
  41274. checkInputs(): void;
  41275. /**
  41276. * Gets the class name of the current intput.
  41277. * @returns the class name
  41278. */
  41279. getClassName(): string;
  41280. /**
  41281. * Get the friendly name associated with the input class.
  41282. * @returns the input friendly name
  41283. */
  41284. getSimpleName(): string;
  41285. }
  41286. }
  41287. declare module BABYLON {
  41288. /**
  41289. * Manage the gamepad inputs to control a free camera.
  41290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41291. */
  41292. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41293. /**
  41294. * Define the camera the input is attached to.
  41295. */
  41296. camera: FreeCamera;
  41297. /**
  41298. * Define the Gamepad controlling the input
  41299. */
  41300. gamepad: Nullable<Gamepad>;
  41301. /**
  41302. * Defines the gamepad rotation sensiblity.
  41303. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41304. */
  41305. gamepadAngularSensibility: number;
  41306. /**
  41307. * Defines the gamepad move sensiblity.
  41308. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41309. */
  41310. gamepadMoveSensibility: number;
  41311. private _yAxisScale;
  41312. /**
  41313. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41314. */
  41315. get invertYAxis(): boolean;
  41316. set invertYAxis(value: boolean);
  41317. private _onGamepadConnectedObserver;
  41318. private _onGamepadDisconnectedObserver;
  41319. private _cameraTransform;
  41320. private _deltaTransform;
  41321. private _vector3;
  41322. private _vector2;
  41323. /**
  41324. * Attach the input controls to a specific dom element to get the input from.
  41325. * @param element Defines the element the controls should be listened from
  41326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41327. */
  41328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41329. /**
  41330. * Detach the current controls from the specified dom element.
  41331. * @param element Defines the element to stop listening the inputs from
  41332. */
  41333. detachControl(element: Nullable<HTMLElement>): void;
  41334. /**
  41335. * Update the current camera state depending on the inputs that have been used this frame.
  41336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41337. */
  41338. checkInputs(): void;
  41339. /**
  41340. * Gets the class name of the current intput.
  41341. * @returns the class name
  41342. */
  41343. getClassName(): string;
  41344. /**
  41345. * Get the friendly name associated with the input class.
  41346. * @returns the input friendly name
  41347. */
  41348. getSimpleName(): string;
  41349. }
  41350. }
  41351. declare module BABYLON {
  41352. /**
  41353. * Defines the potential axis of a Joystick
  41354. */
  41355. export enum JoystickAxis {
  41356. /** X axis */
  41357. X = 0,
  41358. /** Y axis */
  41359. Y = 1,
  41360. /** Z axis */
  41361. Z = 2
  41362. }
  41363. /**
  41364. * Class used to define virtual joystick (used in touch mode)
  41365. */
  41366. export class VirtualJoystick {
  41367. /**
  41368. * Gets or sets a boolean indicating that left and right values must be inverted
  41369. */
  41370. reverseLeftRight: boolean;
  41371. /**
  41372. * Gets or sets a boolean indicating that up and down values must be inverted
  41373. */
  41374. reverseUpDown: boolean;
  41375. /**
  41376. * Gets the offset value for the position (ie. the change of the position value)
  41377. */
  41378. deltaPosition: Vector3;
  41379. /**
  41380. * Gets a boolean indicating if the virtual joystick was pressed
  41381. */
  41382. pressed: boolean;
  41383. /**
  41384. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41385. */
  41386. static Canvas: Nullable<HTMLCanvasElement>;
  41387. private static _globalJoystickIndex;
  41388. private static vjCanvasContext;
  41389. private static vjCanvasWidth;
  41390. private static vjCanvasHeight;
  41391. private static halfWidth;
  41392. private _action;
  41393. private _axisTargetedByLeftAndRight;
  41394. private _axisTargetedByUpAndDown;
  41395. private _joystickSensibility;
  41396. private _inversedSensibility;
  41397. private _joystickPointerID;
  41398. private _joystickColor;
  41399. private _joystickPointerPos;
  41400. private _joystickPreviousPointerPos;
  41401. private _joystickPointerStartPos;
  41402. private _deltaJoystickVector;
  41403. private _leftJoystick;
  41404. private _touches;
  41405. private _onPointerDownHandlerRef;
  41406. private _onPointerMoveHandlerRef;
  41407. private _onPointerUpHandlerRef;
  41408. private _onResize;
  41409. /**
  41410. * Creates a new virtual joystick
  41411. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41412. */
  41413. constructor(leftJoystick?: boolean);
  41414. /**
  41415. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41416. * @param newJoystickSensibility defines the new sensibility
  41417. */
  41418. setJoystickSensibility(newJoystickSensibility: number): void;
  41419. private _onPointerDown;
  41420. private _onPointerMove;
  41421. private _onPointerUp;
  41422. /**
  41423. * Change the color of the virtual joystick
  41424. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41425. */
  41426. setJoystickColor(newColor: string): void;
  41427. /**
  41428. * Defines a callback to call when the joystick is touched
  41429. * @param action defines the callback
  41430. */
  41431. setActionOnTouch(action: () => any): void;
  41432. /**
  41433. * Defines which axis you'd like to control for left & right
  41434. * @param axis defines the axis to use
  41435. */
  41436. setAxisForLeftRight(axis: JoystickAxis): void;
  41437. /**
  41438. * Defines which axis you'd like to control for up & down
  41439. * @param axis defines the axis to use
  41440. */
  41441. setAxisForUpDown(axis: JoystickAxis): void;
  41442. private _drawVirtualJoystick;
  41443. /**
  41444. * Release internal HTML canvas
  41445. */
  41446. releaseCanvas(): void;
  41447. }
  41448. }
  41449. declare module BABYLON {
  41450. interface FreeCameraInputsManager {
  41451. /**
  41452. * Add virtual joystick input support to the input manager.
  41453. * @returns the current input manager
  41454. */
  41455. addVirtualJoystick(): FreeCameraInputsManager;
  41456. }
  41457. /**
  41458. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41462. /**
  41463. * Defines the camera the input is attached to.
  41464. */
  41465. camera: FreeCamera;
  41466. private _leftjoystick;
  41467. private _rightjoystick;
  41468. /**
  41469. * Gets the left stick of the virtual joystick.
  41470. * @returns The virtual Joystick
  41471. */
  41472. getLeftJoystick(): VirtualJoystick;
  41473. /**
  41474. * Gets the right stick of the virtual joystick.
  41475. * @returns The virtual Joystick
  41476. */
  41477. getRightJoystick(): VirtualJoystick;
  41478. /**
  41479. * Update the current camera state depending on the inputs that have been used this frame.
  41480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41481. */
  41482. checkInputs(): void;
  41483. /**
  41484. * Attach the input controls to a specific dom element to get the input from.
  41485. * @param element Defines the element the controls should be listened from
  41486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41487. */
  41488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41489. /**
  41490. * Detach the current controls from the specified dom element.
  41491. * @param element Defines the element to stop listening the inputs from
  41492. */
  41493. detachControl(element: Nullable<HTMLElement>): void;
  41494. /**
  41495. * Gets the class name of the current intput.
  41496. * @returns the class name
  41497. */
  41498. getClassName(): string;
  41499. /**
  41500. * Get the friendly name associated with the input class.
  41501. * @returns the input friendly name
  41502. */
  41503. getSimpleName(): string;
  41504. }
  41505. }
  41506. declare module BABYLON {
  41507. /**
  41508. * This represents a FPS type of camera controlled by touch.
  41509. * This is like a universal camera minus the Gamepad controls.
  41510. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41511. */
  41512. export class TouchCamera extends FreeCamera {
  41513. /**
  41514. * Defines the touch sensibility for rotation.
  41515. * The higher the faster.
  41516. */
  41517. get touchAngularSensibility(): number;
  41518. set touchAngularSensibility(value: number);
  41519. /**
  41520. * Defines the touch sensibility for move.
  41521. * The higher the faster.
  41522. */
  41523. get touchMoveSensibility(): number;
  41524. set touchMoveSensibility(value: number);
  41525. /**
  41526. * Instantiates a new touch camera.
  41527. * This represents a FPS type of camera controlled by touch.
  41528. * This is like a universal camera minus the Gamepad controls.
  41529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41530. * @param name Define the name of the camera in the scene
  41531. * @param position Define the start position of the camera in the scene
  41532. * @param scene Define the scene the camera belongs to
  41533. */
  41534. constructor(name: string, position: Vector3, scene: Scene);
  41535. /**
  41536. * Gets the current object class name.
  41537. * @return the class name
  41538. */
  41539. getClassName(): string;
  41540. /** @hidden */
  41541. _setupInputs(): void;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41547. * being tilted forward or back and left or right.
  41548. */
  41549. export class DeviceOrientationCamera extends FreeCamera {
  41550. private _initialQuaternion;
  41551. private _quaternionCache;
  41552. private _tmpDragQuaternion;
  41553. private _disablePointerInputWhenUsingDeviceOrientation;
  41554. /**
  41555. * Creates a new device orientation camera
  41556. * @param name The name of the camera
  41557. * @param position The start position camera
  41558. * @param scene The scene the camera belongs to
  41559. */
  41560. constructor(name: string, position: Vector3, scene: Scene);
  41561. /**
  41562. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41563. */
  41564. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41565. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41566. private _dragFactor;
  41567. /**
  41568. * Enabled turning on the y axis when the orientation sensor is active
  41569. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41570. */
  41571. enableHorizontalDragging(dragFactor?: number): void;
  41572. /**
  41573. * Gets the current instance class name ("DeviceOrientationCamera").
  41574. * This helps avoiding instanceof at run time.
  41575. * @returns the class name
  41576. */
  41577. getClassName(): string;
  41578. /**
  41579. * @hidden
  41580. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41581. */
  41582. _checkInputs(): void;
  41583. /**
  41584. * Reset the camera to its default orientation on the specified axis only.
  41585. * @param axis The axis to reset
  41586. */
  41587. resetToCurrentRotation(axis?: Axis): void;
  41588. }
  41589. }
  41590. declare module BABYLON {
  41591. /**
  41592. * Defines supported buttons for XBox360 compatible gamepads
  41593. */
  41594. export enum Xbox360Button {
  41595. /** A */
  41596. A = 0,
  41597. /** B */
  41598. B = 1,
  41599. /** X */
  41600. X = 2,
  41601. /** Y */
  41602. Y = 3,
  41603. /** Left button */
  41604. LB = 4,
  41605. /** Right button */
  41606. RB = 5,
  41607. /** Back */
  41608. Back = 8,
  41609. /** Start */
  41610. Start = 9,
  41611. /** Left stick */
  41612. LeftStick = 10,
  41613. /** Right stick */
  41614. RightStick = 11
  41615. }
  41616. /** Defines values for XBox360 DPad */
  41617. export enum Xbox360Dpad {
  41618. /** Up */
  41619. Up = 12,
  41620. /** Down */
  41621. Down = 13,
  41622. /** Left */
  41623. Left = 14,
  41624. /** Right */
  41625. Right = 15
  41626. }
  41627. /**
  41628. * Defines a XBox360 gamepad
  41629. */
  41630. export class Xbox360Pad extends Gamepad {
  41631. private _leftTrigger;
  41632. private _rightTrigger;
  41633. private _onlefttriggerchanged;
  41634. private _onrighttriggerchanged;
  41635. private _onbuttondown;
  41636. private _onbuttonup;
  41637. private _ondpaddown;
  41638. private _ondpadup;
  41639. /** Observable raised when a button is pressed */
  41640. onButtonDownObservable: Observable<Xbox360Button>;
  41641. /** Observable raised when a button is released */
  41642. onButtonUpObservable: Observable<Xbox360Button>;
  41643. /** Observable raised when a pad is pressed */
  41644. onPadDownObservable: Observable<Xbox360Dpad>;
  41645. /** Observable raised when a pad is released */
  41646. onPadUpObservable: Observable<Xbox360Dpad>;
  41647. private _buttonA;
  41648. private _buttonB;
  41649. private _buttonX;
  41650. private _buttonY;
  41651. private _buttonBack;
  41652. private _buttonStart;
  41653. private _buttonLB;
  41654. private _buttonRB;
  41655. private _buttonLeftStick;
  41656. private _buttonRightStick;
  41657. private _dPadUp;
  41658. private _dPadDown;
  41659. private _dPadLeft;
  41660. private _dPadRight;
  41661. private _isXboxOnePad;
  41662. /**
  41663. * Creates a new XBox360 gamepad object
  41664. * @param id defines the id of this gamepad
  41665. * @param index defines its index
  41666. * @param gamepad defines the internal HTML gamepad object
  41667. * @param xboxOne defines if it is a XBox One gamepad
  41668. */
  41669. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41670. /**
  41671. * Defines the callback to call when left trigger is pressed
  41672. * @param callback defines the callback to use
  41673. */
  41674. onlefttriggerchanged(callback: (value: number) => void): void;
  41675. /**
  41676. * Defines the callback to call when right trigger is pressed
  41677. * @param callback defines the callback to use
  41678. */
  41679. onrighttriggerchanged(callback: (value: number) => void): void;
  41680. /**
  41681. * Gets the left trigger value
  41682. */
  41683. get leftTrigger(): number;
  41684. /**
  41685. * Sets the left trigger value
  41686. */
  41687. set leftTrigger(newValue: number);
  41688. /**
  41689. * Gets the right trigger value
  41690. */
  41691. get rightTrigger(): number;
  41692. /**
  41693. * Sets the right trigger value
  41694. */
  41695. set rightTrigger(newValue: number);
  41696. /**
  41697. * Defines the callback to call when a button is pressed
  41698. * @param callback defines the callback to use
  41699. */
  41700. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41701. /**
  41702. * Defines the callback to call when a button is released
  41703. * @param callback defines the callback to use
  41704. */
  41705. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41706. /**
  41707. * Defines the callback to call when a pad is pressed
  41708. * @param callback defines the callback to use
  41709. */
  41710. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41711. /**
  41712. * Defines the callback to call when a pad is released
  41713. * @param callback defines the callback to use
  41714. */
  41715. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41716. private _setButtonValue;
  41717. private _setDPadValue;
  41718. /**
  41719. * Gets the value of the `A` button
  41720. */
  41721. get buttonA(): number;
  41722. /**
  41723. * Sets the value of the `A` button
  41724. */
  41725. set buttonA(value: number);
  41726. /**
  41727. * Gets the value of the `B` button
  41728. */
  41729. get buttonB(): number;
  41730. /**
  41731. * Sets the value of the `B` button
  41732. */
  41733. set buttonB(value: number);
  41734. /**
  41735. * Gets the value of the `X` button
  41736. */
  41737. get buttonX(): number;
  41738. /**
  41739. * Sets the value of the `X` button
  41740. */
  41741. set buttonX(value: number);
  41742. /**
  41743. * Gets the value of the `Y` button
  41744. */
  41745. get buttonY(): number;
  41746. /**
  41747. * Sets the value of the `Y` button
  41748. */
  41749. set buttonY(value: number);
  41750. /**
  41751. * Gets the value of the `Start` button
  41752. */
  41753. get buttonStart(): number;
  41754. /**
  41755. * Sets the value of the `Start` button
  41756. */
  41757. set buttonStart(value: number);
  41758. /**
  41759. * Gets the value of the `Back` button
  41760. */
  41761. get buttonBack(): number;
  41762. /**
  41763. * Sets the value of the `Back` button
  41764. */
  41765. set buttonBack(value: number);
  41766. /**
  41767. * Gets the value of the `Left` button
  41768. */
  41769. get buttonLB(): number;
  41770. /**
  41771. * Sets the value of the `Left` button
  41772. */
  41773. set buttonLB(value: number);
  41774. /**
  41775. * Gets the value of the `Right` button
  41776. */
  41777. get buttonRB(): number;
  41778. /**
  41779. * Sets the value of the `Right` button
  41780. */
  41781. set buttonRB(value: number);
  41782. /**
  41783. * Gets the value of the Left joystick
  41784. */
  41785. get buttonLeftStick(): number;
  41786. /**
  41787. * Sets the value of the Left joystick
  41788. */
  41789. set buttonLeftStick(value: number);
  41790. /**
  41791. * Gets the value of the Right joystick
  41792. */
  41793. get buttonRightStick(): number;
  41794. /**
  41795. * Sets the value of the Right joystick
  41796. */
  41797. set buttonRightStick(value: number);
  41798. /**
  41799. * Gets the value of D-pad up
  41800. */
  41801. get dPadUp(): number;
  41802. /**
  41803. * Sets the value of D-pad up
  41804. */
  41805. set dPadUp(value: number);
  41806. /**
  41807. * Gets the value of D-pad down
  41808. */
  41809. get dPadDown(): number;
  41810. /**
  41811. * Sets the value of D-pad down
  41812. */
  41813. set dPadDown(value: number);
  41814. /**
  41815. * Gets the value of D-pad left
  41816. */
  41817. get dPadLeft(): number;
  41818. /**
  41819. * Sets the value of D-pad left
  41820. */
  41821. set dPadLeft(value: number);
  41822. /**
  41823. * Gets the value of D-pad right
  41824. */
  41825. get dPadRight(): number;
  41826. /**
  41827. * Sets the value of D-pad right
  41828. */
  41829. set dPadRight(value: number);
  41830. /**
  41831. * Force the gamepad to synchronize with device values
  41832. */
  41833. update(): void;
  41834. /**
  41835. * Disposes the gamepad
  41836. */
  41837. dispose(): void;
  41838. }
  41839. }
  41840. declare module BABYLON {
  41841. /**
  41842. * Defines supported buttons for DualShock compatible gamepads
  41843. */
  41844. export enum DualShockButton {
  41845. /** Cross */
  41846. Cross = 0,
  41847. /** Circle */
  41848. Circle = 1,
  41849. /** Square */
  41850. Square = 2,
  41851. /** Triangle */
  41852. Triangle = 3,
  41853. /** L1 */
  41854. L1 = 4,
  41855. /** R1 */
  41856. R1 = 5,
  41857. /** Share */
  41858. Share = 8,
  41859. /** Options */
  41860. Options = 9,
  41861. /** Left stick */
  41862. LeftStick = 10,
  41863. /** Right stick */
  41864. RightStick = 11
  41865. }
  41866. /** Defines values for DualShock DPad */
  41867. export enum DualShockDpad {
  41868. /** Up */
  41869. Up = 12,
  41870. /** Down */
  41871. Down = 13,
  41872. /** Left */
  41873. Left = 14,
  41874. /** Right */
  41875. Right = 15
  41876. }
  41877. /**
  41878. * Defines a DualShock gamepad
  41879. */
  41880. export class DualShockPad extends Gamepad {
  41881. private _leftTrigger;
  41882. private _rightTrigger;
  41883. private _onlefttriggerchanged;
  41884. private _onrighttriggerchanged;
  41885. private _onbuttondown;
  41886. private _onbuttonup;
  41887. private _ondpaddown;
  41888. private _ondpadup;
  41889. /** Observable raised when a button is pressed */
  41890. onButtonDownObservable: Observable<DualShockButton>;
  41891. /** Observable raised when a button is released */
  41892. onButtonUpObservable: Observable<DualShockButton>;
  41893. /** Observable raised when a pad is pressed */
  41894. onPadDownObservable: Observable<DualShockDpad>;
  41895. /** Observable raised when a pad is released */
  41896. onPadUpObservable: Observable<DualShockDpad>;
  41897. private _buttonCross;
  41898. private _buttonCircle;
  41899. private _buttonSquare;
  41900. private _buttonTriangle;
  41901. private _buttonShare;
  41902. private _buttonOptions;
  41903. private _buttonL1;
  41904. private _buttonR1;
  41905. private _buttonLeftStick;
  41906. private _buttonRightStick;
  41907. private _dPadUp;
  41908. private _dPadDown;
  41909. private _dPadLeft;
  41910. private _dPadRight;
  41911. /**
  41912. * Creates a new DualShock gamepad object
  41913. * @param id defines the id of this gamepad
  41914. * @param index defines its index
  41915. * @param gamepad defines the internal HTML gamepad object
  41916. */
  41917. constructor(id: string, index: number, gamepad: any);
  41918. /**
  41919. * Defines the callback to call when left trigger is pressed
  41920. * @param callback defines the callback to use
  41921. */
  41922. onlefttriggerchanged(callback: (value: number) => void): void;
  41923. /**
  41924. * Defines the callback to call when right trigger is pressed
  41925. * @param callback defines the callback to use
  41926. */
  41927. onrighttriggerchanged(callback: (value: number) => void): void;
  41928. /**
  41929. * Gets the left trigger value
  41930. */
  41931. get leftTrigger(): number;
  41932. /**
  41933. * Sets the left trigger value
  41934. */
  41935. set leftTrigger(newValue: number);
  41936. /**
  41937. * Gets the right trigger value
  41938. */
  41939. get rightTrigger(): number;
  41940. /**
  41941. * Sets the right trigger value
  41942. */
  41943. set rightTrigger(newValue: number);
  41944. /**
  41945. * Defines the callback to call when a button is pressed
  41946. * @param callback defines the callback to use
  41947. */
  41948. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41949. /**
  41950. * Defines the callback to call when a button is released
  41951. * @param callback defines the callback to use
  41952. */
  41953. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41954. /**
  41955. * Defines the callback to call when a pad is pressed
  41956. * @param callback defines the callback to use
  41957. */
  41958. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41959. /**
  41960. * Defines the callback to call when a pad is released
  41961. * @param callback defines the callback to use
  41962. */
  41963. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41964. private _setButtonValue;
  41965. private _setDPadValue;
  41966. /**
  41967. * Gets the value of the `Cross` button
  41968. */
  41969. get buttonCross(): number;
  41970. /**
  41971. * Sets the value of the `Cross` button
  41972. */
  41973. set buttonCross(value: number);
  41974. /**
  41975. * Gets the value of the `Circle` button
  41976. */
  41977. get buttonCircle(): number;
  41978. /**
  41979. * Sets the value of the `Circle` button
  41980. */
  41981. set buttonCircle(value: number);
  41982. /**
  41983. * Gets the value of the `Square` button
  41984. */
  41985. get buttonSquare(): number;
  41986. /**
  41987. * Sets the value of the `Square` button
  41988. */
  41989. set buttonSquare(value: number);
  41990. /**
  41991. * Gets the value of the `Triangle` button
  41992. */
  41993. get buttonTriangle(): number;
  41994. /**
  41995. * Sets the value of the `Triangle` button
  41996. */
  41997. set buttonTriangle(value: number);
  41998. /**
  41999. * Gets the value of the `Options` button
  42000. */
  42001. get buttonOptions(): number;
  42002. /**
  42003. * Sets the value of the `Options` button
  42004. */
  42005. set buttonOptions(value: number);
  42006. /**
  42007. * Gets the value of the `Share` button
  42008. */
  42009. get buttonShare(): number;
  42010. /**
  42011. * Sets the value of the `Share` button
  42012. */
  42013. set buttonShare(value: number);
  42014. /**
  42015. * Gets the value of the `L1` button
  42016. */
  42017. get buttonL1(): number;
  42018. /**
  42019. * Sets the value of the `L1` button
  42020. */
  42021. set buttonL1(value: number);
  42022. /**
  42023. * Gets the value of the `R1` button
  42024. */
  42025. get buttonR1(): number;
  42026. /**
  42027. * Sets the value of the `R1` button
  42028. */
  42029. set buttonR1(value: number);
  42030. /**
  42031. * Gets the value of the Left joystick
  42032. */
  42033. get buttonLeftStick(): number;
  42034. /**
  42035. * Sets the value of the Left joystick
  42036. */
  42037. set buttonLeftStick(value: number);
  42038. /**
  42039. * Gets the value of the Right joystick
  42040. */
  42041. get buttonRightStick(): number;
  42042. /**
  42043. * Sets the value of the Right joystick
  42044. */
  42045. set buttonRightStick(value: number);
  42046. /**
  42047. * Gets the value of D-pad up
  42048. */
  42049. get dPadUp(): number;
  42050. /**
  42051. * Sets the value of D-pad up
  42052. */
  42053. set dPadUp(value: number);
  42054. /**
  42055. * Gets the value of D-pad down
  42056. */
  42057. get dPadDown(): number;
  42058. /**
  42059. * Sets the value of D-pad down
  42060. */
  42061. set dPadDown(value: number);
  42062. /**
  42063. * Gets the value of D-pad left
  42064. */
  42065. get dPadLeft(): number;
  42066. /**
  42067. * Sets the value of D-pad left
  42068. */
  42069. set dPadLeft(value: number);
  42070. /**
  42071. * Gets the value of D-pad right
  42072. */
  42073. get dPadRight(): number;
  42074. /**
  42075. * Sets the value of D-pad right
  42076. */
  42077. set dPadRight(value: number);
  42078. /**
  42079. * Force the gamepad to synchronize with device values
  42080. */
  42081. update(): void;
  42082. /**
  42083. * Disposes the gamepad
  42084. */
  42085. dispose(): void;
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Manager for handling gamepads
  42091. */
  42092. export class GamepadManager {
  42093. private _scene?;
  42094. private _babylonGamepads;
  42095. private _oneGamepadConnected;
  42096. /** @hidden */
  42097. _isMonitoring: boolean;
  42098. private _gamepadEventSupported;
  42099. private _gamepadSupport?;
  42100. /**
  42101. * observable to be triggered when the gamepad controller has been connected
  42102. */
  42103. onGamepadConnectedObservable: Observable<Gamepad>;
  42104. /**
  42105. * observable to be triggered when the gamepad controller has been disconnected
  42106. */
  42107. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42108. private _onGamepadConnectedEvent;
  42109. private _onGamepadDisconnectedEvent;
  42110. /**
  42111. * Initializes the gamepad manager
  42112. * @param _scene BabylonJS scene
  42113. */
  42114. constructor(_scene?: Scene | undefined);
  42115. /**
  42116. * The gamepads in the game pad manager
  42117. */
  42118. get gamepads(): Gamepad[];
  42119. /**
  42120. * Get the gamepad controllers based on type
  42121. * @param type The type of gamepad controller
  42122. * @returns Nullable gamepad
  42123. */
  42124. getGamepadByType(type?: number): Nullable<Gamepad>;
  42125. /**
  42126. * Disposes the gamepad manager
  42127. */
  42128. dispose(): void;
  42129. private _addNewGamepad;
  42130. private _startMonitoringGamepads;
  42131. private _stopMonitoringGamepads;
  42132. /** @hidden */
  42133. _checkGamepadsStatus(): void;
  42134. private _updateGamepadObjects;
  42135. }
  42136. }
  42137. declare module BABYLON {
  42138. interface Scene {
  42139. /** @hidden */
  42140. _gamepadManager: Nullable<GamepadManager>;
  42141. /**
  42142. * Gets the gamepad manager associated with the scene
  42143. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42144. */
  42145. gamepadManager: GamepadManager;
  42146. }
  42147. /**
  42148. * Interface representing a free camera inputs manager
  42149. */
  42150. interface FreeCameraInputsManager {
  42151. /**
  42152. * Adds gamepad input support to the FreeCameraInputsManager.
  42153. * @returns the FreeCameraInputsManager
  42154. */
  42155. addGamepad(): FreeCameraInputsManager;
  42156. }
  42157. /**
  42158. * Interface representing an arc rotate camera inputs manager
  42159. */
  42160. interface ArcRotateCameraInputsManager {
  42161. /**
  42162. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42163. * @returns the camera inputs manager
  42164. */
  42165. addGamepad(): ArcRotateCameraInputsManager;
  42166. }
  42167. /**
  42168. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42169. */
  42170. export class GamepadSystemSceneComponent implements ISceneComponent {
  42171. /**
  42172. * The component name helpfull to identify the component in the list of scene components.
  42173. */
  42174. readonly name: string;
  42175. /**
  42176. * The scene the component belongs to.
  42177. */
  42178. scene: Scene;
  42179. /**
  42180. * Creates a new instance of the component for the given scene
  42181. * @param scene Defines the scene to register the component in
  42182. */
  42183. constructor(scene: Scene);
  42184. /**
  42185. * Registers the component in a given scene
  42186. */
  42187. register(): void;
  42188. /**
  42189. * Rebuilds the elements related to this component in case of
  42190. * context lost for instance.
  42191. */
  42192. rebuild(): void;
  42193. /**
  42194. * Disposes the component and the associated ressources
  42195. */
  42196. dispose(): void;
  42197. private _beforeCameraUpdate;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * 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,
  42203. * which still works and will still be found in many Playgrounds.
  42204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42205. */
  42206. export class UniversalCamera extends TouchCamera {
  42207. /**
  42208. * Defines the gamepad rotation sensiblity.
  42209. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42210. */
  42211. get gamepadAngularSensibility(): number;
  42212. set gamepadAngularSensibility(value: number);
  42213. /**
  42214. * Defines the gamepad move sensiblity.
  42215. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42216. */
  42217. get gamepadMoveSensibility(): number;
  42218. set gamepadMoveSensibility(value: number);
  42219. /**
  42220. * 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,
  42221. * which still works and will still be found in many Playgrounds.
  42222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42223. * @param name Define the name of the camera in the scene
  42224. * @param position Define the start position of the camera in the scene
  42225. * @param scene Define the scene the camera belongs to
  42226. */
  42227. constructor(name: string, position: Vector3, scene: Scene);
  42228. /**
  42229. * Gets the current object class name.
  42230. * @return the class name
  42231. */
  42232. getClassName(): string;
  42233. }
  42234. }
  42235. declare module BABYLON {
  42236. /**
  42237. * This represents a FPS type of camera. This is only here for back compat purpose.
  42238. * Please use the UniversalCamera instead as both are identical.
  42239. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42240. */
  42241. export class GamepadCamera extends UniversalCamera {
  42242. /**
  42243. * Instantiates a new Gamepad Camera
  42244. * This represents a FPS type of camera. This is only here for back compat purpose.
  42245. * Please use the UniversalCamera instead as both are identical.
  42246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42247. * @param name Define the name of the camera in the scene
  42248. * @param position Define the start position of the camera in the scene
  42249. * @param scene Define the scene the camera belongs to
  42250. */
  42251. constructor(name: string, position: Vector3, scene: Scene);
  42252. /**
  42253. * Gets the current object class name.
  42254. * @return the class name
  42255. */
  42256. getClassName(): string;
  42257. }
  42258. }
  42259. declare module BABYLON {
  42260. /** @hidden */
  42261. export var passPixelShader: {
  42262. name: string;
  42263. shader: string;
  42264. };
  42265. }
  42266. declare module BABYLON {
  42267. /** @hidden */
  42268. export var passCubePixelShader: {
  42269. name: string;
  42270. shader: string;
  42271. };
  42272. }
  42273. declare module BABYLON {
  42274. /**
  42275. * PassPostProcess which produces an output the same as it's input
  42276. */
  42277. export class PassPostProcess extends PostProcess {
  42278. /**
  42279. * Creates the PassPostProcess
  42280. * @param name The name of the effect.
  42281. * @param options The required width/height ratio to downsize to before computing the render pass.
  42282. * @param camera The camera to apply the render pass to.
  42283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42284. * @param engine The engine which the post process will be applied. (default: current engine)
  42285. * @param reusable If the post process can be reused on the same frame. (default: false)
  42286. * @param textureType The type of texture to be used when performing the post processing.
  42287. * @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)
  42288. */
  42289. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42290. }
  42291. /**
  42292. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42293. */
  42294. export class PassCubePostProcess extends PostProcess {
  42295. private _face;
  42296. /**
  42297. * Gets or sets the cube face to display.
  42298. * * 0 is +X
  42299. * * 1 is -X
  42300. * * 2 is +Y
  42301. * * 3 is -Y
  42302. * * 4 is +Z
  42303. * * 5 is -Z
  42304. */
  42305. get face(): number;
  42306. set face(value: number);
  42307. /**
  42308. * Creates the PassCubePostProcess
  42309. * @param name The name of the effect.
  42310. * @param options The required width/height ratio to downsize to before computing the render pass.
  42311. * @param camera The camera to apply the render pass to.
  42312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42313. * @param engine The engine which the post process will be applied. (default: current engine)
  42314. * @param reusable If the post process can be reused on the same frame. (default: false)
  42315. * @param textureType The type of texture to be used when performing the post processing.
  42316. * @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)
  42317. */
  42318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /** @hidden */
  42323. export var anaglyphPixelShader: {
  42324. name: string;
  42325. shader: string;
  42326. };
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Postprocess used to generate anaglyphic rendering
  42331. */
  42332. export class AnaglyphPostProcess extends PostProcess {
  42333. private _passedProcess;
  42334. /**
  42335. * Creates a new AnaglyphPostProcess
  42336. * @param name defines postprocess name
  42337. * @param options defines creation options or target ratio scale
  42338. * @param rigCameras defines cameras using this postprocess
  42339. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42340. * @param engine defines hosting engine
  42341. * @param reusable defines if the postprocess will be reused multiple times per frame
  42342. */
  42343. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42344. }
  42345. }
  42346. declare module BABYLON {
  42347. /**
  42348. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42349. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42350. */
  42351. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42352. /**
  42353. * Creates a new AnaglyphArcRotateCamera
  42354. * @param name defines camera name
  42355. * @param alpha defines alpha angle (in radians)
  42356. * @param beta defines beta angle (in radians)
  42357. * @param radius defines radius
  42358. * @param target defines camera target
  42359. * @param interaxialDistance defines distance between each color axis
  42360. * @param scene defines the hosting scene
  42361. */
  42362. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42363. /**
  42364. * Gets camera class name
  42365. * @returns AnaglyphArcRotateCamera
  42366. */
  42367. getClassName(): string;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42373. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42374. */
  42375. export class AnaglyphFreeCamera extends FreeCamera {
  42376. /**
  42377. * Creates a new AnaglyphFreeCamera
  42378. * @param name defines camera name
  42379. * @param position defines initial position
  42380. * @param interaxialDistance defines distance between each color axis
  42381. * @param scene defines the hosting scene
  42382. */
  42383. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42384. /**
  42385. * Gets camera class name
  42386. * @returns AnaglyphFreeCamera
  42387. */
  42388. getClassName(): string;
  42389. }
  42390. }
  42391. declare module BABYLON {
  42392. /**
  42393. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42394. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42395. */
  42396. export class AnaglyphGamepadCamera extends GamepadCamera {
  42397. /**
  42398. * Creates a new AnaglyphGamepadCamera
  42399. * @param name defines camera name
  42400. * @param position defines initial position
  42401. * @param interaxialDistance defines distance between each color axis
  42402. * @param scene defines the hosting scene
  42403. */
  42404. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42405. /**
  42406. * Gets camera class name
  42407. * @returns AnaglyphGamepadCamera
  42408. */
  42409. getClassName(): string;
  42410. }
  42411. }
  42412. declare module BABYLON {
  42413. /**
  42414. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42415. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42416. */
  42417. export class AnaglyphUniversalCamera extends UniversalCamera {
  42418. /**
  42419. * Creates a new AnaglyphUniversalCamera
  42420. * @param name defines camera name
  42421. * @param position defines initial position
  42422. * @param interaxialDistance defines distance between each color axis
  42423. * @param scene defines the hosting scene
  42424. */
  42425. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42426. /**
  42427. * Gets camera class name
  42428. * @returns AnaglyphUniversalCamera
  42429. */
  42430. getClassName(): string;
  42431. }
  42432. }
  42433. declare module BABYLON {
  42434. /**
  42435. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42436. * @see http://doc.babylonjs.com/features/cameras
  42437. */
  42438. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42439. /**
  42440. * Creates a new StereoscopicArcRotateCamera
  42441. * @param name defines camera name
  42442. * @param alpha defines alpha angle (in radians)
  42443. * @param beta defines beta angle (in radians)
  42444. * @param radius defines radius
  42445. * @param target defines camera target
  42446. * @param interaxialDistance defines distance between each color axis
  42447. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42448. * @param scene defines the hosting scene
  42449. */
  42450. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42451. /**
  42452. * Gets camera class name
  42453. * @returns StereoscopicArcRotateCamera
  42454. */
  42455. getClassName(): string;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42461. * @see http://doc.babylonjs.com/features/cameras
  42462. */
  42463. export class StereoscopicFreeCamera extends FreeCamera {
  42464. /**
  42465. * Creates a new StereoscopicFreeCamera
  42466. * @param name defines camera name
  42467. * @param position defines initial position
  42468. * @param interaxialDistance defines distance between each color axis
  42469. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42470. * @param scene defines the hosting scene
  42471. */
  42472. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42473. /**
  42474. * Gets camera class name
  42475. * @returns StereoscopicFreeCamera
  42476. */
  42477. getClassName(): string;
  42478. }
  42479. }
  42480. declare module BABYLON {
  42481. /**
  42482. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42483. * @see http://doc.babylonjs.com/features/cameras
  42484. */
  42485. export class StereoscopicGamepadCamera extends GamepadCamera {
  42486. /**
  42487. * Creates a new StereoscopicGamepadCamera
  42488. * @param name defines camera name
  42489. * @param position defines initial position
  42490. * @param interaxialDistance defines distance between each color axis
  42491. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42492. * @param scene defines the hosting scene
  42493. */
  42494. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42495. /**
  42496. * Gets camera class name
  42497. * @returns StereoscopicGamepadCamera
  42498. */
  42499. getClassName(): string;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42505. * @see http://doc.babylonjs.com/features/cameras
  42506. */
  42507. export class StereoscopicUniversalCamera extends UniversalCamera {
  42508. /**
  42509. * Creates a new StereoscopicUniversalCamera
  42510. * @param name defines camera name
  42511. * @param position defines initial position
  42512. * @param interaxialDistance defines distance between each color axis
  42513. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42514. * @param scene defines the hosting scene
  42515. */
  42516. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42517. /**
  42518. * Gets camera class name
  42519. * @returns StereoscopicUniversalCamera
  42520. */
  42521. getClassName(): string;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42527. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42528. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42529. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42530. */
  42531. export class VirtualJoysticksCamera extends FreeCamera {
  42532. /**
  42533. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42534. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42535. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42536. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42537. * @param name Define the name of the camera in the scene
  42538. * @param position Define the start position of the camera in the scene
  42539. * @param scene Define the scene the camera belongs to
  42540. */
  42541. constructor(name: string, position: Vector3, scene: Scene);
  42542. /**
  42543. * Gets the current object class name.
  42544. * @return the class name
  42545. */
  42546. getClassName(): string;
  42547. }
  42548. }
  42549. declare module BABYLON {
  42550. /**
  42551. * This represents all the required metrics to create a VR camera.
  42552. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42553. */
  42554. export class VRCameraMetrics {
  42555. /**
  42556. * Define the horizontal resolution off the screen.
  42557. */
  42558. hResolution: number;
  42559. /**
  42560. * Define the vertical resolution off the screen.
  42561. */
  42562. vResolution: number;
  42563. /**
  42564. * Define the horizontal screen size.
  42565. */
  42566. hScreenSize: number;
  42567. /**
  42568. * Define the vertical screen size.
  42569. */
  42570. vScreenSize: number;
  42571. /**
  42572. * Define the vertical screen center position.
  42573. */
  42574. vScreenCenter: number;
  42575. /**
  42576. * Define the distance of the eyes to the screen.
  42577. */
  42578. eyeToScreenDistance: number;
  42579. /**
  42580. * Define the distance between both lenses
  42581. */
  42582. lensSeparationDistance: number;
  42583. /**
  42584. * Define the distance between both viewer's eyes.
  42585. */
  42586. interpupillaryDistance: number;
  42587. /**
  42588. * Define the distortion factor of the VR postprocess.
  42589. * Please, touch with care.
  42590. */
  42591. distortionK: number[];
  42592. /**
  42593. * Define the chromatic aberration correction factors for the VR post process.
  42594. */
  42595. chromaAbCorrection: number[];
  42596. /**
  42597. * Define the scale factor of the post process.
  42598. * The smaller the better but the slower.
  42599. */
  42600. postProcessScaleFactor: number;
  42601. /**
  42602. * Define an offset for the lens center.
  42603. */
  42604. lensCenterOffset: number;
  42605. /**
  42606. * Define if the current vr camera should compensate the distortion of the lense or not.
  42607. */
  42608. compensateDistortion: boolean;
  42609. /**
  42610. * Defines if multiview should be enabled when rendering (Default: false)
  42611. */
  42612. multiviewEnabled: boolean;
  42613. /**
  42614. * Gets the rendering aspect ratio based on the provided resolutions.
  42615. */
  42616. get aspectRatio(): number;
  42617. /**
  42618. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42619. */
  42620. get aspectRatioFov(): number;
  42621. /**
  42622. * @hidden
  42623. */
  42624. get leftHMatrix(): Matrix;
  42625. /**
  42626. * @hidden
  42627. */
  42628. get rightHMatrix(): Matrix;
  42629. /**
  42630. * @hidden
  42631. */
  42632. get leftPreViewMatrix(): Matrix;
  42633. /**
  42634. * @hidden
  42635. */
  42636. get rightPreViewMatrix(): Matrix;
  42637. /**
  42638. * Get the default VRMetrics based on the most generic setup.
  42639. * @returns the default vr metrics
  42640. */
  42641. static GetDefault(): VRCameraMetrics;
  42642. }
  42643. }
  42644. declare module BABYLON {
  42645. /** @hidden */
  42646. export var vrDistortionCorrectionPixelShader: {
  42647. name: string;
  42648. shader: string;
  42649. };
  42650. }
  42651. declare module BABYLON {
  42652. /**
  42653. * VRDistortionCorrectionPostProcess used for mobile VR
  42654. */
  42655. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42656. private _isRightEye;
  42657. private _distortionFactors;
  42658. private _postProcessScaleFactor;
  42659. private _lensCenterOffset;
  42660. private _scaleIn;
  42661. private _scaleFactor;
  42662. private _lensCenter;
  42663. /**
  42664. * Initializes the VRDistortionCorrectionPostProcess
  42665. * @param name The name of the effect.
  42666. * @param camera The camera to apply the render pass to.
  42667. * @param isRightEye If this is for the right eye distortion
  42668. * @param vrMetrics All the required metrics for the VR camera
  42669. */
  42670. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42671. }
  42672. }
  42673. declare module BABYLON {
  42674. /**
  42675. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42676. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42677. */
  42678. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42679. /**
  42680. * Creates a new VRDeviceOrientationArcRotateCamera
  42681. * @param name defines camera name
  42682. * @param alpha defines the camera rotation along the logitudinal axis
  42683. * @param beta defines the camera rotation along the latitudinal axis
  42684. * @param radius defines the camera distance from its target
  42685. * @param target defines the camera target
  42686. * @param scene defines the scene the camera belongs to
  42687. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42688. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42689. */
  42690. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42691. /**
  42692. * Gets camera class name
  42693. * @returns VRDeviceOrientationArcRotateCamera
  42694. */
  42695. getClassName(): string;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /**
  42700. * Camera used to simulate VR rendering (based on FreeCamera)
  42701. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42702. */
  42703. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42704. /**
  42705. * Creates a new VRDeviceOrientationFreeCamera
  42706. * @param name defines camera name
  42707. * @param position defines the start position of the camera
  42708. * @param scene defines the scene the camera belongs to
  42709. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42710. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42711. */
  42712. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42713. /**
  42714. * Gets camera class name
  42715. * @returns VRDeviceOrientationFreeCamera
  42716. */
  42717. getClassName(): string;
  42718. }
  42719. }
  42720. declare module BABYLON {
  42721. /**
  42722. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42723. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42724. */
  42725. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42726. /**
  42727. * Creates a new VRDeviceOrientationGamepadCamera
  42728. * @param name defines camera name
  42729. * @param position defines the start position of the camera
  42730. * @param scene defines the scene the camera belongs to
  42731. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42732. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42733. */
  42734. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42735. /**
  42736. * Gets camera class name
  42737. * @returns VRDeviceOrientationGamepadCamera
  42738. */
  42739. getClassName(): string;
  42740. }
  42741. }
  42742. declare module BABYLON {
  42743. /** @hidden */
  42744. export var imageProcessingPixelShader: {
  42745. name: string;
  42746. shader: string;
  42747. };
  42748. }
  42749. declare module BABYLON {
  42750. /**
  42751. * ImageProcessingPostProcess
  42752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42753. */
  42754. export class ImageProcessingPostProcess extends PostProcess {
  42755. /**
  42756. * Default configuration related to image processing available in the PBR Material.
  42757. */
  42758. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42759. /**
  42760. * Gets the image processing configuration used either in this material.
  42761. */
  42762. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42763. /**
  42764. * Sets the Default image processing configuration used either in the this material.
  42765. *
  42766. * If sets to null, the scene one is in use.
  42767. */
  42768. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42769. /**
  42770. * Keep track of the image processing observer to allow dispose and replace.
  42771. */
  42772. private _imageProcessingObserver;
  42773. /**
  42774. * Attaches a new image processing configuration to the PBR Material.
  42775. * @param configuration
  42776. */
  42777. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42778. /**
  42779. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42780. */
  42781. get colorCurves(): Nullable<ColorCurves>;
  42782. /**
  42783. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42784. */
  42785. set colorCurves(value: Nullable<ColorCurves>);
  42786. /**
  42787. * Gets wether the color curves effect is enabled.
  42788. */
  42789. get colorCurvesEnabled(): boolean;
  42790. /**
  42791. * Sets wether the color curves effect is enabled.
  42792. */
  42793. set colorCurvesEnabled(value: boolean);
  42794. /**
  42795. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42796. */
  42797. get colorGradingTexture(): Nullable<BaseTexture>;
  42798. /**
  42799. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42800. */
  42801. set colorGradingTexture(value: Nullable<BaseTexture>);
  42802. /**
  42803. * Gets wether the color grading effect is enabled.
  42804. */
  42805. get colorGradingEnabled(): boolean;
  42806. /**
  42807. * Gets wether the color grading effect is enabled.
  42808. */
  42809. set colorGradingEnabled(value: boolean);
  42810. /**
  42811. * Gets exposure used in the effect.
  42812. */
  42813. get exposure(): number;
  42814. /**
  42815. * Sets exposure used in the effect.
  42816. */
  42817. set exposure(value: number);
  42818. /**
  42819. * Gets wether tonemapping is enabled or not.
  42820. */
  42821. get toneMappingEnabled(): boolean;
  42822. /**
  42823. * Sets wether tonemapping is enabled or not
  42824. */
  42825. set toneMappingEnabled(value: boolean);
  42826. /**
  42827. * Gets the type of tone mapping effect.
  42828. */
  42829. get toneMappingType(): number;
  42830. /**
  42831. * Sets the type of tone mapping effect.
  42832. */
  42833. set toneMappingType(value: number);
  42834. /**
  42835. * Gets contrast used in the effect.
  42836. */
  42837. get contrast(): number;
  42838. /**
  42839. * Sets contrast used in the effect.
  42840. */
  42841. set contrast(value: number);
  42842. /**
  42843. * Gets Vignette stretch size.
  42844. */
  42845. get vignetteStretch(): number;
  42846. /**
  42847. * Sets Vignette stretch size.
  42848. */
  42849. set vignetteStretch(value: number);
  42850. /**
  42851. * Gets Vignette centre X Offset.
  42852. */
  42853. get vignetteCentreX(): number;
  42854. /**
  42855. * Sets Vignette centre X Offset.
  42856. */
  42857. set vignetteCentreX(value: number);
  42858. /**
  42859. * Gets Vignette centre Y Offset.
  42860. */
  42861. get vignetteCentreY(): number;
  42862. /**
  42863. * Sets Vignette centre Y Offset.
  42864. */
  42865. set vignetteCentreY(value: number);
  42866. /**
  42867. * Gets Vignette weight or intensity of the vignette effect.
  42868. */
  42869. get vignetteWeight(): number;
  42870. /**
  42871. * Sets Vignette weight or intensity of the vignette effect.
  42872. */
  42873. set vignetteWeight(value: number);
  42874. /**
  42875. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42876. * if vignetteEnabled is set to true.
  42877. */
  42878. get vignetteColor(): Color4;
  42879. /**
  42880. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42881. * if vignetteEnabled is set to true.
  42882. */
  42883. set vignetteColor(value: Color4);
  42884. /**
  42885. * Gets Camera field of view used by the Vignette effect.
  42886. */
  42887. get vignetteCameraFov(): number;
  42888. /**
  42889. * Sets Camera field of view used by the Vignette effect.
  42890. */
  42891. set vignetteCameraFov(value: number);
  42892. /**
  42893. * Gets the vignette blend mode allowing different kind of effect.
  42894. */
  42895. get vignetteBlendMode(): number;
  42896. /**
  42897. * Sets the vignette blend mode allowing different kind of effect.
  42898. */
  42899. set vignetteBlendMode(value: number);
  42900. /**
  42901. * Gets wether the vignette effect is enabled.
  42902. */
  42903. get vignetteEnabled(): boolean;
  42904. /**
  42905. * Sets wether the vignette effect is enabled.
  42906. */
  42907. set vignetteEnabled(value: boolean);
  42908. private _fromLinearSpace;
  42909. /**
  42910. * Gets wether the input of the processing is in Gamma or Linear Space.
  42911. */
  42912. get fromLinearSpace(): boolean;
  42913. /**
  42914. * Sets wether the input of the processing is in Gamma or Linear Space.
  42915. */
  42916. set fromLinearSpace(value: boolean);
  42917. /**
  42918. * Defines cache preventing GC.
  42919. */
  42920. private _defines;
  42921. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42922. /**
  42923. * "ImageProcessingPostProcess"
  42924. * @returns "ImageProcessingPostProcess"
  42925. */
  42926. getClassName(): string;
  42927. protected _updateParameters(): void;
  42928. dispose(camera?: Camera): void;
  42929. }
  42930. }
  42931. declare module BABYLON {
  42932. /**
  42933. * Class containing static functions to help procedurally build meshes
  42934. */
  42935. export class GroundBuilder {
  42936. /**
  42937. * Creates a ground mesh
  42938. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42939. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42941. * @param name defines the name of the mesh
  42942. * @param options defines the options used to create the mesh
  42943. * @param scene defines the hosting scene
  42944. * @returns the ground mesh
  42945. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42946. */
  42947. static CreateGround(name: string, options: {
  42948. width?: number;
  42949. height?: number;
  42950. subdivisions?: number;
  42951. subdivisionsX?: number;
  42952. subdivisionsY?: number;
  42953. updatable?: boolean;
  42954. }, scene: any): Mesh;
  42955. /**
  42956. * Creates a tiled ground mesh
  42957. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42958. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42959. * * 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
  42960. * * 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
  42961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42962. * @param name defines the name of the mesh
  42963. * @param options defines the options used to create the mesh
  42964. * @param scene defines the hosting scene
  42965. * @returns the tiled ground mesh
  42966. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42967. */
  42968. static CreateTiledGround(name: string, options: {
  42969. xmin: number;
  42970. zmin: number;
  42971. xmax: number;
  42972. zmax: number;
  42973. subdivisions?: {
  42974. w: number;
  42975. h: number;
  42976. };
  42977. precision?: {
  42978. w: number;
  42979. h: number;
  42980. };
  42981. updatable?: boolean;
  42982. }, scene?: Nullable<Scene>): Mesh;
  42983. /**
  42984. * Creates a ground mesh from a height map
  42985. * * The parameter `url` sets the URL of the height map image resource.
  42986. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42987. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42988. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42989. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42990. * * 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.
  42991. * * 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).
  42992. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42994. * @param name defines the name of the mesh
  42995. * @param url defines the url to the height map
  42996. * @param options defines the options used to create the mesh
  42997. * @param scene defines the hosting scene
  42998. * @returns the ground mesh
  42999. * @see https://doc.babylonjs.com/babylon101/height_map
  43000. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43001. */
  43002. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43003. width?: number;
  43004. height?: number;
  43005. subdivisions?: number;
  43006. minHeight?: number;
  43007. maxHeight?: number;
  43008. colorFilter?: Color3;
  43009. alphaFilter?: number;
  43010. updatable?: boolean;
  43011. onReady?: (mesh: GroundMesh) => void;
  43012. }, scene?: Nullable<Scene>): GroundMesh;
  43013. }
  43014. }
  43015. declare module BABYLON {
  43016. /**
  43017. * Class containing static functions to help procedurally build meshes
  43018. */
  43019. export class TorusBuilder {
  43020. /**
  43021. * Creates a torus mesh
  43022. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43023. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43024. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43026. * * 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
  43027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43028. * @param name defines the name of the mesh
  43029. * @param options defines the options used to create the mesh
  43030. * @param scene defines the hosting scene
  43031. * @returns the torus mesh
  43032. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43033. */
  43034. static CreateTorus(name: string, options: {
  43035. diameter?: number;
  43036. thickness?: number;
  43037. tessellation?: number;
  43038. updatable?: boolean;
  43039. sideOrientation?: number;
  43040. frontUVs?: Vector4;
  43041. backUVs?: Vector4;
  43042. }, scene: any): Mesh;
  43043. }
  43044. }
  43045. declare module BABYLON {
  43046. /**
  43047. * Class containing static functions to help procedurally build meshes
  43048. */
  43049. export class CylinderBuilder {
  43050. /**
  43051. * Creates a cylinder or a cone mesh
  43052. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43053. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43054. * * 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.
  43055. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43056. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43057. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43058. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43059. * * 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).
  43060. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43061. * * 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).
  43062. * * 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
  43063. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43064. * * 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
  43065. * * 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.
  43066. * * If `enclose` is false, a ring surface is one element.
  43067. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43068. * * 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
  43069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43070. * * 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
  43071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43072. * @param name defines the name of the mesh
  43073. * @param options defines the options used to create the mesh
  43074. * @param scene defines the hosting scene
  43075. * @returns the cylinder mesh
  43076. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43077. */
  43078. static CreateCylinder(name: string, options: {
  43079. height?: number;
  43080. diameterTop?: number;
  43081. diameterBottom?: number;
  43082. diameter?: number;
  43083. tessellation?: number;
  43084. subdivisions?: number;
  43085. arc?: number;
  43086. faceColors?: Color4[];
  43087. faceUV?: Vector4[];
  43088. updatable?: boolean;
  43089. hasRings?: boolean;
  43090. enclose?: boolean;
  43091. cap?: number;
  43092. sideOrientation?: number;
  43093. frontUVs?: Vector4;
  43094. backUVs?: Vector4;
  43095. }, scene: any): Mesh;
  43096. }
  43097. }
  43098. declare module BABYLON {
  43099. /**
  43100. * States of the webXR experience
  43101. */
  43102. export enum WebXRState {
  43103. /**
  43104. * Transitioning to being in XR mode
  43105. */
  43106. ENTERING_XR = 0,
  43107. /**
  43108. * Transitioning to non XR mode
  43109. */
  43110. EXITING_XR = 1,
  43111. /**
  43112. * In XR mode and presenting
  43113. */
  43114. IN_XR = 2,
  43115. /**
  43116. * Not entered XR mode
  43117. */
  43118. NOT_IN_XR = 3
  43119. }
  43120. /**
  43121. * Abstraction of the XR render target
  43122. */
  43123. export interface WebXRRenderTarget extends IDisposable {
  43124. /**
  43125. * xrpresent context of the canvas which can be used to display/mirror xr content
  43126. */
  43127. canvasContext: WebGLRenderingContext;
  43128. /**
  43129. * xr layer for the canvas
  43130. */
  43131. xrLayer: Nullable<XRWebGLLayer>;
  43132. /**
  43133. * Initializes the xr layer for the session
  43134. * @param xrSession xr session
  43135. * @returns a promise that will resolve once the XR Layer has been created
  43136. */
  43137. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43138. }
  43139. }
  43140. declare module BABYLON {
  43141. /**
  43142. * COnfiguration object for WebXR output canvas
  43143. */
  43144. export class WebXRManagedOutputCanvasOptions {
  43145. /**
  43146. * An optional canvas in case you wish to create it yourself and provide it here.
  43147. * If not provided, a new canvas will be created
  43148. */
  43149. canvasElement?: HTMLCanvasElement;
  43150. /**
  43151. * Options for this XR Layer output
  43152. */
  43153. canvasOptions?: XRWebGLLayerOptions;
  43154. /**
  43155. * CSS styling for a newly created canvas (if not provided)
  43156. */
  43157. newCanvasCssStyle?: string;
  43158. /**
  43159. * Get the default values of the configuration object
  43160. * @returns default values of this configuration object
  43161. */
  43162. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43163. }
  43164. /**
  43165. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43166. */
  43167. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43168. private _options;
  43169. private _canvas;
  43170. private _engine;
  43171. /**
  43172. * Rendering context of the canvas which can be used to display/mirror xr content
  43173. */
  43174. canvasContext: WebGLRenderingContext;
  43175. /**
  43176. * xr layer for the canvas
  43177. */
  43178. xrLayer: Nullable<XRWebGLLayer>;
  43179. /**
  43180. * Initializes the canvas to be added/removed upon entering/exiting xr
  43181. * @param _xrSessionManager The XR Session manager
  43182. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43183. */
  43184. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43185. /**
  43186. * Disposes of the object
  43187. */
  43188. dispose(): void;
  43189. /**
  43190. * Initializes the xr layer for the session
  43191. * @param xrSession xr session
  43192. * @returns a promise that will resolve once the XR Layer has been created
  43193. */
  43194. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43195. private _addCanvas;
  43196. private _removeCanvas;
  43197. private _setManagedOutputCanvas;
  43198. }
  43199. }
  43200. declare module BABYLON {
  43201. /**
  43202. * Manages an XRSession to work with Babylon's engine
  43203. * @see https://doc.babylonjs.com/how_to/webxr
  43204. */
  43205. export class WebXRSessionManager implements IDisposable {
  43206. /** The scene which the session should be created for */
  43207. scene: Scene;
  43208. private _referenceSpace;
  43209. private _rttProvider;
  43210. private _sessionEnded;
  43211. private _xrNavigator;
  43212. private baseLayer;
  43213. /**
  43214. * The base reference space from which the session started. good if you want to reset your
  43215. * reference space
  43216. */
  43217. baseReferenceSpace: XRReferenceSpace;
  43218. /**
  43219. * Current XR frame
  43220. */
  43221. currentFrame: Nullable<XRFrame>;
  43222. /** WebXR timestamp updated every frame */
  43223. currentTimestamp: number;
  43224. /**
  43225. * Used just in case of a failure to initialize an immersive session.
  43226. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43227. */
  43228. defaultHeightCompensation: number;
  43229. /**
  43230. * Fires every time a new xrFrame arrives which can be used to update the camera
  43231. */
  43232. onXRFrameObservable: Observable<XRFrame>;
  43233. /**
  43234. * Fires when the reference space changed
  43235. */
  43236. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43237. /**
  43238. * Fires when the xr session is ended either by the device or manually done
  43239. */
  43240. onXRSessionEnded: Observable<any>;
  43241. /**
  43242. * Fires when the xr session is ended either by the device or manually done
  43243. */
  43244. onXRSessionInit: Observable<XRSession>;
  43245. /**
  43246. * Underlying xr session
  43247. */
  43248. session: XRSession;
  43249. /**
  43250. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43251. * or get the offset the player is currently at.
  43252. */
  43253. viewerReferenceSpace: XRReferenceSpace;
  43254. /**
  43255. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43256. * @param scene The scene which the session should be created for
  43257. */
  43258. constructor(
  43259. /** The scene which the session should be created for */
  43260. scene: Scene);
  43261. /**
  43262. * The current reference space used in this session. This reference space can constantly change!
  43263. * It is mainly used to offset the camera's position.
  43264. */
  43265. get referenceSpace(): XRReferenceSpace;
  43266. /**
  43267. * Set a new reference space and triggers the observable
  43268. */
  43269. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43270. /**
  43271. * Disposes of the session manager
  43272. */
  43273. dispose(): void;
  43274. /**
  43275. * Stops the xrSession and restores the render loop
  43276. * @returns Promise which resolves after it exits XR
  43277. */
  43278. exitXRAsync(): Promise<void>;
  43279. /**
  43280. * Gets the correct render target texture to be rendered this frame for this eye
  43281. * @param eye the eye for which to get the render target
  43282. * @returns the render target for the specified eye
  43283. */
  43284. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43285. /**
  43286. * Creates a WebXRRenderTarget object for the XR session
  43287. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43288. * @param options optional options to provide when creating a new render target
  43289. * @returns a WebXR render target to which the session can render
  43290. */
  43291. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43292. /**
  43293. * Initializes the manager
  43294. * After initialization enterXR can be called to start an XR session
  43295. * @returns Promise which resolves after it is initialized
  43296. */
  43297. initializeAsync(): Promise<void>;
  43298. /**
  43299. * Initializes an xr session
  43300. * @param xrSessionMode mode to initialize
  43301. * @param xrSessionInit defines optional and required values to pass to the session builder
  43302. * @returns a promise which will resolve once the session has been initialized
  43303. */
  43304. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43305. /**
  43306. * Checks if a session would be supported for the creation options specified
  43307. * @param sessionMode session mode to check if supported eg. immersive-vr
  43308. * @returns A Promise that resolves to true if supported and false if not
  43309. */
  43310. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43311. /**
  43312. * Resets the reference space to the one started the session
  43313. */
  43314. resetReferenceSpace(): void;
  43315. /**
  43316. * Starts rendering to the xr layer
  43317. */
  43318. runXRRenderLoop(): void;
  43319. /**
  43320. * Sets the reference space on the xr session
  43321. * @param referenceSpaceType space to set
  43322. * @returns a promise that will resolve once the reference space has been set
  43323. */
  43324. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43325. /**
  43326. * Updates the render state of the session
  43327. * @param state state to set
  43328. * @returns a promise that resolves once the render state has been updated
  43329. */
  43330. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43331. /**
  43332. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43333. * @param sessionMode defines the session to test
  43334. * @returns a promise with boolean as final value
  43335. */
  43336. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43337. private _createRenderTargetTexture;
  43338. }
  43339. }
  43340. declare module BABYLON {
  43341. /**
  43342. * WebXR Camera which holds the views for the xrSession
  43343. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43344. */
  43345. export class WebXRCamera extends FreeCamera {
  43346. private _xrSessionManager;
  43347. private _firstFrame;
  43348. private _referenceQuaternion;
  43349. private _referencedPosition;
  43350. private _xrInvPositionCache;
  43351. private _xrInvQuaternionCache;
  43352. /**
  43353. * Should position compensation execute on first frame.
  43354. * This is used when copying the position from a native (non XR) camera
  43355. */
  43356. compensateOnFirstFrame: boolean;
  43357. /**
  43358. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43359. * @param name the name of the camera
  43360. * @param scene the scene to add the camera to
  43361. * @param _xrSessionManager a constructed xr session manager
  43362. */
  43363. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43364. /**
  43365. * Return the user's height, unrelated to the current ground.
  43366. * This will be the y position of this camera, when ground level is 0.
  43367. */
  43368. get realWorldHeight(): number;
  43369. /** @hidden */
  43370. _updateForDualEyeDebugging(): void;
  43371. /**
  43372. * Sets this camera's transformation based on a non-vr camera
  43373. * @param otherCamera the non-vr camera to copy the transformation from
  43374. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43375. */
  43376. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43377. /**
  43378. * Gets the current instance class name ("WebXRCamera").
  43379. * @returns the class name
  43380. */
  43381. getClassName(): string;
  43382. private _updateFromXRSession;
  43383. private _updateNumberOfRigCameras;
  43384. private _updateReferenceSpace;
  43385. private _updateReferenceSpaceOffset;
  43386. }
  43387. }
  43388. declare module BABYLON {
  43389. /**
  43390. * Defining the interface required for a (webxr) feature
  43391. */
  43392. export interface IWebXRFeature extends IDisposable {
  43393. /**
  43394. * Is this feature attached
  43395. */
  43396. attached: boolean;
  43397. /**
  43398. * Should auto-attach be disabled?
  43399. */
  43400. disableAutoAttach: boolean;
  43401. /**
  43402. * Attach the feature to the session
  43403. * Will usually be called by the features manager
  43404. *
  43405. * @param force should attachment be forced (even when already attached)
  43406. * @returns true if successful.
  43407. */
  43408. attach(force?: boolean): boolean;
  43409. /**
  43410. * Detach the feature from the session
  43411. * Will usually be called by the features manager
  43412. *
  43413. * @returns true if successful.
  43414. */
  43415. detach(): boolean;
  43416. }
  43417. /**
  43418. * A list of the currently available features without referencing them
  43419. */
  43420. export class WebXRFeatureName {
  43421. /**
  43422. * The name of the anchor system feature
  43423. */
  43424. static ANCHOR_SYSTEM: string;
  43425. /**
  43426. * The name of the background remover feature
  43427. */
  43428. static BACKGROUND_REMOVER: string;
  43429. /**
  43430. * The name of the hit test feature
  43431. */
  43432. static HIT_TEST: string;
  43433. /**
  43434. * physics impostors for xr controllers feature
  43435. */
  43436. static PHYSICS_CONTROLLERS: string;
  43437. /**
  43438. * The name of the plane detection feature
  43439. */
  43440. static PLANE_DETECTION: string;
  43441. /**
  43442. * The name of the pointer selection feature
  43443. */
  43444. static POINTER_SELECTION: string;
  43445. /**
  43446. * The name of the teleportation feature
  43447. */
  43448. static TELEPORTATION: string;
  43449. }
  43450. /**
  43451. * Defining the constructor of a feature. Used to register the modules.
  43452. */
  43453. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43454. /**
  43455. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43456. * It is mainly used in AR sessions.
  43457. *
  43458. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43459. */
  43460. export class WebXRFeaturesManager implements IDisposable {
  43461. private _xrSessionManager;
  43462. private static readonly _AvailableFeatures;
  43463. private _features;
  43464. /**
  43465. * constructs a new features manages.
  43466. *
  43467. * @param _xrSessionManager an instance of WebXRSessionManager
  43468. */
  43469. constructor(_xrSessionManager: WebXRSessionManager);
  43470. /**
  43471. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43472. * Mainly used internally.
  43473. *
  43474. * @param featureName the name of the feature to register
  43475. * @param constructorFunction the function used to construct the module
  43476. * @param version the (babylon) version of the module
  43477. * @param stable is that a stable version of this module
  43478. */
  43479. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43480. /**
  43481. * Returns a constructor of a specific feature.
  43482. *
  43483. * @param featureName the name of the feature to construct
  43484. * @param version the version of the feature to load
  43485. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43486. * @param options optional options provided to the module.
  43487. * @returns a function that, when called, will return a new instance of this feature
  43488. */
  43489. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43490. /**
  43491. * Can be used to return the list of features currently registered
  43492. *
  43493. * @returns an Array of available features
  43494. */
  43495. static GetAvailableFeatures(): string[];
  43496. /**
  43497. * Gets the versions available for a specific feature
  43498. * @param featureName the name of the feature
  43499. * @returns an array with the available versions
  43500. */
  43501. static GetAvailableVersions(featureName: string): string[];
  43502. /**
  43503. * Return the latest unstable version of this feature
  43504. * @param featureName the name of the feature to search
  43505. * @returns the version number. if not found will return -1
  43506. */
  43507. static GetLatestVersionOfFeature(featureName: string): number;
  43508. /**
  43509. * Return the latest stable version of this feature
  43510. * @param featureName the name of the feature to search
  43511. * @returns the version number. if not found will return -1
  43512. */
  43513. static GetStableVersionOfFeature(featureName: string): number;
  43514. /**
  43515. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43516. * Can be used during a session to start a feature
  43517. * @param featureName the name of feature to attach
  43518. */
  43519. attachFeature(featureName: string): void;
  43520. /**
  43521. * Can be used inside a session or when the session ends to detach a specific feature
  43522. * @param featureName the name of the feature to detach
  43523. */
  43524. detachFeature(featureName: string): void;
  43525. /**
  43526. * Used to disable an already-enabled feature
  43527. * The feature will be disposed and will be recreated once enabled.
  43528. * @param featureName the feature to disable
  43529. * @returns true if disable was successful
  43530. */
  43531. disableFeature(featureName: string | {
  43532. Name: string;
  43533. }): boolean;
  43534. /**
  43535. * dispose this features manager
  43536. */
  43537. dispose(): void;
  43538. /**
  43539. * 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.
  43540. * 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.
  43541. *
  43542. * @param featureName the name of the feature to load or the class of the feature
  43543. * @param version optional version to load. if not provided the latest version will be enabled
  43544. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43545. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43546. * @returns a new constructed feature or throws an error if feature not found.
  43547. */
  43548. enableFeature(featureName: string | {
  43549. Name: string;
  43550. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43551. /**
  43552. * get the implementation of an enabled feature.
  43553. * @param featureName the name of the feature to load
  43554. * @returns the feature class, if found
  43555. */
  43556. getEnabledFeature(featureName: string): IWebXRFeature;
  43557. /**
  43558. * Get the list of enabled features
  43559. * @returns an array of enabled features
  43560. */
  43561. getEnabledFeatures(): string[];
  43562. }
  43563. }
  43564. declare module BABYLON {
  43565. /**
  43566. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43567. * @see https://doc.babylonjs.com/how_to/webxr
  43568. */
  43569. export class WebXRExperienceHelper implements IDisposable {
  43570. private scene;
  43571. private _nonVRCamera;
  43572. private _originalSceneAutoClear;
  43573. private _supported;
  43574. /**
  43575. * Camera used to render xr content
  43576. */
  43577. camera: WebXRCamera;
  43578. /** A features manager for this xr session */
  43579. featuresManager: WebXRFeaturesManager;
  43580. /**
  43581. * Observers registered here will be triggered after the camera's initial transformation is set
  43582. * This can be used to set a different ground level or an extra rotation.
  43583. *
  43584. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43585. * to the position set after this observable is done executing.
  43586. */
  43587. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43588. /**
  43589. * Fires when the state of the experience helper has changed
  43590. */
  43591. onStateChangedObservable: Observable<WebXRState>;
  43592. /** Session manager used to keep track of xr session */
  43593. sessionManager: WebXRSessionManager;
  43594. /**
  43595. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43596. */
  43597. state: WebXRState;
  43598. /**
  43599. * Creates a WebXRExperienceHelper
  43600. * @param scene The scene the helper should be created in
  43601. */
  43602. private constructor();
  43603. /**
  43604. * Creates the experience helper
  43605. * @param scene the scene to attach the experience helper to
  43606. * @returns a promise for the experience helper
  43607. */
  43608. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43609. /**
  43610. * Disposes of the experience helper
  43611. */
  43612. dispose(): void;
  43613. /**
  43614. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43615. * @param sessionMode options for the XR session
  43616. * @param referenceSpaceType frame of reference of the XR session
  43617. * @param renderTarget the output canvas that will be used to enter XR mode
  43618. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  43619. * @returns promise that resolves after xr mode has entered
  43620. */
  43621. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  43622. /**
  43623. * Exits XR mode and returns the scene to its original state
  43624. * @returns promise that resolves after xr mode has exited
  43625. */
  43626. exitXRAsync(): Promise<void>;
  43627. private _nonXRToXRCamera;
  43628. private _setState;
  43629. }
  43630. }
  43631. declare module BABYLON {
  43632. /**
  43633. * X-Y values for axes in WebXR
  43634. */
  43635. export interface IWebXRMotionControllerAxesValue {
  43636. /**
  43637. * The value of the x axis
  43638. */
  43639. x: number;
  43640. /**
  43641. * The value of the y-axis
  43642. */
  43643. y: number;
  43644. }
  43645. /**
  43646. * changed / previous values for the values of this component
  43647. */
  43648. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43649. /**
  43650. * current (this frame) value
  43651. */
  43652. current: T;
  43653. /**
  43654. * previous (last change) value
  43655. */
  43656. previous: T;
  43657. }
  43658. /**
  43659. * Represents changes in the component between current frame and last values recorded
  43660. */
  43661. export interface IWebXRMotionControllerComponentChanges {
  43662. /**
  43663. * will be populated with previous and current values if axes changed
  43664. */
  43665. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43666. /**
  43667. * will be populated with previous and current values if pressed changed
  43668. */
  43669. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43670. /**
  43671. * will be populated with previous and current values if touched changed
  43672. */
  43673. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43674. /**
  43675. * will be populated with previous and current values if value changed
  43676. */
  43677. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43678. }
  43679. /**
  43680. * This class represents a single component (for example button or thumbstick) of a motion controller
  43681. */
  43682. export class WebXRControllerComponent implements IDisposable {
  43683. /**
  43684. * the id of this component
  43685. */
  43686. id: string;
  43687. /**
  43688. * the type of the component
  43689. */
  43690. type: MotionControllerComponentType;
  43691. private _buttonIndex;
  43692. private _axesIndices;
  43693. private _axes;
  43694. private _changes;
  43695. private _currentValue;
  43696. private _hasChanges;
  43697. private _pressed;
  43698. private _touched;
  43699. /**
  43700. * button component type
  43701. */
  43702. static BUTTON_TYPE: MotionControllerComponentType;
  43703. /**
  43704. * squeeze component type
  43705. */
  43706. static SQUEEZE_TYPE: MotionControllerComponentType;
  43707. /**
  43708. * Thumbstick component type
  43709. */
  43710. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43711. /**
  43712. * Touchpad component type
  43713. */
  43714. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43715. /**
  43716. * trigger component type
  43717. */
  43718. static TRIGGER_TYPE: MotionControllerComponentType;
  43719. /**
  43720. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43721. * the axes data changes
  43722. */
  43723. onAxisValueChangedObservable: Observable<{
  43724. x: number;
  43725. y: number;
  43726. }>;
  43727. /**
  43728. * Observers registered here will be triggered when the state of a button changes
  43729. * State change is either pressed / touched / value
  43730. */
  43731. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43732. /**
  43733. * Creates a new component for a motion controller.
  43734. * It is created by the motion controller itself
  43735. *
  43736. * @param id the id of this component
  43737. * @param type the type of the component
  43738. * @param _buttonIndex index in the buttons array of the gamepad
  43739. * @param _axesIndices indices of the values in the axes array of the gamepad
  43740. */
  43741. constructor(
  43742. /**
  43743. * the id of this component
  43744. */
  43745. id: string,
  43746. /**
  43747. * the type of the component
  43748. */
  43749. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43750. /**
  43751. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43752. */
  43753. get axes(): IWebXRMotionControllerAxesValue;
  43754. /**
  43755. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43756. */
  43757. get changes(): IWebXRMotionControllerComponentChanges;
  43758. /**
  43759. * Return whether or not the component changed the last frame
  43760. */
  43761. get hasChanges(): boolean;
  43762. /**
  43763. * is the button currently pressed
  43764. */
  43765. get pressed(): boolean;
  43766. /**
  43767. * is the button currently touched
  43768. */
  43769. get touched(): boolean;
  43770. /**
  43771. * Get the current value of this component
  43772. */
  43773. get value(): number;
  43774. /**
  43775. * Dispose this component
  43776. */
  43777. dispose(): void;
  43778. /**
  43779. * Are there axes correlating to this component
  43780. * @return true is axes data is available
  43781. */
  43782. isAxes(): boolean;
  43783. /**
  43784. * Is this component a button (hence - pressable)
  43785. * @returns true if can be pressed
  43786. */
  43787. isButton(): boolean;
  43788. /**
  43789. * update this component using the gamepad object it is in. Called on every frame
  43790. * @param nativeController the native gamepad controller object
  43791. */
  43792. update(nativeController: IMinimalMotionControllerObject): void;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. /**
  43797. * Class used to represent data loading progression
  43798. */
  43799. export class SceneLoaderProgressEvent {
  43800. /** defines if data length to load can be evaluated */
  43801. readonly lengthComputable: boolean;
  43802. /** defines the loaded data length */
  43803. readonly loaded: number;
  43804. /** defines the data length to load */
  43805. readonly total: number;
  43806. /**
  43807. * Create a new progress event
  43808. * @param lengthComputable defines if data length to load can be evaluated
  43809. * @param loaded defines the loaded data length
  43810. * @param total defines the data length to load
  43811. */
  43812. constructor(
  43813. /** defines if data length to load can be evaluated */
  43814. lengthComputable: boolean,
  43815. /** defines the loaded data length */
  43816. loaded: number,
  43817. /** defines the data length to load */
  43818. total: number);
  43819. /**
  43820. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43821. * @param event defines the source event
  43822. * @returns a new SceneLoaderProgressEvent
  43823. */
  43824. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43825. }
  43826. /**
  43827. * Interface used by SceneLoader plugins to define supported file extensions
  43828. */
  43829. export interface ISceneLoaderPluginExtensions {
  43830. /**
  43831. * Defines the list of supported extensions
  43832. */
  43833. [extension: string]: {
  43834. isBinary: boolean;
  43835. };
  43836. }
  43837. /**
  43838. * Interface used by SceneLoader plugin factory
  43839. */
  43840. export interface ISceneLoaderPluginFactory {
  43841. /**
  43842. * Defines the name of the factory
  43843. */
  43844. name: string;
  43845. /**
  43846. * Function called to create a new plugin
  43847. * @return the new plugin
  43848. */
  43849. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43850. /**
  43851. * The callback that returns true if the data can be directly loaded.
  43852. * @param data string containing the file data
  43853. * @returns if the data can be loaded directly
  43854. */
  43855. canDirectLoad?(data: string): boolean;
  43856. }
  43857. /**
  43858. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43859. */
  43860. export interface ISceneLoaderPluginBase {
  43861. /**
  43862. * The friendly name of this plugin.
  43863. */
  43864. name: string;
  43865. /**
  43866. * The file extensions supported by this plugin.
  43867. */
  43868. extensions: string | ISceneLoaderPluginExtensions;
  43869. /**
  43870. * The callback called when loading from a url.
  43871. * @param scene scene loading this url
  43872. * @param url url to load
  43873. * @param onSuccess callback called when the file successfully loads
  43874. * @param onProgress callback called while file is loading (if the server supports this mode)
  43875. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43876. * @param onError callback called when the file fails to load
  43877. * @returns a file request object
  43878. */
  43879. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43880. /**
  43881. * The callback called when loading from a file object.
  43882. * @param scene scene loading this file
  43883. * @param file defines the file to load
  43884. * @param onSuccess defines the callback to call when data is loaded
  43885. * @param onProgress defines the callback to call during loading process
  43886. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43887. * @param onError defines the callback to call when an error occurs
  43888. * @returns a file request object
  43889. */
  43890. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43891. /**
  43892. * The callback that returns true if the data can be directly loaded.
  43893. * @param data string containing the file data
  43894. * @returns if the data can be loaded directly
  43895. */
  43896. canDirectLoad?(data: string): boolean;
  43897. /**
  43898. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43899. * @param scene scene loading this data
  43900. * @param data string containing the data
  43901. * @returns data to pass to the plugin
  43902. */
  43903. directLoad?(scene: Scene, data: string): any;
  43904. /**
  43905. * The callback that allows custom handling of the root url based on the response url.
  43906. * @param rootUrl the original root url
  43907. * @param responseURL the response url if available
  43908. * @returns the new root url
  43909. */
  43910. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43911. }
  43912. /**
  43913. * Interface used to define a SceneLoader plugin
  43914. */
  43915. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43916. /**
  43917. * Import meshes into a scene.
  43918. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43919. * @param scene The scene to import into
  43920. * @param data The data to import
  43921. * @param rootUrl The root url for scene and resources
  43922. * @param meshes The meshes array to import into
  43923. * @param particleSystems The particle systems array to import into
  43924. * @param skeletons The skeletons array to import into
  43925. * @param onError The callback when import fails
  43926. * @returns True if successful or false otherwise
  43927. */
  43928. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43929. /**
  43930. * Load into a scene.
  43931. * @param scene The scene to load into
  43932. * @param data The data to import
  43933. * @param rootUrl The root url for scene and resources
  43934. * @param onError The callback when import fails
  43935. * @returns True if successful or false otherwise
  43936. */
  43937. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43938. /**
  43939. * Load into an asset container.
  43940. * @param scene The scene to load into
  43941. * @param data The data to import
  43942. * @param rootUrl The root url for scene and resources
  43943. * @param onError The callback when import fails
  43944. * @returns The loaded asset container
  43945. */
  43946. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43947. }
  43948. /**
  43949. * Interface used to define an async SceneLoader plugin
  43950. */
  43951. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43952. /**
  43953. * Import meshes into a scene.
  43954. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43955. * @param scene The scene to import into
  43956. * @param data The data to import
  43957. * @param rootUrl The root url for scene and resources
  43958. * @param onProgress The callback when the load progresses
  43959. * @param fileName Defines the name of the file to load
  43960. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43961. */
  43962. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43963. meshes: AbstractMesh[];
  43964. particleSystems: IParticleSystem[];
  43965. skeletons: Skeleton[];
  43966. animationGroups: AnimationGroup[];
  43967. }>;
  43968. /**
  43969. * Load into a scene.
  43970. * @param scene The scene to load into
  43971. * @param data The data to import
  43972. * @param rootUrl The root url for scene and resources
  43973. * @param onProgress The callback when the load progresses
  43974. * @param fileName Defines the name of the file to load
  43975. * @returns Nothing
  43976. */
  43977. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43978. /**
  43979. * Load into an asset container.
  43980. * @param scene The scene to load into
  43981. * @param data The data to import
  43982. * @param rootUrl The root url for scene and resources
  43983. * @param onProgress The callback when the load progresses
  43984. * @param fileName Defines the name of the file to load
  43985. * @returns The loaded asset container
  43986. */
  43987. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43988. }
  43989. /**
  43990. * Mode that determines how to handle old animation groups before loading new ones.
  43991. */
  43992. export enum SceneLoaderAnimationGroupLoadingMode {
  43993. /**
  43994. * Reset all old animations to initial state then dispose them.
  43995. */
  43996. Clean = 0,
  43997. /**
  43998. * Stop all old animations.
  43999. */
  44000. Stop = 1,
  44001. /**
  44002. * Restart old animations from first frame.
  44003. */
  44004. Sync = 2,
  44005. /**
  44006. * Old animations remains untouched.
  44007. */
  44008. NoSync = 3
  44009. }
  44010. /**
  44011. * Class used to load scene from various file formats using registered plugins
  44012. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44013. */
  44014. export class SceneLoader {
  44015. /**
  44016. * No logging while loading
  44017. */
  44018. static readonly NO_LOGGING: number;
  44019. /**
  44020. * Minimal logging while loading
  44021. */
  44022. static readonly MINIMAL_LOGGING: number;
  44023. /**
  44024. * Summary logging while loading
  44025. */
  44026. static readonly SUMMARY_LOGGING: number;
  44027. /**
  44028. * Detailled logging while loading
  44029. */
  44030. static readonly DETAILED_LOGGING: number;
  44031. /**
  44032. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44033. */
  44034. static get ForceFullSceneLoadingForIncremental(): boolean;
  44035. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44036. /**
  44037. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44038. */
  44039. static get ShowLoadingScreen(): boolean;
  44040. static set ShowLoadingScreen(value: boolean);
  44041. /**
  44042. * Defines the current logging level (while loading the scene)
  44043. * @ignorenaming
  44044. */
  44045. static get loggingLevel(): number;
  44046. static set loggingLevel(value: number);
  44047. /**
  44048. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44049. */
  44050. static get CleanBoneMatrixWeights(): boolean;
  44051. static set CleanBoneMatrixWeights(value: boolean);
  44052. /**
  44053. * Event raised when a plugin is used to load a scene
  44054. */
  44055. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44056. private static _registeredPlugins;
  44057. private static _getDefaultPlugin;
  44058. private static _getPluginForExtension;
  44059. private static _getPluginForDirectLoad;
  44060. private static _getPluginForFilename;
  44061. private static _getDirectLoad;
  44062. private static _loadData;
  44063. private static _getFileInfo;
  44064. /**
  44065. * Gets a plugin that can load the given extension
  44066. * @param extension defines the extension to load
  44067. * @returns a plugin or null if none works
  44068. */
  44069. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44070. /**
  44071. * Gets a boolean indicating that the given extension can be loaded
  44072. * @param extension defines the extension to load
  44073. * @returns true if the extension is supported
  44074. */
  44075. static IsPluginForExtensionAvailable(extension: string): boolean;
  44076. /**
  44077. * Adds a new plugin to the list of registered plugins
  44078. * @param plugin defines the plugin to add
  44079. */
  44080. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44081. /**
  44082. * Import meshes into a scene
  44083. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44084. * @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)
  44085. * @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)
  44086. * @param scene the instance of BABYLON.Scene to append to
  44087. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44088. * @param onProgress a callback with a progress event for each file being loaded
  44089. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44090. * @param pluginExtension the extension used to determine the plugin
  44091. * @returns The loaded plugin
  44092. */
  44093. 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>;
  44094. /**
  44095. * Import meshes into a scene
  44096. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44097. * @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)
  44098. * @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)
  44099. * @param scene the instance of BABYLON.Scene to append to
  44100. * @param onProgress a callback with a progress event for each file being loaded
  44101. * @param pluginExtension the extension used to determine the plugin
  44102. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44103. */
  44104. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44105. meshes: AbstractMesh[];
  44106. particleSystems: IParticleSystem[];
  44107. skeletons: Skeleton[];
  44108. animationGroups: AnimationGroup[];
  44109. }>;
  44110. /**
  44111. * Load a scene
  44112. * @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)
  44113. * @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)
  44114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44115. * @param onSuccess a callback with the scene when import succeeds
  44116. * @param onProgress a callback with a progress event for each file being loaded
  44117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44118. * @param pluginExtension the extension used to determine the plugin
  44119. * @returns The loaded plugin
  44120. */
  44121. 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>;
  44122. /**
  44123. * Load a scene
  44124. * @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)
  44125. * @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)
  44126. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44127. * @param onProgress a callback with a progress event for each file being loaded
  44128. * @param pluginExtension the extension used to determine the plugin
  44129. * @returns The loaded scene
  44130. */
  44131. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44132. /**
  44133. * Append a scene
  44134. * @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)
  44135. * @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)
  44136. * @param scene is the instance of BABYLON.Scene to append to
  44137. * @param onSuccess a callback with the scene when import succeeds
  44138. * @param onProgress a callback with a progress event for each file being loaded
  44139. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44140. * @param pluginExtension the extension used to determine the plugin
  44141. * @returns The loaded plugin
  44142. */
  44143. 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>;
  44144. /**
  44145. * Append a scene
  44146. * @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)
  44147. * @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)
  44148. * @param scene is the instance of BABYLON.Scene to append to
  44149. * @param onProgress a callback with a progress event for each file being loaded
  44150. * @param pluginExtension the extension used to determine the plugin
  44151. * @returns The given scene
  44152. */
  44153. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44154. /**
  44155. * Load a scene into an asset container
  44156. * @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)
  44157. * @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)
  44158. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44159. * @param onSuccess a callback with the scene when import succeeds
  44160. * @param onProgress a callback with a progress event for each file being loaded
  44161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44162. * @param pluginExtension the extension used to determine the plugin
  44163. * @returns The loaded plugin
  44164. */
  44165. 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>;
  44166. /**
  44167. * Load a scene into an asset container
  44168. * @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)
  44169. * @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)
  44170. * @param scene is the instance of Scene to append to
  44171. * @param onProgress a callback with a progress event for each file being loaded
  44172. * @param pluginExtension the extension used to determine the plugin
  44173. * @returns The loaded asset container
  44174. */
  44175. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44176. /**
  44177. * Import animations from a file into a scene
  44178. * @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)
  44179. * @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)
  44180. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44181. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44182. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44183. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44184. * @param onSuccess a callback with the scene when import succeeds
  44185. * @param onProgress a callback with a progress event for each file being loaded
  44186. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44187. */
  44188. 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;
  44189. /**
  44190. * Import animations from a file into a scene
  44191. * @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)
  44192. * @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)
  44193. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44194. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44195. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44196. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44197. * @param onSuccess a callback with the scene when import succeeds
  44198. * @param onProgress a callback with a progress event for each file being loaded
  44199. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44200. * @returns the updated scene with imported animations
  44201. */
  44202. 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>;
  44203. }
  44204. }
  44205. declare module BABYLON {
  44206. /**
  44207. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44208. */
  44209. export type MotionControllerHandedness = "none" | "left" | "right";
  44210. /**
  44211. * The type of components available in motion controllers.
  44212. * This is not the name of the component.
  44213. */
  44214. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44215. /**
  44216. * The state of a controller component
  44217. */
  44218. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44219. /**
  44220. * The schema of motion controller layout.
  44221. * No object will be initialized using this interface
  44222. * This is used just to define the profile.
  44223. */
  44224. export interface IMotionControllerLayout {
  44225. /**
  44226. * Path to load the assets. Usually relative to the base path
  44227. */
  44228. assetPath: string;
  44229. /**
  44230. * Available components (unsorted)
  44231. */
  44232. components: {
  44233. /**
  44234. * A map of component Ids
  44235. */
  44236. [componentId: string]: {
  44237. /**
  44238. * The type of input the component outputs
  44239. */
  44240. type: MotionControllerComponentType;
  44241. /**
  44242. * The indices of this component in the gamepad object
  44243. */
  44244. gamepadIndices: {
  44245. /**
  44246. * Index of button
  44247. */
  44248. button?: number;
  44249. /**
  44250. * If available, index of x-axis
  44251. */
  44252. xAxis?: number;
  44253. /**
  44254. * If available, index of y-axis
  44255. */
  44256. yAxis?: number;
  44257. };
  44258. /**
  44259. * The mesh's root node name
  44260. */
  44261. rootNodeName: string;
  44262. /**
  44263. * Animation definitions for this model
  44264. */
  44265. visualResponses: {
  44266. [stateKey: string]: {
  44267. /**
  44268. * What property will be animated
  44269. */
  44270. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44271. /**
  44272. * What states influence this visual response
  44273. */
  44274. states: MotionControllerComponentStateType[];
  44275. /**
  44276. * Type of animation - movement or visibility
  44277. */
  44278. valueNodeProperty: "transform" | "visibility";
  44279. /**
  44280. * Base node name to move. Its position will be calculated according to the min and max nodes
  44281. */
  44282. valueNodeName?: string;
  44283. /**
  44284. * Minimum movement node
  44285. */
  44286. minNodeName?: string;
  44287. /**
  44288. * Max movement node
  44289. */
  44290. maxNodeName?: string;
  44291. };
  44292. };
  44293. /**
  44294. * If touch enabled, what is the name of node to display user feedback
  44295. */
  44296. touchPointNodeName?: string;
  44297. };
  44298. };
  44299. /**
  44300. * Is it xr standard mapping or not
  44301. */
  44302. gamepadMapping: "" | "xr-standard";
  44303. /**
  44304. * Base root node of this entire model
  44305. */
  44306. rootNodeName: string;
  44307. /**
  44308. * Defines the main button component id
  44309. */
  44310. selectComponentId: string;
  44311. }
  44312. /**
  44313. * A definition for the layout map in the input profile
  44314. */
  44315. export interface IMotionControllerLayoutMap {
  44316. /**
  44317. * Layouts with handedness type as a key
  44318. */
  44319. [handedness: string]: IMotionControllerLayout;
  44320. }
  44321. /**
  44322. * The XR Input profile schema
  44323. * Profiles can be found here:
  44324. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44325. */
  44326. export interface IMotionControllerProfile {
  44327. /**
  44328. * fallback profiles for this profileId
  44329. */
  44330. fallbackProfileIds: string[];
  44331. /**
  44332. * The layout map, with handedness as key
  44333. */
  44334. layouts: IMotionControllerLayoutMap;
  44335. /**
  44336. * The id of this profile
  44337. * correlates to the profile(s) in the xrInput.profiles array
  44338. */
  44339. profileId: string;
  44340. }
  44341. /**
  44342. * A helper-interface for the 3 meshes needed for controller button animation
  44343. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44344. */
  44345. export interface IMotionControllerButtonMeshMap {
  44346. /**
  44347. * the mesh that defines the pressed value mesh position.
  44348. * This is used to find the max-position of this button
  44349. */
  44350. pressedMesh: AbstractMesh;
  44351. /**
  44352. * the mesh that defines the unpressed value mesh position.
  44353. * This is used to find the min (or initial) position of this button
  44354. */
  44355. unpressedMesh: AbstractMesh;
  44356. /**
  44357. * The mesh that will be changed when value changes
  44358. */
  44359. valueMesh: AbstractMesh;
  44360. }
  44361. /**
  44362. * A helper-interface for the 3 meshes needed for controller axis animation.
  44363. * This will be expanded when touchpad animations are fully supported
  44364. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44365. */
  44366. export interface IMotionControllerMeshMap {
  44367. /**
  44368. * the mesh that defines the maximum value mesh position.
  44369. */
  44370. maxMesh?: AbstractMesh;
  44371. /**
  44372. * the mesh that defines the minimum value mesh position.
  44373. */
  44374. minMesh?: AbstractMesh;
  44375. /**
  44376. * The mesh that will be changed when axis value changes
  44377. */
  44378. valueMesh: AbstractMesh;
  44379. }
  44380. /**
  44381. * The elements needed for change-detection of the gamepad objects in motion controllers
  44382. */
  44383. export interface IMinimalMotionControllerObject {
  44384. /**
  44385. * Available axes of this controller
  44386. */
  44387. axes: number[];
  44388. /**
  44389. * An array of available buttons
  44390. */
  44391. buttons: Array<{
  44392. /**
  44393. * Value of the button/trigger
  44394. */
  44395. value: number;
  44396. /**
  44397. * If the button/trigger is currently touched
  44398. */
  44399. touched: boolean;
  44400. /**
  44401. * If the button/trigger is currently pressed
  44402. */
  44403. pressed: boolean;
  44404. }>;
  44405. /**
  44406. * EXPERIMENTAL haptic support.
  44407. */
  44408. hapticActuators?: Array<{
  44409. pulse: (value: number, duration: number) => Promise<boolean>;
  44410. }>;
  44411. }
  44412. /**
  44413. * An Abstract Motion controller
  44414. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44415. * Each component has an observable to check for changes in value and state
  44416. */
  44417. export abstract class WebXRAbstractMotionController implements IDisposable {
  44418. protected scene: Scene;
  44419. protected layout: IMotionControllerLayout;
  44420. /**
  44421. * The gamepad object correlating to this controller
  44422. */
  44423. gamepadObject: IMinimalMotionControllerObject;
  44424. /**
  44425. * handedness (left/right/none) of this controller
  44426. */
  44427. handedness: MotionControllerHandedness;
  44428. private _initComponent;
  44429. private _modelReady;
  44430. /**
  44431. * A map of components (WebXRControllerComponent) in this motion controller
  44432. * Components have a ComponentType and can also have both button and axis definitions
  44433. */
  44434. readonly components: {
  44435. [id: string]: WebXRControllerComponent;
  44436. };
  44437. /**
  44438. * Disable the model's animation. Can be set at any time.
  44439. */
  44440. disableAnimation: boolean;
  44441. /**
  44442. * Observers registered here will be triggered when the model of this controller is done loading
  44443. */
  44444. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44445. /**
  44446. * The profile id of this motion controller
  44447. */
  44448. abstract profileId: string;
  44449. /**
  44450. * The root mesh of the model. It is null if the model was not yet initialized
  44451. */
  44452. rootMesh: Nullable<AbstractMesh>;
  44453. /**
  44454. * constructs a new abstract motion controller
  44455. * @param scene the scene to which the model of the controller will be added
  44456. * @param layout The profile layout to load
  44457. * @param gamepadObject The gamepad object correlating to this controller
  44458. * @param handedness handedness (left/right/none) of this controller
  44459. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44460. */
  44461. constructor(scene: Scene, layout: IMotionControllerLayout,
  44462. /**
  44463. * The gamepad object correlating to this controller
  44464. */
  44465. gamepadObject: IMinimalMotionControllerObject,
  44466. /**
  44467. * handedness (left/right/none) of this controller
  44468. */
  44469. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44470. /**
  44471. * Dispose this controller, the model mesh and all its components
  44472. */
  44473. dispose(): void;
  44474. /**
  44475. * Returns all components of specific type
  44476. * @param type the type to search for
  44477. * @return an array of components with this type
  44478. */
  44479. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44480. /**
  44481. * get a component based an its component id as defined in layout.components
  44482. * @param id the id of the component
  44483. * @returns the component correlates to the id or undefined if not found
  44484. */
  44485. getComponent(id: string): WebXRControllerComponent;
  44486. /**
  44487. * Get the list of components available in this motion controller
  44488. * @returns an array of strings correlating to available components
  44489. */
  44490. getComponentIds(): string[];
  44491. /**
  44492. * Get the first component of specific type
  44493. * @param type type of component to find
  44494. * @return a controller component or null if not found
  44495. */
  44496. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44497. /**
  44498. * Get the main (Select) component of this controller as defined in the layout
  44499. * @returns the main component of this controller
  44500. */
  44501. getMainComponent(): WebXRControllerComponent;
  44502. /**
  44503. * Loads the model correlating to this controller
  44504. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44505. * @returns A promise fulfilled with the result of the model loading
  44506. */
  44507. loadModel(): Promise<boolean>;
  44508. /**
  44509. * Update this model using the current XRFrame
  44510. * @param xrFrame the current xr frame to use and update the model
  44511. */
  44512. updateFromXRFrame(xrFrame: XRFrame): void;
  44513. /**
  44514. * Backwards compatibility due to a deeply-integrated typo
  44515. */
  44516. get handness(): XREye;
  44517. /**
  44518. * Pulse (vibrate) this controller
  44519. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  44520. * Consecutive calls to this function will cancel the last pulse call
  44521. *
  44522. * @param value the strength of the pulse in 0.0...1.0 range
  44523. * @param duration Duration of the pulse in milliseconds
  44524. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  44525. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  44526. */
  44527. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  44528. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44529. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44530. /**
  44531. * Moves the axis on the controller mesh based on its current state
  44532. * @param axis the index of the axis
  44533. * @param axisValue the value of the axis which determines the meshes new position
  44534. * @hidden
  44535. */
  44536. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44537. /**
  44538. * Update the model itself with the current frame data
  44539. * @param xrFrame the frame to use for updating the model mesh
  44540. */
  44541. protected updateModel(xrFrame: XRFrame): void;
  44542. /**
  44543. * Get the filename and path for this controller's model
  44544. * @returns a map of filename and path
  44545. */
  44546. protected abstract _getFilenameAndPath(): {
  44547. filename: string;
  44548. path: string;
  44549. };
  44550. /**
  44551. * This function is called before the mesh is loaded. It checks for loading constraints.
  44552. * For example, this function can check if the GLB loader is available
  44553. * If this function returns false, the generic controller will be loaded instead
  44554. * @returns Is the client ready to load the mesh
  44555. */
  44556. protected abstract _getModelLoadingConstraints(): boolean;
  44557. /**
  44558. * This function will be called after the model was successfully loaded and can be used
  44559. * for mesh transformations before it is available for the user
  44560. * @param meshes the loaded meshes
  44561. */
  44562. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44563. /**
  44564. * Set the root mesh for this controller. Important for the WebXR controller class
  44565. * @param meshes the loaded meshes
  44566. */
  44567. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44568. /**
  44569. * A function executed each frame that updates the mesh (if needed)
  44570. * @param xrFrame the current xrFrame
  44571. */
  44572. protected abstract _updateModel(xrFrame: XRFrame): void;
  44573. private _getGenericFilenameAndPath;
  44574. private _getGenericParentMesh;
  44575. }
  44576. }
  44577. declare module BABYLON {
  44578. /**
  44579. * A generic trigger-only motion controller for WebXR
  44580. */
  44581. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44582. /**
  44583. * Static version of the profile id of this controller
  44584. */
  44585. static ProfileId: string;
  44586. profileId: string;
  44587. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44588. protected _getFilenameAndPath(): {
  44589. filename: string;
  44590. path: string;
  44591. };
  44592. protected _getModelLoadingConstraints(): boolean;
  44593. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44594. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44595. protected _updateModel(): void;
  44596. }
  44597. }
  44598. declare module BABYLON {
  44599. /**
  44600. * Class containing static functions to help procedurally build meshes
  44601. */
  44602. export class SphereBuilder {
  44603. /**
  44604. * Creates a sphere mesh
  44605. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44606. * * 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`)
  44607. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44608. * * 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
  44609. * * 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)
  44610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44611. * * 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
  44612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44613. * @param name defines the name of the mesh
  44614. * @param options defines the options used to create the mesh
  44615. * @param scene defines the hosting scene
  44616. * @returns the sphere mesh
  44617. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44618. */
  44619. static CreateSphere(name: string, options: {
  44620. segments?: number;
  44621. diameter?: number;
  44622. diameterX?: number;
  44623. diameterY?: number;
  44624. diameterZ?: number;
  44625. arc?: number;
  44626. slice?: number;
  44627. sideOrientation?: number;
  44628. frontUVs?: Vector4;
  44629. backUVs?: Vector4;
  44630. updatable?: boolean;
  44631. }, scene?: Nullable<Scene>): Mesh;
  44632. }
  44633. }
  44634. declare module BABYLON {
  44635. /**
  44636. * A profiled motion controller has its profile loaded from an online repository.
  44637. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44638. */
  44639. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44640. private _repositoryUrl;
  44641. private _buttonMeshMapping;
  44642. private _touchDots;
  44643. /**
  44644. * The profile ID of this controller. Will be populated when the controller initializes.
  44645. */
  44646. profileId: string;
  44647. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44648. dispose(): void;
  44649. protected _getFilenameAndPath(): {
  44650. filename: string;
  44651. path: string;
  44652. };
  44653. protected _getModelLoadingConstraints(): boolean;
  44654. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44655. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44656. protected _updateModel(_xrFrame: XRFrame): void;
  44657. }
  44658. }
  44659. declare module BABYLON {
  44660. /**
  44661. * A construction function type to create a new controller based on an xrInput object
  44662. */
  44663. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44664. /**
  44665. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44666. *
  44667. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44668. * it should be replaced with auto-loaded controllers.
  44669. *
  44670. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44671. */
  44672. export class WebXRMotionControllerManager {
  44673. private static _AvailableControllers;
  44674. private static _Fallbacks;
  44675. private static _ProfileLoadingPromises;
  44676. private static _ProfilesList;
  44677. /**
  44678. * The base URL of the online controller repository. Can be changed at any time.
  44679. */
  44680. static BaseRepositoryUrl: string;
  44681. /**
  44682. * Which repository gets priority - local or online
  44683. */
  44684. static PrioritizeOnlineRepository: boolean;
  44685. /**
  44686. * Use the online repository, or use only locally-defined controllers
  44687. */
  44688. static UseOnlineRepository: boolean;
  44689. /**
  44690. * Clear the cache used for profile loading and reload when requested again
  44691. */
  44692. static ClearProfilesCache(): void;
  44693. /**
  44694. * Register the default fallbacks.
  44695. * This function is called automatically when this file is imported.
  44696. */
  44697. static DefaultFallbacks(): void;
  44698. /**
  44699. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44700. * @param profileId the profile to which a fallback needs to be found
  44701. * @return an array with corresponding fallback profiles
  44702. */
  44703. static FindFallbackWithProfileId(profileId: string): string[];
  44704. /**
  44705. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44706. * The order of search:
  44707. *
  44708. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44709. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44710. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44711. * 4) return the generic trigger controller if none were found
  44712. *
  44713. * @param xrInput the xrInput to which a new controller is initialized
  44714. * @param scene the scene to which the model will be added
  44715. * @param forceProfile force a certain profile for this controller
  44716. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44717. */
  44718. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44719. /**
  44720. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44721. *
  44722. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44723. *
  44724. * @param type the profile type to register
  44725. * @param constructFunction the function to be called when loading this profile
  44726. */
  44727. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44728. /**
  44729. * Register a fallback to a specific profile.
  44730. * @param profileId the profileId that will receive the fallbacks
  44731. * @param fallbacks A list of fallback profiles
  44732. */
  44733. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44734. /**
  44735. * Will update the list of profiles available in the repository
  44736. * @return a promise that resolves to a map of profiles available online
  44737. */
  44738. static UpdateProfilesList(): Promise<{
  44739. [profile: string]: string;
  44740. }>;
  44741. private static _LoadProfileFromRepository;
  44742. private static _LoadProfilesFromAvailableControllers;
  44743. }
  44744. }
  44745. declare module BABYLON {
  44746. /**
  44747. * Configuration options for the WebXR controller creation
  44748. */
  44749. export interface IWebXRControllerOptions {
  44750. /**
  44751. * Should the controller mesh be animated when a user interacts with it
  44752. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44753. */
  44754. disableMotionControllerAnimation?: boolean;
  44755. /**
  44756. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44757. */
  44758. doNotLoadControllerMesh?: boolean;
  44759. /**
  44760. * Force a specific controller type for this controller.
  44761. * This can be used when creating your own profile or when testing different controllers
  44762. */
  44763. forceControllerProfile?: string;
  44764. /**
  44765. * Defines a rendering group ID for meshes that will be loaded.
  44766. * This is for the default controllers only.
  44767. */
  44768. renderingGroupId?: number;
  44769. }
  44770. /**
  44771. * Represents an XR controller
  44772. */
  44773. export class WebXRInputSource {
  44774. private _scene;
  44775. /** The underlying input source for the controller */
  44776. inputSource: XRInputSource;
  44777. private _options;
  44778. private _tmpQuaternion;
  44779. private _tmpVector;
  44780. private _uniqueId;
  44781. /**
  44782. * 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
  44783. */
  44784. grip?: AbstractMesh;
  44785. /**
  44786. * If available, this is the gamepad object related to this controller.
  44787. * Using this object it is possible to get click events and trackpad changes of the
  44788. * webxr controller that is currently being used.
  44789. */
  44790. motionController?: WebXRAbstractMotionController;
  44791. /**
  44792. * Event that fires when the controller is removed/disposed.
  44793. * The object provided as event data is this controller, after associated assets were disposed.
  44794. * uniqueId is still available.
  44795. */
  44796. onDisposeObservable: Observable<WebXRInputSource>;
  44797. /**
  44798. * Will be triggered when the mesh associated with the motion controller is done loading.
  44799. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44800. * A shortened version of controller -> motion controller -> on mesh loaded.
  44801. */
  44802. onMeshLoadedObservable: Observable<AbstractMesh>;
  44803. /**
  44804. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44805. */
  44806. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44807. /**
  44808. * Pointer which can be used to select objects or attach a visible laser to
  44809. */
  44810. pointer: AbstractMesh;
  44811. /**
  44812. * Creates the controller
  44813. * @see https://doc.babylonjs.com/how_to/webxr
  44814. * @param _scene the scene which the controller should be associated to
  44815. * @param inputSource the underlying input source for the controller
  44816. * @param _options options for this controller creation
  44817. */
  44818. constructor(_scene: Scene,
  44819. /** The underlying input source for the controller */
  44820. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44821. /**
  44822. * Get this controllers unique id
  44823. */
  44824. get uniqueId(): string;
  44825. /**
  44826. * Disposes of the object
  44827. */
  44828. dispose(): void;
  44829. /**
  44830. * Gets a world space ray coming from the pointer or grip
  44831. * @param result the resulting ray
  44832. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44833. */
  44834. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44835. /**
  44836. * Updates the controller pose based on the given XRFrame
  44837. * @param xrFrame xr frame to update the pose with
  44838. * @param referenceSpace reference space to use
  44839. */
  44840. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44841. }
  44842. }
  44843. declare module BABYLON {
  44844. /**
  44845. * The schema for initialization options of the XR Input class
  44846. */
  44847. export interface IWebXRInputOptions {
  44848. /**
  44849. * If set to true no model will be automatically loaded
  44850. */
  44851. doNotLoadControllerMeshes?: boolean;
  44852. /**
  44853. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44854. * If not found, the xr input profile data will be used.
  44855. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44856. */
  44857. forceInputProfile?: string;
  44858. /**
  44859. * Do not send a request to the controller repository to load the profile.
  44860. *
  44861. * Instead, use the controllers available in babylon itself.
  44862. */
  44863. disableOnlineControllerRepository?: boolean;
  44864. /**
  44865. * A custom URL for the controllers repository
  44866. */
  44867. customControllersRepositoryURL?: string;
  44868. /**
  44869. * Should the controller model's components not move according to the user input
  44870. */
  44871. disableControllerAnimation?: boolean;
  44872. /**
  44873. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  44874. */
  44875. controllerOptions?: IWebXRControllerOptions;
  44876. }
  44877. /**
  44878. * XR input used to track XR inputs such as controllers/rays
  44879. */
  44880. export class WebXRInput implements IDisposable {
  44881. /**
  44882. * the xr session manager for this session
  44883. */
  44884. xrSessionManager: WebXRSessionManager;
  44885. /**
  44886. * the WebXR camera for this session. Mainly used for teleportation
  44887. */
  44888. xrCamera: WebXRCamera;
  44889. private readonly options;
  44890. /**
  44891. * XR controllers being tracked
  44892. */
  44893. controllers: Array<WebXRInputSource>;
  44894. private _frameObserver;
  44895. private _sessionEndedObserver;
  44896. private _sessionInitObserver;
  44897. /**
  44898. * Event when a controller has been connected/added
  44899. */
  44900. onControllerAddedObservable: Observable<WebXRInputSource>;
  44901. /**
  44902. * Event when a controller has been removed/disconnected
  44903. */
  44904. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44905. /**
  44906. * Initializes the WebXRInput
  44907. * @param xrSessionManager the xr session manager for this session
  44908. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44909. * @param options = initialization options for this xr input
  44910. */
  44911. constructor(
  44912. /**
  44913. * the xr session manager for this session
  44914. */
  44915. xrSessionManager: WebXRSessionManager,
  44916. /**
  44917. * the WebXR camera for this session. Mainly used for teleportation
  44918. */
  44919. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44920. private _onInputSourcesChange;
  44921. private _addAndRemoveControllers;
  44922. /**
  44923. * Disposes of the object
  44924. */
  44925. dispose(): void;
  44926. }
  44927. }
  44928. declare module BABYLON {
  44929. /**
  44930. * This is the base class for all WebXR features.
  44931. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44932. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44933. */
  44934. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44935. protected _xrSessionManager: WebXRSessionManager;
  44936. private _attached;
  44937. private _removeOnDetach;
  44938. /**
  44939. * Should auto-attach be disabled?
  44940. */
  44941. disableAutoAttach: boolean;
  44942. /**
  44943. * Construct a new (abstract) WebXR feature
  44944. * @param _xrSessionManager the xr session manager for this feature
  44945. */
  44946. constructor(_xrSessionManager: WebXRSessionManager);
  44947. /**
  44948. * Is this feature attached
  44949. */
  44950. get attached(): boolean;
  44951. /**
  44952. * attach this feature
  44953. *
  44954. * @param force should attachment be forced (even when already attached)
  44955. * @returns true if successful, false is failed or already attached
  44956. */
  44957. attach(force?: boolean): boolean;
  44958. /**
  44959. * detach this feature.
  44960. *
  44961. * @returns true if successful, false if failed or already detached
  44962. */
  44963. detach(): boolean;
  44964. /**
  44965. * Dispose this feature and all of the resources attached
  44966. */
  44967. dispose(): void;
  44968. /**
  44969. * This is used to register callbacks that will automatically be removed when detach is called.
  44970. * @param observable the observable to which the observer will be attached
  44971. * @param callback the callback to register
  44972. */
  44973. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44974. /**
  44975. * Code in this function will be executed on each xrFrame received from the browser.
  44976. * This function will not execute after the feature is detached.
  44977. * @param _xrFrame the current frame
  44978. */
  44979. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44980. }
  44981. }
  44982. declare module BABYLON {
  44983. /**
  44984. * Renders a layer on top of an existing scene
  44985. */
  44986. export class UtilityLayerRenderer implements IDisposable {
  44987. /** the original scene that will be rendered on top of */
  44988. originalScene: Scene;
  44989. private _pointerCaptures;
  44990. private _lastPointerEvents;
  44991. private static _DefaultUtilityLayer;
  44992. private static _DefaultKeepDepthUtilityLayer;
  44993. private _sharedGizmoLight;
  44994. private _renderCamera;
  44995. /**
  44996. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44997. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44998. * @returns the camera that is used when rendering the utility layer
  44999. */
  45000. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45001. /**
  45002. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45003. * @param cam the camera that should be used when rendering the utility layer
  45004. */
  45005. setRenderCamera(cam: Nullable<Camera>): void;
  45006. /**
  45007. * @hidden
  45008. * Light which used by gizmos to get light shading
  45009. */
  45010. _getSharedGizmoLight(): HemisphericLight;
  45011. /**
  45012. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45013. */
  45014. pickUtilitySceneFirst: boolean;
  45015. /**
  45016. * 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)
  45017. */
  45018. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45019. /**
  45020. * 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)
  45021. */
  45022. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45023. /**
  45024. * The scene that is rendered on top of the original scene
  45025. */
  45026. utilityLayerScene: Scene;
  45027. /**
  45028. * If the utility layer should automatically be rendered on top of existing scene
  45029. */
  45030. shouldRender: boolean;
  45031. /**
  45032. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45033. */
  45034. onlyCheckPointerDownEvents: boolean;
  45035. /**
  45036. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45037. */
  45038. processAllEvents: boolean;
  45039. /**
  45040. * Observable raised when the pointer move from the utility layer scene to the main scene
  45041. */
  45042. onPointerOutObservable: Observable<number>;
  45043. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45044. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45045. private _afterRenderObserver;
  45046. private _sceneDisposeObserver;
  45047. private _originalPointerObserver;
  45048. /**
  45049. * Instantiates a UtilityLayerRenderer
  45050. * @param originalScene the original scene that will be rendered on top of
  45051. * @param handleEvents boolean indicating if the utility layer should handle events
  45052. */
  45053. constructor(
  45054. /** the original scene that will be rendered on top of */
  45055. originalScene: Scene, handleEvents?: boolean);
  45056. private _notifyObservers;
  45057. /**
  45058. * Renders the utility layers scene on top of the original scene
  45059. */
  45060. render(): void;
  45061. /**
  45062. * Disposes of the renderer
  45063. */
  45064. dispose(): void;
  45065. private _updateCamera;
  45066. }
  45067. }
  45068. declare module BABYLON {
  45069. /**
  45070. * Options interface for the pointer selection module
  45071. */
  45072. export interface IWebXRControllerPointerSelectionOptions {
  45073. /**
  45074. * if provided, this scene will be used to render meshes.
  45075. */
  45076. customUtilityLayerScene?: Scene;
  45077. /**
  45078. * 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)
  45079. * If not disabled, the last picked point will be used to execute a pointer up event
  45080. * If disabled, pointer up event will be triggered right after the pointer down event.
  45081. * Used in screen and gaze target ray mode only
  45082. */
  45083. disablePointerUpOnTouchOut: boolean;
  45084. /**
  45085. * For gaze mode (time to select instead of press)
  45086. */
  45087. forceGazeMode: boolean;
  45088. /**
  45089. * 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
  45090. * to start a new countdown to the pointer down event.
  45091. * Defaults to 1.
  45092. */
  45093. gazeModePointerMovedFactor?: number;
  45094. /**
  45095. * Different button type to use instead of the main component
  45096. */
  45097. overrideButtonId?: string;
  45098. /**
  45099. * use this rendering group id for the meshes (optional)
  45100. */
  45101. renderingGroupId?: number;
  45102. /**
  45103. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45104. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45105. * 3000 means 3 seconds between pointing at something and selecting it
  45106. */
  45107. timeToSelect?: number;
  45108. /**
  45109. * Should meshes created here be added to a utility layer or the main scene
  45110. */
  45111. useUtilityLayer?: boolean;
  45112. /**
  45113. * the xr input to use with this pointer selection
  45114. */
  45115. xrInput: WebXRInput;
  45116. }
  45117. /**
  45118. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45119. */
  45120. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45121. private readonly _options;
  45122. private static _idCounter;
  45123. private _attachController;
  45124. private _controllers;
  45125. private _scene;
  45126. private _tmpVectorForPickCompare;
  45127. /**
  45128. * The module's name
  45129. */
  45130. static readonly Name: string;
  45131. /**
  45132. * The (Babylon) version of this module.
  45133. * This is an integer representing the implementation version.
  45134. * This number does not correspond to the WebXR specs version
  45135. */
  45136. static readonly Version: number;
  45137. /**
  45138. * Disable lighting on the laser pointer (so it will always be visible)
  45139. */
  45140. disablePointerLighting: boolean;
  45141. /**
  45142. * Disable lighting on the selection mesh (so it will always be visible)
  45143. */
  45144. disableSelectionMeshLighting: boolean;
  45145. /**
  45146. * Should the laser pointer be displayed
  45147. */
  45148. displayLaserPointer: boolean;
  45149. /**
  45150. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45151. */
  45152. displaySelectionMesh: boolean;
  45153. /**
  45154. * This color will be set to the laser pointer when selection is triggered
  45155. */
  45156. laserPointerPickedColor: Color3;
  45157. /**
  45158. * Default color of the laser pointer
  45159. */
  45160. lasterPointerDefaultColor: Color3;
  45161. /**
  45162. * default color of the selection ring
  45163. */
  45164. selectionMeshDefaultColor: Color3;
  45165. /**
  45166. * This color will be applied to the selection ring when selection is triggered
  45167. */
  45168. selectionMeshPickedColor: Color3;
  45169. /**
  45170. * Optional filter to be used for ray selection. This predicate shares behavior with
  45171. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45172. */
  45173. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45174. /**
  45175. * constructs a new background remover module
  45176. * @param _xrSessionManager the session manager for this module
  45177. * @param _options read-only options to be used in this module
  45178. */
  45179. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45180. /**
  45181. * attach this feature
  45182. * Will usually be called by the features manager
  45183. *
  45184. * @returns true if successful.
  45185. */
  45186. attach(): boolean;
  45187. /**
  45188. * detach this feature.
  45189. * Will usually be called by the features manager
  45190. *
  45191. * @returns true if successful.
  45192. */
  45193. detach(): boolean;
  45194. /**
  45195. * Will get the mesh under a specific pointer.
  45196. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45197. * @param controllerId the controllerId to check
  45198. * @returns The mesh under pointer or null if no mesh is under the pointer
  45199. */
  45200. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45201. /**
  45202. * Get the xr controller that correlates to the pointer id in the pointer event
  45203. *
  45204. * @param id the pointer id to search for
  45205. * @returns the controller that correlates to this id or null if not found
  45206. */
  45207. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45208. protected _onXRFrame(_xrFrame: XRFrame): void;
  45209. private _attachGazeMode;
  45210. private _attachScreenRayMode;
  45211. private _attachTrackedPointerRayMode;
  45212. private _convertNormalToDirectionOfRay;
  45213. private _detachController;
  45214. private _generateNewMeshPair;
  45215. private _pickingMoved;
  45216. private _updatePointerDistance;
  45217. }
  45218. }
  45219. declare module BABYLON {
  45220. /**
  45221. * Button which can be used to enter a different mode of XR
  45222. */
  45223. export class WebXREnterExitUIButton {
  45224. /** button element */
  45225. element: HTMLElement;
  45226. /** XR initialization options for the button */
  45227. sessionMode: XRSessionMode;
  45228. /** Reference space type */
  45229. referenceSpaceType: XRReferenceSpaceType;
  45230. /**
  45231. * Creates a WebXREnterExitUIButton
  45232. * @param element button element
  45233. * @param sessionMode XR initialization session mode
  45234. * @param referenceSpaceType the type of reference space to be used
  45235. */
  45236. constructor(
  45237. /** button element */
  45238. element: HTMLElement,
  45239. /** XR initialization options for the button */
  45240. sessionMode: XRSessionMode,
  45241. /** Reference space type */
  45242. referenceSpaceType: XRReferenceSpaceType);
  45243. /**
  45244. * Extendable function which can be used to update the button's visuals when the state changes
  45245. * @param activeButton the current active button in the UI
  45246. */
  45247. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45248. }
  45249. /**
  45250. * Options to create the webXR UI
  45251. */
  45252. export class WebXREnterExitUIOptions {
  45253. /**
  45254. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45255. */
  45256. customButtons?: Array<WebXREnterExitUIButton>;
  45257. /**
  45258. * A reference space type to use when creating the default button.
  45259. * Default is local-floor
  45260. */
  45261. referenceSpaceType?: XRReferenceSpaceType;
  45262. /**
  45263. * Context to enter xr with
  45264. */
  45265. renderTarget?: Nullable<WebXRRenderTarget>;
  45266. /**
  45267. * A session mode to use when creating the default button.
  45268. * Default is immersive-vr
  45269. */
  45270. sessionMode?: XRSessionMode;
  45271. /**
  45272. * A list of optional features to init the session with
  45273. */
  45274. optionalFeatures?: string[];
  45275. }
  45276. /**
  45277. * UI to allow the user to enter/exit XR mode
  45278. */
  45279. export class WebXREnterExitUI implements IDisposable {
  45280. private scene;
  45281. /** version of the options passed to this UI */
  45282. options: WebXREnterExitUIOptions;
  45283. private _activeButton;
  45284. private _buttons;
  45285. private _overlay;
  45286. /**
  45287. * Fired every time the active button is changed.
  45288. *
  45289. * When xr is entered via a button that launches xr that button will be the callback parameter
  45290. *
  45291. * When exiting xr the callback parameter will be null)
  45292. */
  45293. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45294. /**
  45295. *
  45296. * @param scene babylon scene object to use
  45297. * @param options (read-only) version of the options passed to this UI
  45298. */
  45299. private constructor();
  45300. /**
  45301. * Creates UI to allow the user to enter/exit XR mode
  45302. * @param scene the scene to add the ui to
  45303. * @param helper the xr experience helper to enter/exit xr with
  45304. * @param options options to configure the UI
  45305. * @returns the created ui
  45306. */
  45307. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45308. /**
  45309. * Disposes of the XR UI component
  45310. */
  45311. dispose(): void;
  45312. private _updateButtons;
  45313. }
  45314. }
  45315. declare module BABYLON {
  45316. /**
  45317. * Class containing static functions to help procedurally build meshes
  45318. */
  45319. export class LinesBuilder {
  45320. /**
  45321. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45322. * * 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
  45323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45324. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45325. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45326. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45327. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45328. * * 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
  45329. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45332. * @param name defines the name of the new line system
  45333. * @param options defines the options used to create the line system
  45334. * @param scene defines the hosting scene
  45335. * @returns a new line system mesh
  45336. */
  45337. static CreateLineSystem(name: string, options: {
  45338. lines: Vector3[][];
  45339. updatable?: boolean;
  45340. instance?: Nullable<LinesMesh>;
  45341. colors?: Nullable<Color4[][]>;
  45342. useVertexAlpha?: boolean;
  45343. }, scene: Nullable<Scene>): LinesMesh;
  45344. /**
  45345. * Creates a line mesh
  45346. * 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
  45347. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45348. * * The parameter `points` is an array successive Vector3
  45349. * * 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
  45350. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45352. * * When updating an instance, remember that only point positions can change, not the number of points
  45353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45355. * @param name defines the name of the new line system
  45356. * @param options defines the options used to create the line system
  45357. * @param scene defines the hosting scene
  45358. * @returns a new line mesh
  45359. */
  45360. static CreateLines(name: string, options: {
  45361. points: Vector3[];
  45362. updatable?: boolean;
  45363. instance?: Nullable<LinesMesh>;
  45364. colors?: Color4[];
  45365. useVertexAlpha?: boolean;
  45366. }, scene?: Nullable<Scene>): LinesMesh;
  45367. /**
  45368. * Creates a dashed line mesh
  45369. * * 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
  45370. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45371. * * The parameter `points` is an array successive Vector3
  45372. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45373. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45374. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45375. * * 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
  45376. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45377. * * When updating an instance, remember that only point positions can change, not the number of points
  45378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45379. * @param name defines the name of the mesh
  45380. * @param options defines the options used to create the mesh
  45381. * @param scene defines the hosting scene
  45382. * @returns the dashed line mesh
  45383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45384. */
  45385. static CreateDashedLines(name: string, options: {
  45386. points: Vector3[];
  45387. dashSize?: number;
  45388. gapSize?: number;
  45389. dashNb?: number;
  45390. updatable?: boolean;
  45391. instance?: LinesMesh;
  45392. useVertexAlpha?: boolean;
  45393. }, scene?: Nullable<Scene>): LinesMesh;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * The options container for the teleportation module
  45399. */
  45400. export interface IWebXRTeleportationOptions {
  45401. /**
  45402. * if provided, this scene will be used to render meshes.
  45403. */
  45404. customUtilityLayerScene?: Scene;
  45405. /**
  45406. * Values to configure the default target mesh
  45407. */
  45408. defaultTargetMeshOptions?: {
  45409. /**
  45410. * Fill color of the teleportation area
  45411. */
  45412. teleportationFillColor?: string;
  45413. /**
  45414. * Border color for the teleportation area
  45415. */
  45416. teleportationBorderColor?: string;
  45417. /**
  45418. * Disable the mesh's animation sequence
  45419. */
  45420. disableAnimation?: boolean;
  45421. /**
  45422. * Disable lighting on the material or the ring and arrow
  45423. */
  45424. disableLighting?: boolean;
  45425. /**
  45426. * Override the default material of the torus and arrow
  45427. */
  45428. torusArrowMaterial?: Material;
  45429. };
  45430. /**
  45431. * A list of meshes to use as floor meshes.
  45432. * Meshes can be added and removed after initializing the feature using the
  45433. * addFloorMesh and removeFloorMesh functions
  45434. * If empty, rotation will still work
  45435. */
  45436. floorMeshes?: AbstractMesh[];
  45437. /**
  45438. * use this rendering group id for the meshes (optional)
  45439. */
  45440. renderingGroupId?: number;
  45441. /**
  45442. * Should teleportation move only to snap points
  45443. */
  45444. snapPointsOnly?: boolean;
  45445. /**
  45446. * An array of points to which the teleportation will snap to.
  45447. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45448. */
  45449. snapPositions?: Vector3[];
  45450. /**
  45451. * How close should the teleportation ray be in order to snap to position.
  45452. * Default to 0.8 units (meters)
  45453. */
  45454. snapToPositionRadius?: number;
  45455. /**
  45456. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45457. * If you want to support rotation, make sure your mesh has a direction indicator.
  45458. *
  45459. * When left untouched, the default mesh will be initialized.
  45460. */
  45461. teleportationTargetMesh?: AbstractMesh;
  45462. /**
  45463. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45464. */
  45465. timeToTeleport?: number;
  45466. /**
  45467. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45468. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45469. */
  45470. useMainComponentOnly?: boolean;
  45471. /**
  45472. * Should meshes created here be added to a utility layer or the main scene
  45473. */
  45474. useUtilityLayer?: boolean;
  45475. /**
  45476. * Babylon XR Input class for controller
  45477. */
  45478. xrInput: WebXRInput;
  45479. }
  45480. /**
  45481. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45482. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45483. * the input of the attached controllers.
  45484. */
  45485. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45486. private _options;
  45487. private _controllers;
  45488. private _currentTeleportationControllerId;
  45489. private _floorMeshes;
  45490. private _quadraticBezierCurve;
  45491. private _selectionFeature;
  45492. private _snapToPositions;
  45493. private _snappedToPoint;
  45494. private _teleportationRingMaterial?;
  45495. private _tmpRay;
  45496. private _tmpVector;
  45497. /**
  45498. * The module's name
  45499. */
  45500. static readonly Name: string;
  45501. /**
  45502. * The (Babylon) version of this module.
  45503. * This is an integer representing the implementation version.
  45504. * This number does not correspond to the webxr specs version
  45505. */
  45506. static readonly Version: number;
  45507. /**
  45508. * Is movement backwards enabled
  45509. */
  45510. backwardsMovementEnabled: boolean;
  45511. /**
  45512. * Distance to travel when moving backwards
  45513. */
  45514. backwardsTeleportationDistance: number;
  45515. /**
  45516. * The distance from the user to the inspection point in the direction of the controller
  45517. * A higher number will allow the user to move further
  45518. * defaults to 5 (meters, in xr units)
  45519. */
  45520. parabolicCheckRadius: number;
  45521. /**
  45522. * Should the module support parabolic ray on top of direct ray
  45523. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45524. * Very helpful when moving between floors / different heights
  45525. */
  45526. parabolicRayEnabled: boolean;
  45527. /**
  45528. * How much rotation should be applied when rotating right and left
  45529. */
  45530. rotationAngle: number;
  45531. /**
  45532. * Is rotation enabled when moving forward?
  45533. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45534. */
  45535. rotationEnabled: boolean;
  45536. /**
  45537. * constructs a new anchor system
  45538. * @param _xrSessionManager an instance of WebXRSessionManager
  45539. * @param _options configuration object for this feature
  45540. */
  45541. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45542. /**
  45543. * Get the snapPointsOnly flag
  45544. */
  45545. get snapPointsOnly(): boolean;
  45546. /**
  45547. * Sets the snapPointsOnly flag
  45548. * @param snapToPoints should teleportation be exclusively to snap points
  45549. */
  45550. set snapPointsOnly(snapToPoints: boolean);
  45551. /**
  45552. * Add a new mesh to the floor meshes array
  45553. * @param mesh the mesh to use as floor mesh
  45554. */
  45555. addFloorMesh(mesh: AbstractMesh): void;
  45556. /**
  45557. * Add a new snap-to point to fix teleportation to this position
  45558. * @param newSnapPoint The new Snap-To point
  45559. */
  45560. addSnapPoint(newSnapPoint: Vector3): void;
  45561. attach(): boolean;
  45562. detach(): boolean;
  45563. dispose(): void;
  45564. /**
  45565. * Remove a mesh from the floor meshes array
  45566. * @param mesh the mesh to remove
  45567. */
  45568. removeFloorMesh(mesh: AbstractMesh): void;
  45569. /**
  45570. * Remove a mesh from the floor meshes array using its name
  45571. * @param name the mesh name to remove
  45572. */
  45573. removeFloorMeshByName(name: string): void;
  45574. /**
  45575. * 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
  45576. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45577. * @returns was the point found and removed or not
  45578. */
  45579. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45580. /**
  45581. * This function sets a selection feature that will be disabled when
  45582. * the forward ray is shown and will be reattached when hidden.
  45583. * This is used to remove the selection rays when moving.
  45584. * @param selectionFeature the feature to disable when forward movement is enabled
  45585. */
  45586. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45587. protected _onXRFrame(_xrFrame: XRFrame): void;
  45588. private _attachController;
  45589. private _createDefaultTargetMesh;
  45590. private _detachController;
  45591. private _findClosestSnapPointWithRadius;
  45592. private _setTargetMeshPosition;
  45593. private _setTargetMeshVisibility;
  45594. private _showParabolicPath;
  45595. private _teleportForward;
  45596. }
  45597. }
  45598. declare module BABYLON {
  45599. /**
  45600. * Options for the default xr helper
  45601. */
  45602. export class WebXRDefaultExperienceOptions {
  45603. /**
  45604. * Enable or disable default UI to enter XR
  45605. */
  45606. disableDefaultUI?: boolean;
  45607. /**
  45608. * Should teleportation not initialize. defaults to false.
  45609. */
  45610. disableTeleportation?: boolean;
  45611. /**
  45612. * Floor meshes that will be used for teleport
  45613. */
  45614. floorMeshes?: Array<AbstractMesh>;
  45615. /**
  45616. * If set to true, the first frame will not be used to reset position
  45617. * The first frame is mainly used when copying transformation from the old camera
  45618. * Mainly used in AR
  45619. */
  45620. ignoreNativeCameraTransformation?: boolean;
  45621. /**
  45622. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45623. */
  45624. inputOptions?: IWebXRInputOptions;
  45625. /**
  45626. * optional configuration for the output canvas
  45627. */
  45628. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45629. /**
  45630. * optional UI options. This can be used among other to change session mode and reference space type
  45631. */
  45632. uiOptions?: WebXREnterExitUIOptions;
  45633. /**
  45634. * When loading teleportation and pointer select, use stable versions instead of latest.
  45635. */
  45636. useStablePlugins?: boolean;
  45637. /**
  45638. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  45639. */
  45640. renderingGroupId?: number;
  45641. /**
  45642. * A list of optional features to init the session with
  45643. * If set to true, all features we support will be added
  45644. */
  45645. optionalFeatures?: boolean | string[];
  45646. }
  45647. /**
  45648. * Default experience which provides a similar setup to the previous webVRExperience
  45649. */
  45650. export class WebXRDefaultExperience {
  45651. /**
  45652. * Base experience
  45653. */
  45654. baseExperience: WebXRExperienceHelper;
  45655. /**
  45656. * Enables ui for entering/exiting xr
  45657. */
  45658. enterExitUI: WebXREnterExitUI;
  45659. /**
  45660. * Input experience extension
  45661. */
  45662. input: WebXRInput;
  45663. /**
  45664. * Enables laser pointer and selection
  45665. */
  45666. pointerSelection: WebXRControllerPointerSelection;
  45667. /**
  45668. * Default target xr should render to
  45669. */
  45670. renderTarget: WebXRRenderTarget;
  45671. /**
  45672. * Enables teleportation
  45673. */
  45674. teleportation: WebXRMotionControllerTeleportation;
  45675. private constructor();
  45676. /**
  45677. * Creates the default xr experience
  45678. * @param scene scene
  45679. * @param options options for basic configuration
  45680. * @returns resulting WebXRDefaultExperience
  45681. */
  45682. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45683. /**
  45684. * DIsposes of the experience helper
  45685. */
  45686. dispose(): void;
  45687. }
  45688. }
  45689. declare module BABYLON {
  45690. /**
  45691. * Options to modify the vr teleportation behavior.
  45692. */
  45693. export interface VRTeleportationOptions {
  45694. /**
  45695. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45696. */
  45697. floorMeshName?: string;
  45698. /**
  45699. * A list of meshes to be used as the teleportation floor. (default: empty)
  45700. */
  45701. floorMeshes?: Mesh[];
  45702. /**
  45703. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45704. */
  45705. teleportationMode?: number;
  45706. /**
  45707. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45708. */
  45709. teleportationTime?: number;
  45710. /**
  45711. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45712. */
  45713. teleportationSpeed?: number;
  45714. /**
  45715. * The easing function used in the animation or null for Linear. (default CircleEase)
  45716. */
  45717. easingFunction?: EasingFunction;
  45718. }
  45719. /**
  45720. * Options to modify the vr experience helper's behavior.
  45721. */
  45722. export interface VRExperienceHelperOptions extends WebVROptions {
  45723. /**
  45724. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45725. */
  45726. createDeviceOrientationCamera?: boolean;
  45727. /**
  45728. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45729. */
  45730. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45731. /**
  45732. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45733. */
  45734. laserToggle?: boolean;
  45735. /**
  45736. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45737. */
  45738. floorMeshes?: Mesh[];
  45739. /**
  45740. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45741. */
  45742. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45743. /**
  45744. * Defines if WebXR should be used instead of WebVR (if available)
  45745. */
  45746. useXR?: boolean;
  45747. }
  45748. /**
  45749. * Event containing information after VR has been entered
  45750. */
  45751. export class OnAfterEnteringVRObservableEvent {
  45752. /**
  45753. * If entering vr was successful
  45754. */
  45755. success: boolean;
  45756. }
  45757. /**
  45758. * Helps to quickly add VR support to an existing scene.
  45759. * See http://doc.babylonjs.com/how_to/webvr_helper
  45760. */
  45761. export class VRExperienceHelper {
  45762. /** Options to modify the vr experience helper's behavior. */
  45763. webVROptions: VRExperienceHelperOptions;
  45764. private _scene;
  45765. private _position;
  45766. private _btnVR;
  45767. private _btnVRDisplayed;
  45768. private _webVRsupported;
  45769. private _webVRready;
  45770. private _webVRrequesting;
  45771. private _webVRpresenting;
  45772. private _hasEnteredVR;
  45773. private _fullscreenVRpresenting;
  45774. private _inputElement;
  45775. private _webVRCamera;
  45776. private _vrDeviceOrientationCamera;
  45777. private _deviceOrientationCamera;
  45778. private _existingCamera;
  45779. private _onKeyDown;
  45780. private _onVrDisplayPresentChange;
  45781. private _onVRDisplayChanged;
  45782. private _onVRRequestPresentStart;
  45783. private _onVRRequestPresentComplete;
  45784. /**
  45785. * 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)
  45786. */
  45787. enableGazeEvenWhenNoPointerLock: boolean;
  45788. /**
  45789. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45790. */
  45791. exitVROnDoubleTap: boolean;
  45792. /**
  45793. * Observable raised right before entering VR.
  45794. */
  45795. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45796. /**
  45797. * Observable raised when entering VR has completed.
  45798. */
  45799. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45800. /**
  45801. * Observable raised when exiting VR.
  45802. */
  45803. onExitingVRObservable: Observable<VRExperienceHelper>;
  45804. /**
  45805. * Observable raised when controller mesh is loaded.
  45806. */
  45807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45808. /** Return this.onEnteringVRObservable
  45809. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45810. */
  45811. get onEnteringVR(): Observable<VRExperienceHelper>;
  45812. /** Return this.onExitingVRObservable
  45813. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45814. */
  45815. get onExitingVR(): Observable<VRExperienceHelper>;
  45816. /** Return this.onControllerMeshLoadedObservable
  45817. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45818. */
  45819. get onControllerMeshLoaded(): Observable<WebVRController>;
  45820. private _rayLength;
  45821. private _useCustomVRButton;
  45822. private _teleportationRequested;
  45823. private _teleportActive;
  45824. private _floorMeshName;
  45825. private _floorMeshesCollection;
  45826. private _teleportationMode;
  45827. private _teleportationTime;
  45828. private _teleportationSpeed;
  45829. private _teleportationEasing;
  45830. private _rotationAllowed;
  45831. private _teleportBackwardsVector;
  45832. private _teleportationTarget;
  45833. private _isDefaultTeleportationTarget;
  45834. private _postProcessMove;
  45835. private _teleportationFillColor;
  45836. private _teleportationBorderColor;
  45837. private _rotationAngle;
  45838. private _haloCenter;
  45839. private _cameraGazer;
  45840. private _padSensibilityUp;
  45841. private _padSensibilityDown;
  45842. private _leftController;
  45843. private _rightController;
  45844. private _gazeColor;
  45845. private _laserColor;
  45846. private _pickedLaserColor;
  45847. private _pickedGazeColor;
  45848. /**
  45849. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45850. */
  45851. onNewMeshSelected: Observable<AbstractMesh>;
  45852. /**
  45853. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45854. * This observable will provide the mesh and the controller used to select the mesh
  45855. */
  45856. onMeshSelectedWithController: Observable<{
  45857. mesh: AbstractMesh;
  45858. controller: WebVRController;
  45859. }>;
  45860. /**
  45861. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45862. */
  45863. onNewMeshPicked: Observable<PickingInfo>;
  45864. private _circleEase;
  45865. /**
  45866. * Observable raised before camera teleportation
  45867. */
  45868. onBeforeCameraTeleport: Observable<Vector3>;
  45869. /**
  45870. * Observable raised after camera teleportation
  45871. */
  45872. onAfterCameraTeleport: Observable<Vector3>;
  45873. /**
  45874. * Observable raised when current selected mesh gets unselected
  45875. */
  45876. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45877. private _raySelectionPredicate;
  45878. /**
  45879. * To be optionaly changed by user to define custom ray selection
  45880. */
  45881. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45882. /**
  45883. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45884. */
  45885. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45886. /**
  45887. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45888. */
  45889. teleportationEnabled: boolean;
  45890. private _defaultHeight;
  45891. private _teleportationInitialized;
  45892. private _interactionsEnabled;
  45893. private _interactionsRequested;
  45894. private _displayGaze;
  45895. private _displayLaserPointer;
  45896. /**
  45897. * The mesh used to display where the user is going to teleport.
  45898. */
  45899. get teleportationTarget(): Mesh;
  45900. /**
  45901. * Sets the mesh to be used to display where the user is going to teleport.
  45902. */
  45903. set teleportationTarget(value: Mesh);
  45904. /**
  45905. * 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
  45906. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45907. * See http://doc.babylonjs.com/resources/baking_transformations
  45908. */
  45909. get gazeTrackerMesh(): Mesh;
  45910. set gazeTrackerMesh(value: Mesh);
  45911. /**
  45912. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45913. */
  45914. updateGazeTrackerScale: boolean;
  45915. /**
  45916. * If the gaze trackers color should be updated when selecting meshes
  45917. */
  45918. updateGazeTrackerColor: boolean;
  45919. /**
  45920. * If the controller laser color should be updated when selecting meshes
  45921. */
  45922. updateControllerLaserColor: boolean;
  45923. /**
  45924. * The gaze tracking mesh corresponding to the left controller
  45925. */
  45926. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45927. /**
  45928. * The gaze tracking mesh corresponding to the right controller
  45929. */
  45930. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45931. /**
  45932. * If the ray of the gaze should be displayed.
  45933. */
  45934. get displayGaze(): boolean;
  45935. /**
  45936. * Sets if the ray of the gaze should be displayed.
  45937. */
  45938. set displayGaze(value: boolean);
  45939. /**
  45940. * If the ray of the LaserPointer should be displayed.
  45941. */
  45942. get displayLaserPointer(): boolean;
  45943. /**
  45944. * Sets if the ray of the LaserPointer should be displayed.
  45945. */
  45946. set displayLaserPointer(value: boolean);
  45947. /**
  45948. * The deviceOrientationCamera used as the camera when not in VR.
  45949. */
  45950. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45951. /**
  45952. * Based on the current WebVR support, returns the current VR camera used.
  45953. */
  45954. get currentVRCamera(): Nullable<Camera>;
  45955. /**
  45956. * The webVRCamera which is used when in VR.
  45957. */
  45958. get webVRCamera(): WebVRFreeCamera;
  45959. /**
  45960. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45961. */
  45962. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45963. /**
  45964. * The html button that is used to trigger entering into VR.
  45965. */
  45966. get vrButton(): Nullable<HTMLButtonElement>;
  45967. private get _teleportationRequestInitiated();
  45968. /**
  45969. * Defines whether or not Pointer lock should be requested when switching to
  45970. * full screen.
  45971. */
  45972. requestPointerLockOnFullScreen: boolean;
  45973. /**
  45974. * If asking to force XR, this will be populated with the default xr experience
  45975. */
  45976. xr: WebXRDefaultExperience;
  45977. /**
  45978. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45979. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45980. */
  45981. xrTestDone: boolean;
  45982. /**
  45983. * Instantiates a VRExperienceHelper.
  45984. * Helps to quickly add VR support to an existing scene.
  45985. * @param scene The scene the VRExperienceHelper belongs to.
  45986. * @param webVROptions Options to modify the vr experience helper's behavior.
  45987. */
  45988. constructor(scene: Scene,
  45989. /** Options to modify the vr experience helper's behavior. */
  45990. webVROptions?: VRExperienceHelperOptions);
  45991. private completeVRInit;
  45992. private _onDefaultMeshLoaded;
  45993. private _onResize;
  45994. private _onFullscreenChange;
  45995. /**
  45996. * Gets a value indicating if we are currently in VR mode.
  45997. */
  45998. get isInVRMode(): boolean;
  45999. private onVrDisplayPresentChange;
  46000. private onVRDisplayChanged;
  46001. private moveButtonToBottomRight;
  46002. private displayVRButton;
  46003. private updateButtonVisibility;
  46004. private _cachedAngularSensibility;
  46005. /**
  46006. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46007. * Otherwise, will use the fullscreen API.
  46008. */
  46009. enterVR(): void;
  46010. /**
  46011. * Attempt to exit VR, or fullscreen.
  46012. */
  46013. exitVR(): void;
  46014. /**
  46015. * The position of the vr experience helper.
  46016. */
  46017. get position(): Vector3;
  46018. /**
  46019. * Sets the position of the vr experience helper.
  46020. */
  46021. set position(value: Vector3);
  46022. /**
  46023. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46024. */
  46025. enableInteractions(): void;
  46026. private get _noControllerIsActive();
  46027. private beforeRender;
  46028. private _isTeleportationFloor;
  46029. /**
  46030. * Adds a floor mesh to be used for teleportation.
  46031. * @param floorMesh the mesh to be used for teleportation.
  46032. */
  46033. addFloorMesh(floorMesh: Mesh): void;
  46034. /**
  46035. * Removes a floor mesh from being used for teleportation.
  46036. * @param floorMesh the mesh to be removed.
  46037. */
  46038. removeFloorMesh(floorMesh: Mesh): void;
  46039. /**
  46040. * Enables interactions and teleportation using the VR controllers and gaze.
  46041. * @param vrTeleportationOptions options to modify teleportation behavior.
  46042. */
  46043. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46044. private _onNewGamepadConnected;
  46045. private _tryEnableInteractionOnController;
  46046. private _onNewGamepadDisconnected;
  46047. private _enableInteractionOnController;
  46048. private _checkTeleportWithRay;
  46049. private _checkRotate;
  46050. private _checkTeleportBackwards;
  46051. private _enableTeleportationOnController;
  46052. private _createTeleportationCircles;
  46053. private _displayTeleportationTarget;
  46054. private _hideTeleportationTarget;
  46055. private _rotateCamera;
  46056. private _moveTeleportationSelectorTo;
  46057. private _workingVector;
  46058. private _workingQuaternion;
  46059. private _workingMatrix;
  46060. /**
  46061. * Time Constant Teleportation Mode
  46062. */
  46063. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46064. /**
  46065. * Speed Constant Teleportation Mode
  46066. */
  46067. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46068. /**
  46069. * Teleports the users feet to the desired location
  46070. * @param location The location where the user's feet should be placed
  46071. */
  46072. teleportCamera(location: Vector3): void;
  46073. private _convertNormalToDirectionOfRay;
  46074. private _castRayAndSelectObject;
  46075. private _notifySelectedMeshUnselected;
  46076. /**
  46077. * Permanently set new colors for the laser pointer
  46078. * @param color the new laser color
  46079. * @param pickedColor the new laser color when picked mesh detected
  46080. */
  46081. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46082. /**
  46083. * Set lighting enabled / disabled on the laser pointer of both controllers
  46084. * @param enabled should the lighting be enabled on the laser pointer
  46085. */
  46086. setLaserLightingState(enabled?: boolean): void;
  46087. /**
  46088. * Permanently set new colors for the gaze pointer
  46089. * @param color the new gaze color
  46090. * @param pickedColor the new gaze color when picked mesh detected
  46091. */
  46092. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46093. /**
  46094. * Sets the color of the laser ray from the vr controllers.
  46095. * @param color new color for the ray.
  46096. */
  46097. changeLaserColor(color: Color3): void;
  46098. /**
  46099. * Sets the color of the ray from the vr headsets gaze.
  46100. * @param color new color for the ray.
  46101. */
  46102. changeGazeColor(color: Color3): void;
  46103. /**
  46104. * Exits VR and disposes of the vr experience helper
  46105. */
  46106. dispose(): void;
  46107. /**
  46108. * Gets the name of the VRExperienceHelper class
  46109. * @returns "VRExperienceHelper"
  46110. */
  46111. getClassName(): string;
  46112. }
  46113. }
  46114. declare module BABYLON {
  46115. /**
  46116. * Contains an array of blocks representing the octree
  46117. */
  46118. export interface IOctreeContainer<T> {
  46119. /**
  46120. * Blocks within the octree
  46121. */
  46122. blocks: Array<OctreeBlock<T>>;
  46123. }
  46124. /**
  46125. * Class used to store a cell in an octree
  46126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46127. */
  46128. export class OctreeBlock<T> {
  46129. /**
  46130. * Gets the content of the current block
  46131. */
  46132. entries: T[];
  46133. /**
  46134. * Gets the list of block children
  46135. */
  46136. blocks: Array<OctreeBlock<T>>;
  46137. private _depth;
  46138. private _maxDepth;
  46139. private _capacity;
  46140. private _minPoint;
  46141. private _maxPoint;
  46142. private _boundingVectors;
  46143. private _creationFunc;
  46144. /**
  46145. * Creates a new block
  46146. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46147. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46148. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46149. * @param depth defines the current depth of this block in the octree
  46150. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46151. * @param creationFunc defines a callback to call when an element is added to the block
  46152. */
  46153. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46154. /**
  46155. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46156. */
  46157. get capacity(): number;
  46158. /**
  46159. * Gets the minimum vector (in world space) of the block's bounding box
  46160. */
  46161. get minPoint(): Vector3;
  46162. /**
  46163. * Gets the maximum vector (in world space) of the block's bounding box
  46164. */
  46165. get maxPoint(): Vector3;
  46166. /**
  46167. * Add a new element to this block
  46168. * @param entry defines the element to add
  46169. */
  46170. addEntry(entry: T): void;
  46171. /**
  46172. * Remove an element from this block
  46173. * @param entry defines the element to remove
  46174. */
  46175. removeEntry(entry: T): void;
  46176. /**
  46177. * Add an array of elements to this block
  46178. * @param entries defines the array of elements to add
  46179. */
  46180. addEntries(entries: T[]): void;
  46181. /**
  46182. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46183. * @param frustumPlanes defines the frustum planes to test
  46184. * @param selection defines the array to store current content if selection is positive
  46185. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46186. */
  46187. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46188. /**
  46189. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46190. * @param sphereCenter defines the bounding sphere center
  46191. * @param sphereRadius defines the bounding sphere radius
  46192. * @param selection defines the array to store current content if selection is positive
  46193. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46194. */
  46195. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46196. /**
  46197. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46198. * @param ray defines the ray to test with
  46199. * @param selection defines the array to store current content if selection is positive
  46200. */
  46201. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46202. /**
  46203. * Subdivide the content into child blocks (this block will then be empty)
  46204. */
  46205. createInnerBlocks(): void;
  46206. /**
  46207. * @hidden
  46208. */
  46209. 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;
  46210. }
  46211. }
  46212. declare module BABYLON {
  46213. /**
  46214. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46216. */
  46217. export class Octree<T> {
  46218. /** 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.) */
  46219. maxDepth: number;
  46220. /**
  46221. * Blocks within the octree containing objects
  46222. */
  46223. blocks: Array<OctreeBlock<T>>;
  46224. /**
  46225. * Content stored in the octree
  46226. */
  46227. dynamicContent: T[];
  46228. private _maxBlockCapacity;
  46229. private _selectionContent;
  46230. private _creationFunc;
  46231. /**
  46232. * Creates a octree
  46233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46234. * @param creationFunc function to be used to instatiate the octree
  46235. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46236. * @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.)
  46237. */
  46238. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46239. /** 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.) */
  46240. maxDepth?: number);
  46241. /**
  46242. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46243. * @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);
  46244. * @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);
  46245. * @param entries meshes to be added to the octree blocks
  46246. */
  46247. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46248. /**
  46249. * Adds a mesh to the octree
  46250. * @param entry Mesh to add to the octree
  46251. */
  46252. addMesh(entry: T): void;
  46253. /**
  46254. * Remove an element from the octree
  46255. * @param entry defines the element to remove
  46256. */
  46257. removeMesh(entry: T): void;
  46258. /**
  46259. * Selects an array of meshes within the frustum
  46260. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46261. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46262. * @returns array of meshes within the frustum
  46263. */
  46264. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46265. /**
  46266. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46267. * @param sphereCenter defines the bounding sphere center
  46268. * @param sphereRadius defines the bounding sphere radius
  46269. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46270. * @returns an array of objects that intersect the sphere
  46271. */
  46272. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46273. /**
  46274. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46275. * @param ray defines the ray to test with
  46276. * @returns array of intersected objects
  46277. */
  46278. intersectsRay(ray: Ray): SmartArray<T>;
  46279. /**
  46280. * Adds a mesh into the octree block if it intersects the block
  46281. */
  46282. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46283. /**
  46284. * Adds a submesh into the octree block if it intersects the block
  46285. */
  46286. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46287. }
  46288. }
  46289. declare module BABYLON {
  46290. interface Scene {
  46291. /**
  46292. * @hidden
  46293. * Backing Filed
  46294. */
  46295. _selectionOctree: Octree<AbstractMesh>;
  46296. /**
  46297. * Gets the octree used to boost mesh selection (picking)
  46298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46299. */
  46300. selectionOctree: Octree<AbstractMesh>;
  46301. /**
  46302. * Creates or updates the octree used to boost selection (picking)
  46303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46304. * @param maxCapacity defines the maximum capacity per leaf
  46305. * @param maxDepth defines the maximum depth of the octree
  46306. * @returns an octree of AbstractMesh
  46307. */
  46308. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46309. }
  46310. interface AbstractMesh {
  46311. /**
  46312. * @hidden
  46313. * Backing Field
  46314. */
  46315. _submeshesOctree: Octree<SubMesh>;
  46316. /**
  46317. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46318. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46319. * @param maxCapacity defines the maximum size of each block (64 by default)
  46320. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46321. * @returns the new octree
  46322. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46324. */
  46325. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46326. }
  46327. /**
  46328. * Defines the octree scene component responsible to manage any octrees
  46329. * in a given scene.
  46330. */
  46331. export class OctreeSceneComponent {
  46332. /**
  46333. * The component name help to identify the component in the list of scene components.
  46334. */
  46335. readonly name: string;
  46336. /**
  46337. * The scene the component belongs to.
  46338. */
  46339. scene: Scene;
  46340. /**
  46341. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46342. */
  46343. readonly checksIsEnabled: boolean;
  46344. /**
  46345. * Creates a new instance of the component for the given scene
  46346. * @param scene Defines the scene to register the component in
  46347. */
  46348. constructor(scene: Scene);
  46349. /**
  46350. * Registers the component in a given scene
  46351. */
  46352. register(): void;
  46353. /**
  46354. * Return the list of active meshes
  46355. * @returns the list of active meshes
  46356. */
  46357. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46358. /**
  46359. * Return the list of active sub meshes
  46360. * @param mesh The mesh to get the candidates sub meshes from
  46361. * @returns the list of active sub meshes
  46362. */
  46363. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46364. private _tempRay;
  46365. /**
  46366. * Return the list of sub meshes intersecting with a given local ray
  46367. * @param mesh defines the mesh to find the submesh for
  46368. * @param localRay defines the ray in local space
  46369. * @returns the list of intersecting sub meshes
  46370. */
  46371. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46372. /**
  46373. * Return the list of sub meshes colliding with a collider
  46374. * @param mesh defines the mesh to find the submesh for
  46375. * @param collider defines the collider to evaluate the collision against
  46376. * @returns the list of colliding sub meshes
  46377. */
  46378. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46379. /**
  46380. * Rebuilds the elements related to this component in case of
  46381. * context lost for instance.
  46382. */
  46383. rebuild(): void;
  46384. /**
  46385. * Disposes the component and the associated ressources.
  46386. */
  46387. dispose(): void;
  46388. }
  46389. }
  46390. declare module BABYLON {
  46391. /**
  46392. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46393. */
  46394. export class Gizmo implements IDisposable {
  46395. /** The utility layer the gizmo will be added to */
  46396. gizmoLayer: UtilityLayerRenderer;
  46397. /**
  46398. * The root mesh of the gizmo
  46399. */
  46400. _rootMesh: Mesh;
  46401. private _attachedMesh;
  46402. /**
  46403. * Ratio for the scale of the gizmo (Default: 1)
  46404. */
  46405. scaleRatio: number;
  46406. /**
  46407. * If a custom mesh has been set (Default: false)
  46408. */
  46409. protected _customMeshSet: boolean;
  46410. /**
  46411. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46412. * * When set, interactions will be enabled
  46413. */
  46414. get attachedMesh(): Nullable<AbstractMesh>;
  46415. set attachedMesh(value: Nullable<AbstractMesh>);
  46416. /**
  46417. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46418. * @param mesh The mesh to replace the default mesh of the gizmo
  46419. */
  46420. setCustomMesh(mesh: Mesh): void;
  46421. /**
  46422. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46423. */
  46424. updateGizmoRotationToMatchAttachedMesh: boolean;
  46425. /**
  46426. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46427. */
  46428. updateGizmoPositionToMatchAttachedMesh: boolean;
  46429. /**
  46430. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46431. */
  46432. updateScale: boolean;
  46433. protected _interactionsEnabled: boolean;
  46434. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46435. private _beforeRenderObserver;
  46436. private _tempVector;
  46437. /**
  46438. * Creates a gizmo
  46439. * @param gizmoLayer The utility layer the gizmo will be added to
  46440. */
  46441. constructor(
  46442. /** The utility layer the gizmo will be added to */
  46443. gizmoLayer?: UtilityLayerRenderer);
  46444. /**
  46445. * Updates the gizmo to match the attached mesh's position/rotation
  46446. */
  46447. protected _update(): void;
  46448. /**
  46449. * Disposes of the gizmo
  46450. */
  46451. dispose(): void;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * Single plane drag gizmo
  46457. */
  46458. export class PlaneDragGizmo extends Gizmo {
  46459. /**
  46460. * Drag behavior responsible for the gizmos dragging interactions
  46461. */
  46462. dragBehavior: PointerDragBehavior;
  46463. private _pointerObserver;
  46464. /**
  46465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46466. */
  46467. snapDistance: number;
  46468. /**
  46469. * Event that fires each time the gizmo snaps to a new location.
  46470. * * snapDistance is the the change in distance
  46471. */
  46472. onSnapObservable: Observable<{
  46473. snapDistance: number;
  46474. }>;
  46475. private _plane;
  46476. private _coloredMaterial;
  46477. private _hoverMaterial;
  46478. private _isEnabled;
  46479. private _parent;
  46480. /** @hidden */
  46481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46482. /** @hidden */
  46483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46484. /**
  46485. * Creates a PlaneDragGizmo
  46486. * @param gizmoLayer The utility layer the gizmo will be added to
  46487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46488. * @param color The color of the gizmo
  46489. */
  46490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46492. /**
  46493. * If the gizmo is enabled
  46494. */
  46495. set isEnabled(value: boolean);
  46496. get isEnabled(): boolean;
  46497. /**
  46498. * Disposes of the gizmo
  46499. */
  46500. dispose(): void;
  46501. }
  46502. }
  46503. declare module BABYLON {
  46504. /**
  46505. * Gizmo that enables dragging a mesh along 3 axis
  46506. */
  46507. export class PositionGizmo extends Gizmo {
  46508. /**
  46509. * Internal gizmo used for interactions on the x axis
  46510. */
  46511. xGizmo: AxisDragGizmo;
  46512. /**
  46513. * Internal gizmo used for interactions on the y axis
  46514. */
  46515. yGizmo: AxisDragGizmo;
  46516. /**
  46517. * Internal gizmo used for interactions on the z axis
  46518. */
  46519. zGizmo: AxisDragGizmo;
  46520. /**
  46521. * Internal gizmo used for interactions on the yz plane
  46522. */
  46523. xPlaneGizmo: PlaneDragGizmo;
  46524. /**
  46525. * Internal gizmo used for interactions on the xz plane
  46526. */
  46527. yPlaneGizmo: PlaneDragGizmo;
  46528. /**
  46529. * Internal gizmo used for interactions on the xy plane
  46530. */
  46531. zPlaneGizmo: PlaneDragGizmo;
  46532. /**
  46533. * private variables
  46534. */
  46535. private _meshAttached;
  46536. private _updateGizmoRotationToMatchAttachedMesh;
  46537. private _snapDistance;
  46538. private _scaleRatio;
  46539. /** Fires an event when any of it's sub gizmos are dragged */
  46540. onDragStartObservable: Observable<unknown>;
  46541. /** Fires an event when any of it's sub gizmos are released from dragging */
  46542. onDragEndObservable: Observable<unknown>;
  46543. /**
  46544. * If set to true, planar drag is enabled
  46545. */
  46546. private _planarGizmoEnabled;
  46547. get attachedMesh(): Nullable<AbstractMesh>;
  46548. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46549. /**
  46550. * Creates a PositionGizmo
  46551. * @param gizmoLayer The utility layer the gizmo will be added to
  46552. */
  46553. constructor(gizmoLayer?: UtilityLayerRenderer);
  46554. /**
  46555. * If the planar drag gizmo is enabled
  46556. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46557. */
  46558. set planarGizmoEnabled(value: boolean);
  46559. get planarGizmoEnabled(): boolean;
  46560. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46561. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46562. /**
  46563. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46564. */
  46565. set snapDistance(value: number);
  46566. get snapDistance(): number;
  46567. /**
  46568. * Ratio for the scale of the gizmo (Default: 1)
  46569. */
  46570. set scaleRatio(value: number);
  46571. get scaleRatio(): number;
  46572. /**
  46573. * Disposes of the gizmo
  46574. */
  46575. dispose(): void;
  46576. /**
  46577. * CustomMeshes are not supported by this gizmo
  46578. * @param mesh The mesh to replace the default mesh of the gizmo
  46579. */
  46580. setCustomMesh(mesh: Mesh): void;
  46581. }
  46582. }
  46583. declare module BABYLON {
  46584. /**
  46585. * Single axis drag gizmo
  46586. */
  46587. export class AxisDragGizmo extends Gizmo {
  46588. /**
  46589. * Drag behavior responsible for the gizmos dragging interactions
  46590. */
  46591. dragBehavior: PointerDragBehavior;
  46592. private _pointerObserver;
  46593. /**
  46594. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46595. */
  46596. snapDistance: number;
  46597. /**
  46598. * Event that fires each time the gizmo snaps to a new location.
  46599. * * snapDistance is the the change in distance
  46600. */
  46601. onSnapObservable: Observable<{
  46602. snapDistance: number;
  46603. }>;
  46604. private _isEnabled;
  46605. private _parent;
  46606. private _arrow;
  46607. private _coloredMaterial;
  46608. private _hoverMaterial;
  46609. /** @hidden */
  46610. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46611. /** @hidden */
  46612. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46613. /**
  46614. * Creates an AxisDragGizmo
  46615. * @param gizmoLayer The utility layer the gizmo will be added to
  46616. * @param dragAxis The axis which the gizmo will be able to drag on
  46617. * @param color The color of the gizmo
  46618. */
  46619. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46620. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46621. /**
  46622. * If the gizmo is enabled
  46623. */
  46624. set isEnabled(value: boolean);
  46625. get isEnabled(): boolean;
  46626. /**
  46627. * Disposes of the gizmo
  46628. */
  46629. dispose(): void;
  46630. }
  46631. }
  46632. declare module BABYLON.Debug {
  46633. /**
  46634. * The Axes viewer will show 3 axes in a specific point in space
  46635. */
  46636. export class AxesViewer {
  46637. private _xAxis;
  46638. private _yAxis;
  46639. private _zAxis;
  46640. private _scaleLinesFactor;
  46641. private _instanced;
  46642. /**
  46643. * Gets the hosting scene
  46644. */
  46645. scene: Scene;
  46646. /**
  46647. * Gets or sets a number used to scale line length
  46648. */
  46649. scaleLines: number;
  46650. /** Gets the node hierarchy used to render x-axis */
  46651. get xAxis(): TransformNode;
  46652. /** Gets the node hierarchy used to render y-axis */
  46653. get yAxis(): TransformNode;
  46654. /** Gets the node hierarchy used to render z-axis */
  46655. get zAxis(): TransformNode;
  46656. /**
  46657. * Creates a new AxesViewer
  46658. * @param scene defines the hosting scene
  46659. * @param scaleLines defines a number used to scale line length (1 by default)
  46660. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46661. * @param xAxis defines the node hierarchy used to render the x-axis
  46662. * @param yAxis defines the node hierarchy used to render the y-axis
  46663. * @param zAxis defines the node hierarchy used to render the z-axis
  46664. */
  46665. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46666. /**
  46667. * Force the viewer to update
  46668. * @param position defines the position of the viewer
  46669. * @param xaxis defines the x axis of the viewer
  46670. * @param yaxis defines the y axis of the viewer
  46671. * @param zaxis defines the z axis of the viewer
  46672. */
  46673. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46674. /**
  46675. * Creates an instance of this axes viewer.
  46676. * @returns a new axes viewer with instanced meshes
  46677. */
  46678. createInstance(): AxesViewer;
  46679. /** Releases resources */
  46680. dispose(): void;
  46681. private static _SetRenderingGroupId;
  46682. }
  46683. }
  46684. declare module BABYLON.Debug {
  46685. /**
  46686. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46687. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46688. */
  46689. export class BoneAxesViewer extends AxesViewer {
  46690. /**
  46691. * Gets or sets the target mesh where to display the axes viewer
  46692. */
  46693. mesh: Nullable<Mesh>;
  46694. /**
  46695. * Gets or sets the target bone where to display the axes viewer
  46696. */
  46697. bone: Nullable<Bone>;
  46698. /** Gets current position */
  46699. pos: Vector3;
  46700. /** Gets direction of X axis */
  46701. xaxis: Vector3;
  46702. /** Gets direction of Y axis */
  46703. yaxis: Vector3;
  46704. /** Gets direction of Z axis */
  46705. zaxis: Vector3;
  46706. /**
  46707. * Creates a new BoneAxesViewer
  46708. * @param scene defines the hosting scene
  46709. * @param bone defines the target bone
  46710. * @param mesh defines the target mesh
  46711. * @param scaleLines defines a scaling factor for line length (1 by default)
  46712. */
  46713. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46714. /**
  46715. * Force the viewer to update
  46716. */
  46717. update(): void;
  46718. /** Releases resources */
  46719. dispose(): void;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * Interface used to define scene explorer extensibility option
  46725. */
  46726. export interface IExplorerExtensibilityOption {
  46727. /**
  46728. * Define the option label
  46729. */
  46730. label: string;
  46731. /**
  46732. * Defines the action to execute on click
  46733. */
  46734. action: (entity: any) => void;
  46735. }
  46736. /**
  46737. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46738. */
  46739. export interface IExplorerExtensibilityGroup {
  46740. /**
  46741. * Defines a predicate to test if a given type mut be extended
  46742. */
  46743. predicate: (entity: any) => boolean;
  46744. /**
  46745. * Gets the list of options added to a type
  46746. */
  46747. entries: IExplorerExtensibilityOption[];
  46748. }
  46749. /**
  46750. * Interface used to define the options to use to create the Inspector
  46751. */
  46752. export interface IInspectorOptions {
  46753. /**
  46754. * Display in overlay mode (default: false)
  46755. */
  46756. overlay?: boolean;
  46757. /**
  46758. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46759. */
  46760. globalRoot?: HTMLElement;
  46761. /**
  46762. * Display the Scene explorer
  46763. */
  46764. showExplorer?: boolean;
  46765. /**
  46766. * Display the property inspector
  46767. */
  46768. showInspector?: boolean;
  46769. /**
  46770. * Display in embed mode (both panes on the right)
  46771. */
  46772. embedMode?: boolean;
  46773. /**
  46774. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46775. */
  46776. handleResize?: boolean;
  46777. /**
  46778. * Allow the panes to popup (default: true)
  46779. */
  46780. enablePopup?: boolean;
  46781. /**
  46782. * Allow the panes to be closed by users (default: true)
  46783. */
  46784. enableClose?: boolean;
  46785. /**
  46786. * Optional list of extensibility entries
  46787. */
  46788. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46789. /**
  46790. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46791. */
  46792. inspectorURL?: string;
  46793. /**
  46794. * Optional initial tab (default to DebugLayerTab.Properties)
  46795. */
  46796. initialTab?: DebugLayerTab;
  46797. }
  46798. interface Scene {
  46799. /**
  46800. * @hidden
  46801. * Backing field
  46802. */
  46803. _debugLayer: DebugLayer;
  46804. /**
  46805. * Gets the debug layer (aka Inspector) associated with the scene
  46806. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46807. */
  46808. debugLayer: DebugLayer;
  46809. }
  46810. /**
  46811. * Enum of inspector action tab
  46812. */
  46813. export enum DebugLayerTab {
  46814. /**
  46815. * Properties tag (default)
  46816. */
  46817. Properties = 0,
  46818. /**
  46819. * Debug tab
  46820. */
  46821. Debug = 1,
  46822. /**
  46823. * Statistics tab
  46824. */
  46825. Statistics = 2,
  46826. /**
  46827. * Tools tab
  46828. */
  46829. Tools = 3,
  46830. /**
  46831. * Settings tab
  46832. */
  46833. Settings = 4
  46834. }
  46835. /**
  46836. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46837. * what is happening in your scene
  46838. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46839. */
  46840. export class DebugLayer {
  46841. /**
  46842. * Define the url to get the inspector script from.
  46843. * By default it uses the babylonjs CDN.
  46844. * @ignoreNaming
  46845. */
  46846. static InspectorURL: string;
  46847. private _scene;
  46848. private BJSINSPECTOR;
  46849. private _onPropertyChangedObservable?;
  46850. /**
  46851. * Observable triggered when a property is changed through the inspector.
  46852. */
  46853. get onPropertyChangedObservable(): any;
  46854. /**
  46855. * Instantiates a new debug layer.
  46856. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46857. * what is happening in your scene
  46858. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46859. * @param scene Defines the scene to inspect
  46860. */
  46861. constructor(scene: Scene);
  46862. /** Creates the inspector window. */
  46863. private _createInspector;
  46864. /**
  46865. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46866. * @param entity defines the entity to select
  46867. * @param lineContainerTitle defines the specific block to highlight
  46868. */
  46869. select(entity: any, lineContainerTitle?: string): void;
  46870. /** Get the inspector from bundle or global */
  46871. private _getGlobalInspector;
  46872. /**
  46873. * Get if the inspector is visible or not.
  46874. * @returns true if visible otherwise, false
  46875. */
  46876. isVisible(): boolean;
  46877. /**
  46878. * Hide the inspector and close its window.
  46879. */
  46880. hide(): void;
  46881. /**
  46882. * Update the scene in the inspector
  46883. */
  46884. setAsActiveScene(): void;
  46885. /**
  46886. * Launch the debugLayer.
  46887. * @param config Define the configuration of the inspector
  46888. * @return a promise fulfilled when the debug layer is visible
  46889. */
  46890. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46891. }
  46892. }
  46893. declare module BABYLON {
  46894. /**
  46895. * Class containing static functions to help procedurally build meshes
  46896. */
  46897. export class BoxBuilder {
  46898. /**
  46899. * Creates a box mesh
  46900. * * The parameter `size` sets the size (float) of each box side (default 1)
  46901. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46902. * * 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)
  46903. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46905. * * 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
  46906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46907. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46908. * @param name defines the name of the mesh
  46909. * @param options defines the options used to create the mesh
  46910. * @param scene defines the hosting scene
  46911. * @returns the box mesh
  46912. */
  46913. static CreateBox(name: string, options: {
  46914. size?: number;
  46915. width?: number;
  46916. height?: number;
  46917. depth?: number;
  46918. faceUV?: Vector4[];
  46919. faceColors?: Color4[];
  46920. sideOrientation?: number;
  46921. frontUVs?: Vector4;
  46922. backUVs?: Vector4;
  46923. wrap?: boolean;
  46924. topBaseAt?: number;
  46925. bottomBaseAt?: number;
  46926. updatable?: boolean;
  46927. }, scene?: Nullable<Scene>): Mesh;
  46928. }
  46929. }
  46930. declare module BABYLON.Debug {
  46931. /**
  46932. * Used to show the physics impostor around the specific mesh
  46933. */
  46934. export class PhysicsViewer {
  46935. /** @hidden */
  46936. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46937. /** @hidden */
  46938. protected _meshes: Array<Nullable<AbstractMesh>>;
  46939. /** @hidden */
  46940. protected _scene: Nullable<Scene>;
  46941. /** @hidden */
  46942. protected _numMeshes: number;
  46943. /** @hidden */
  46944. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46945. private _renderFunction;
  46946. private _utilityLayer;
  46947. private _debugBoxMesh;
  46948. private _debugSphereMesh;
  46949. private _debugCylinderMesh;
  46950. private _debugMaterial;
  46951. private _debugMeshMeshes;
  46952. /**
  46953. * Creates a new PhysicsViewer
  46954. * @param scene defines the hosting scene
  46955. */
  46956. constructor(scene: Scene);
  46957. /** @hidden */
  46958. protected _updateDebugMeshes(): void;
  46959. /**
  46960. * Renders a specified physic impostor
  46961. * @param impostor defines the impostor to render
  46962. * @param targetMesh defines the mesh represented by the impostor
  46963. * @returns the new debug mesh used to render the impostor
  46964. */
  46965. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46966. /**
  46967. * Hides a specified physic impostor
  46968. * @param impostor defines the impostor to hide
  46969. */
  46970. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46971. private _getDebugMaterial;
  46972. private _getDebugBoxMesh;
  46973. private _getDebugSphereMesh;
  46974. private _getDebugCylinderMesh;
  46975. private _getDebugMeshMesh;
  46976. private _getDebugMesh;
  46977. /** Releases all resources */
  46978. dispose(): void;
  46979. }
  46980. }
  46981. declare module BABYLON {
  46982. /**
  46983. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46984. * in order to better appreciate the issue one might have.
  46985. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46986. */
  46987. export class RayHelper {
  46988. /**
  46989. * Defines the ray we are currently tryin to visualize.
  46990. */
  46991. ray: Nullable<Ray>;
  46992. private _renderPoints;
  46993. private _renderLine;
  46994. private _renderFunction;
  46995. private _scene;
  46996. private _updateToMeshFunction;
  46997. private _attachedToMesh;
  46998. private _meshSpaceDirection;
  46999. private _meshSpaceOrigin;
  47000. /**
  47001. * Helper function to create a colored helper in a scene in one line.
  47002. * @param ray Defines the ray we are currently tryin to visualize
  47003. * @param scene Defines the scene the ray is used in
  47004. * @param color Defines the color we want to see the ray in
  47005. * @returns The newly created ray helper.
  47006. */
  47007. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47008. /**
  47009. * Instantiate a new ray helper.
  47010. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47011. * in order to better appreciate the issue one might have.
  47012. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47013. * @param ray Defines the ray we are currently tryin to visualize
  47014. */
  47015. constructor(ray: Ray);
  47016. /**
  47017. * Shows the ray we are willing to debug.
  47018. * @param scene Defines the scene the ray needs to be rendered in
  47019. * @param color Defines the color the ray needs to be rendered in
  47020. */
  47021. show(scene: Scene, color?: Color3): void;
  47022. /**
  47023. * Hides the ray we are debugging.
  47024. */
  47025. hide(): void;
  47026. private _render;
  47027. /**
  47028. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47029. * @param mesh Defines the mesh we want the helper attached to
  47030. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47031. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47032. * @param length Defines the length of the ray
  47033. */
  47034. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47035. /**
  47036. * Detach the ray helper from the mesh it has previously been attached to.
  47037. */
  47038. detachFromMesh(): void;
  47039. private _updateToMesh;
  47040. /**
  47041. * Dispose the helper and release its associated resources.
  47042. */
  47043. dispose(): void;
  47044. }
  47045. }
  47046. declare module BABYLON.Debug {
  47047. /**
  47048. * Class used to render a debug view of a given skeleton
  47049. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47050. */
  47051. export class SkeletonViewer {
  47052. /** defines the skeleton to render */
  47053. skeleton: Skeleton;
  47054. /** defines the mesh attached to the skeleton */
  47055. mesh: AbstractMesh;
  47056. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47057. autoUpdateBonesMatrices: boolean;
  47058. /** defines the rendering group id to use with the viewer */
  47059. renderingGroupId: number;
  47060. /** Gets or sets the color used to render the skeleton */
  47061. color: Color3;
  47062. private _scene;
  47063. private _debugLines;
  47064. private _debugMesh;
  47065. private _isEnabled;
  47066. private _renderFunction;
  47067. private _utilityLayer;
  47068. /**
  47069. * Returns the mesh used to render the bones
  47070. */
  47071. get debugMesh(): Nullable<LinesMesh>;
  47072. /**
  47073. * Creates a new SkeletonViewer
  47074. * @param skeleton defines the skeleton to render
  47075. * @param mesh defines the mesh attached to the skeleton
  47076. * @param scene defines the hosting scene
  47077. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47078. * @param renderingGroupId defines the rendering group id to use with the viewer
  47079. */
  47080. constructor(
  47081. /** defines the skeleton to render */
  47082. skeleton: Skeleton,
  47083. /** defines the mesh attached to the skeleton */
  47084. mesh: AbstractMesh, scene: Scene,
  47085. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47086. autoUpdateBonesMatrices?: boolean,
  47087. /** defines the rendering group id to use with the viewer */
  47088. renderingGroupId?: number);
  47089. /** Gets or sets a boolean indicating if the viewer is enabled */
  47090. set isEnabled(value: boolean);
  47091. get isEnabled(): boolean;
  47092. private _getBonePosition;
  47093. private _getLinesForBonesWithLength;
  47094. private _getLinesForBonesNoLength;
  47095. /** Update the viewer to sync with current skeleton state */
  47096. update(): void;
  47097. /** Release associated resources */
  47098. dispose(): void;
  47099. }
  47100. }
  47101. declare module BABYLON {
  47102. /**
  47103. * This class will take all inputs from Keyboard, Pointer, and
  47104. * any Gamepads and provide a polling system that all devices
  47105. * will use. This class assumes that there will only be one
  47106. * pointer device and one keyboard.
  47107. */
  47108. export class DeviceInputSystem implements IDisposable {
  47109. /** POINTER_DEVICE */
  47110. static readonly POINTER_DEVICE: string;
  47111. /** KEYBOARD_DEVICE */
  47112. static readonly KEYBOARD_DEVICE: string;
  47113. /**
  47114. * Observable to be triggered when a device is connected
  47115. */
  47116. onDeviceConnectedObservable: Observable<string>;
  47117. /**
  47118. * Observable to be triggered when a device is disconnected
  47119. */
  47120. onDeviceDisconnectedObservable: Observable<string>;
  47121. private _inputs;
  47122. private _gamepads;
  47123. private _keyboardActive;
  47124. private _pointerActive;
  47125. private _elementToAttachTo;
  47126. private _keyboardDownEvent;
  47127. private _keyboardUpEvent;
  47128. private _pointerMoveEvent;
  47129. private _pointerDownEvent;
  47130. private _pointerUpEvent;
  47131. private _gamepadConnectedEvent;
  47132. private _gamepadDisconnectedEvent;
  47133. private static _MAX_KEYCODES;
  47134. private static _MAX_POINTER_INPUTS;
  47135. /**
  47136. * Default Constructor
  47137. * @param engine - engine to pull input element from
  47138. */
  47139. constructor(engine: Engine);
  47140. /**
  47141. * Checks for current device input value, given an id and input index
  47142. * @param deviceName Id of connected device
  47143. * @param inputIndex Index of device input
  47144. * @returns Current value of input
  47145. */
  47146. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  47147. /**
  47148. * Dispose of all the eventlisteners and clears the observables
  47149. */
  47150. dispose(): void;
  47151. /**
  47152. * Add device and inputs to device map
  47153. * @param deviceName Assigned name of device (may be SN)
  47154. * @param numberOfInputs Number of input entries to create for given device
  47155. */
  47156. private _registerDevice;
  47157. /**
  47158. * Given a specific device name, remove that device from the device map
  47159. * @param deviceName Name of device to be removed
  47160. */
  47161. private _unregisterDevice;
  47162. /**
  47163. * Handle all actions that come from keyboard interaction
  47164. */
  47165. private _handleKeyActions;
  47166. /**
  47167. * Handle all actions that come from pointer interaction
  47168. */
  47169. private _handlePointerActions;
  47170. /**
  47171. * Handle all actions that come from gamepad interaction
  47172. */
  47173. private _handleGamepadActions;
  47174. /**
  47175. * Update all non-event based devices with each frame
  47176. */
  47177. private _updateDevice;
  47178. }
  47179. }
  47180. declare module BABYLON {
  47181. /**
  47182. * Options to create the null engine
  47183. */
  47184. export class NullEngineOptions {
  47185. /**
  47186. * Render width (Default: 512)
  47187. */
  47188. renderWidth: number;
  47189. /**
  47190. * Render height (Default: 256)
  47191. */
  47192. renderHeight: number;
  47193. /**
  47194. * Texture size (Default: 512)
  47195. */
  47196. textureSize: number;
  47197. /**
  47198. * If delta time between frames should be constant
  47199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47200. */
  47201. deterministicLockstep: boolean;
  47202. /**
  47203. * Maximum about of steps between frames (Default: 4)
  47204. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47205. */
  47206. lockstepMaxSteps: number;
  47207. }
  47208. /**
  47209. * The null engine class provides support for headless version of babylon.js.
  47210. * This can be used in server side scenario or for testing purposes
  47211. */
  47212. export class NullEngine extends Engine {
  47213. private _options;
  47214. /**
  47215. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47217. * @returns true if engine is in deterministic lock step mode
  47218. */
  47219. isDeterministicLockStep(): boolean;
  47220. /**
  47221. * Gets the max steps when engine is running in deterministic lock step
  47222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47223. * @returns the max steps
  47224. */
  47225. getLockstepMaxSteps(): number;
  47226. /**
  47227. * Gets the current hardware scaling level.
  47228. * By default the hardware scaling level is computed from the window device ratio.
  47229. * 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.
  47230. * @returns a number indicating the current hardware scaling level
  47231. */
  47232. getHardwareScalingLevel(): number;
  47233. constructor(options?: NullEngineOptions);
  47234. /**
  47235. * Creates a vertex buffer
  47236. * @param vertices the data for the vertex buffer
  47237. * @returns the new WebGL static buffer
  47238. */
  47239. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47240. /**
  47241. * Creates a new index buffer
  47242. * @param indices defines the content of the index buffer
  47243. * @param updatable defines if the index buffer must be updatable
  47244. * @returns a new webGL buffer
  47245. */
  47246. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47247. /**
  47248. * Clear the current render buffer or the current render target (if any is set up)
  47249. * @param color defines the color to use
  47250. * @param backBuffer defines if the back buffer must be cleared
  47251. * @param depth defines if the depth buffer must be cleared
  47252. * @param stencil defines if the stencil buffer must be cleared
  47253. */
  47254. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47255. /**
  47256. * Gets the current render width
  47257. * @param useScreen defines if screen size must be used (or the current render target if any)
  47258. * @returns a number defining the current render width
  47259. */
  47260. getRenderWidth(useScreen?: boolean): number;
  47261. /**
  47262. * Gets the current render height
  47263. * @param useScreen defines if screen size must be used (or the current render target if any)
  47264. * @returns a number defining the current render height
  47265. */
  47266. getRenderHeight(useScreen?: boolean): number;
  47267. /**
  47268. * Set the WebGL's viewport
  47269. * @param viewport defines the viewport element to be used
  47270. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47271. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47272. */
  47273. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47275. /**
  47276. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47277. * @param pipelineContext defines the pipeline context to use
  47278. * @param uniformsNames defines the list of uniform names
  47279. * @returns an array of webGL uniform locations
  47280. */
  47281. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47282. /**
  47283. * Gets the lsit of active attributes for a given webGL program
  47284. * @param pipelineContext defines the pipeline context to use
  47285. * @param attributesNames defines the list of attribute names to get
  47286. * @returns an array of indices indicating the offset of each attribute
  47287. */
  47288. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47289. /**
  47290. * Binds an effect to the webGL context
  47291. * @param effect defines the effect to bind
  47292. */
  47293. bindSamplers(effect: Effect): void;
  47294. /**
  47295. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47296. * @param effect defines the effect to activate
  47297. */
  47298. enableEffect(effect: Effect): void;
  47299. /**
  47300. * Set various states to the webGL context
  47301. * @param culling defines backface culling state
  47302. * @param zOffset defines the value to apply to zOffset (0 by default)
  47303. * @param force defines if states must be applied even if cache is up to date
  47304. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47305. */
  47306. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47307. /**
  47308. * Set the value of an uniform to an array of int32
  47309. * @param uniform defines the webGL uniform location where to store the value
  47310. * @param array defines the array of int32 to store
  47311. */
  47312. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47313. /**
  47314. * Set the value of an uniform to an array of int32 (stored as vec2)
  47315. * @param uniform defines the webGL uniform location where to store the value
  47316. * @param array defines the array of int32 to store
  47317. */
  47318. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47319. /**
  47320. * Set the value of an uniform to an array of int32 (stored as vec3)
  47321. * @param uniform defines the webGL uniform location where to store the value
  47322. * @param array defines the array of int32 to store
  47323. */
  47324. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47325. /**
  47326. * Set the value of an uniform to an array of int32 (stored as vec4)
  47327. * @param uniform defines the webGL uniform location where to store the value
  47328. * @param array defines the array of int32 to store
  47329. */
  47330. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47331. /**
  47332. * Set the value of an uniform to an array of float32
  47333. * @param uniform defines the webGL uniform location where to store the value
  47334. * @param array defines the array of float32 to store
  47335. */
  47336. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47337. /**
  47338. * Set the value of an uniform to an array of float32 (stored as vec2)
  47339. * @param uniform defines the webGL uniform location where to store the value
  47340. * @param array defines the array of float32 to store
  47341. */
  47342. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47343. /**
  47344. * Set the value of an uniform to an array of float32 (stored as vec3)
  47345. * @param uniform defines the webGL uniform location where to store the value
  47346. * @param array defines the array of float32 to store
  47347. */
  47348. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47349. /**
  47350. * Set the value of an uniform to an array of float32 (stored as vec4)
  47351. * @param uniform defines the webGL uniform location where to store the value
  47352. * @param array defines the array of float32 to store
  47353. */
  47354. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47355. /**
  47356. * Set the value of an uniform to an array of number
  47357. * @param uniform defines the webGL uniform location where to store the value
  47358. * @param array defines the array of number to store
  47359. */
  47360. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47361. /**
  47362. * Set the value of an uniform to an array of number (stored as vec2)
  47363. * @param uniform defines the webGL uniform location where to store the value
  47364. * @param array defines the array of number to store
  47365. */
  47366. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47367. /**
  47368. * Set the value of an uniform to an array of number (stored as vec3)
  47369. * @param uniform defines the webGL uniform location where to store the value
  47370. * @param array defines the array of number to store
  47371. */
  47372. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47373. /**
  47374. * Set the value of an uniform to an array of number (stored as vec4)
  47375. * @param uniform defines the webGL uniform location where to store the value
  47376. * @param array defines the array of number to store
  47377. */
  47378. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47379. /**
  47380. * Set the value of an uniform to an array of float32 (stored as matrices)
  47381. * @param uniform defines the webGL uniform location where to store the value
  47382. * @param matrices defines the array of float32 to store
  47383. */
  47384. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47385. /**
  47386. * Set the value of an uniform to a matrix (3x3)
  47387. * @param uniform defines the webGL uniform location where to store the value
  47388. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47389. */
  47390. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47391. /**
  47392. * Set the value of an uniform to a matrix (2x2)
  47393. * @param uniform defines the webGL uniform location where to store the value
  47394. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47395. */
  47396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47397. /**
  47398. * Set the value of an uniform to a number (float)
  47399. * @param uniform defines the webGL uniform location where to store the value
  47400. * @param value defines the float number to store
  47401. */
  47402. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47403. /**
  47404. * Set the value of an uniform to a vec2
  47405. * @param uniform defines the webGL uniform location where to store the value
  47406. * @param x defines the 1st component of the value
  47407. * @param y defines the 2nd component of the value
  47408. */
  47409. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47410. /**
  47411. * Set the value of an uniform to a vec3
  47412. * @param uniform defines the webGL uniform location where to store the value
  47413. * @param x defines the 1st component of the value
  47414. * @param y defines the 2nd component of the value
  47415. * @param z defines the 3rd component of the value
  47416. */
  47417. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47418. /**
  47419. * Set the value of an uniform to a boolean
  47420. * @param uniform defines the webGL uniform location where to store the value
  47421. * @param bool defines the boolean to store
  47422. */
  47423. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47424. /**
  47425. * Set the value of an uniform to a vec4
  47426. * @param uniform defines the webGL uniform location where to store the value
  47427. * @param x defines the 1st component of the value
  47428. * @param y defines the 2nd component of the value
  47429. * @param z defines the 3rd component of the value
  47430. * @param w defines the 4th component of the value
  47431. */
  47432. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47433. /**
  47434. * Sets the current alpha mode
  47435. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47436. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47438. */
  47439. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47440. /**
  47441. * Bind webGl buffers directly to the webGL context
  47442. * @param vertexBuffers defines the vertex buffer to bind
  47443. * @param indexBuffer defines the index buffer to bind
  47444. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47445. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47446. * @param effect defines the effect associated with the vertex buffer
  47447. */
  47448. bindBuffers(vertexBuffers: {
  47449. [key: string]: VertexBuffer;
  47450. }, indexBuffer: DataBuffer, effect: Effect): void;
  47451. /**
  47452. * Force the entire cache to be cleared
  47453. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47454. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47455. */
  47456. wipeCaches(bruteForce?: boolean): void;
  47457. /**
  47458. * Send a draw order
  47459. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47460. * @param indexStart defines the starting index
  47461. * @param indexCount defines the number of index to draw
  47462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47463. */
  47464. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47465. /**
  47466. * Draw a list of indexed primitives
  47467. * @param fillMode defines the primitive to use
  47468. * @param indexStart defines the starting index
  47469. * @param indexCount defines the number of index to draw
  47470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47471. */
  47472. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47473. /**
  47474. * Draw a list of unindexed primitives
  47475. * @param fillMode defines the primitive to use
  47476. * @param verticesStart defines the index of first vertex to draw
  47477. * @param verticesCount defines the count of vertices to draw
  47478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47479. */
  47480. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47481. /** @hidden */
  47482. _createTexture(): WebGLTexture;
  47483. /** @hidden */
  47484. _releaseTexture(texture: InternalTexture): void;
  47485. /**
  47486. * Usually called from Texture.ts.
  47487. * Passed information to create a WebGLTexture
  47488. * @param urlArg defines a value which contains one of the following:
  47489. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47490. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47491. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47493. * @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)
  47494. * @param scene needed for loading to the correct scene
  47495. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47496. * @param onLoad optional callback to be called upon successful completion
  47497. * @param onError optional callback to be called upon failure
  47498. * @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
  47499. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47500. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47501. * @param forcedExtension defines the extension to use to pick the right loader
  47502. * @param mimeType defines an optional mime type
  47503. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47504. */
  47505. 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;
  47506. /**
  47507. * Creates a new render target texture
  47508. * @param size defines the size of the texture
  47509. * @param options defines the options used to create the texture
  47510. * @returns a new render target texture stored in an InternalTexture
  47511. */
  47512. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47513. /**
  47514. * Update the sampling mode of a given texture
  47515. * @param samplingMode defines the required sampling mode
  47516. * @param texture defines the texture to update
  47517. */
  47518. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47519. /**
  47520. * Binds the frame buffer to the specified texture.
  47521. * @param texture The texture to render to or null for the default canvas
  47522. * @param faceIndex The face of the texture to render to in case of cube texture
  47523. * @param requiredWidth The width of the target to render to
  47524. * @param requiredHeight The height of the target to render to
  47525. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47526. * @param lodLevel defines le lod level to bind to the frame buffer
  47527. */
  47528. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47529. /**
  47530. * Unbind the current render target texture from the webGL context
  47531. * @param texture defines the render target texture to unbind
  47532. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47533. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47534. */
  47535. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47536. /**
  47537. * Creates a dynamic vertex buffer
  47538. * @param vertices the data for the dynamic vertex buffer
  47539. * @returns the new WebGL dynamic buffer
  47540. */
  47541. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47542. /**
  47543. * Update the content of a dynamic texture
  47544. * @param texture defines the texture to update
  47545. * @param canvas defines the canvas containing the source
  47546. * @param invertY defines if data must be stored with Y axis inverted
  47547. * @param premulAlpha defines if alpha is stored as premultiplied
  47548. * @param format defines the format of the data
  47549. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47550. */
  47551. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47552. /**
  47553. * Gets a boolean indicating if all created effects are ready
  47554. * @returns true if all effects are ready
  47555. */
  47556. areAllEffectsReady(): boolean;
  47557. /**
  47558. * @hidden
  47559. * Get the current error code of the webGL context
  47560. * @returns the error code
  47561. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47562. */
  47563. getError(): number;
  47564. /** @hidden */
  47565. _getUnpackAlignement(): number;
  47566. /** @hidden */
  47567. _unpackFlipY(value: boolean): void;
  47568. /**
  47569. * Update a dynamic index buffer
  47570. * @param indexBuffer defines the target index buffer
  47571. * @param indices defines the data to update
  47572. * @param offset defines the offset in the target index buffer where update should start
  47573. */
  47574. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47575. /**
  47576. * Updates a dynamic vertex buffer.
  47577. * @param vertexBuffer the vertex buffer to update
  47578. * @param vertices the data used to update the vertex buffer
  47579. * @param byteOffset the byte offset of the data (optional)
  47580. * @param byteLength the byte length of the data (optional)
  47581. */
  47582. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47583. /** @hidden */
  47584. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47585. /** @hidden */
  47586. _bindTexture(channel: number, texture: InternalTexture): void;
  47587. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47588. /**
  47589. * 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
  47590. */
  47591. releaseEffects(): void;
  47592. displayLoadingUI(): void;
  47593. hideLoadingUI(): void;
  47594. /** @hidden */
  47595. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47596. /** @hidden */
  47597. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47598. /** @hidden */
  47599. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47600. /** @hidden */
  47601. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. /**
  47606. * @hidden
  47607. **/
  47608. export class _TimeToken {
  47609. _startTimeQuery: Nullable<WebGLQuery>;
  47610. _endTimeQuery: Nullable<WebGLQuery>;
  47611. _timeElapsedQuery: Nullable<WebGLQuery>;
  47612. _timeElapsedQueryEnded: boolean;
  47613. }
  47614. }
  47615. declare module BABYLON {
  47616. /** @hidden */
  47617. export class _OcclusionDataStorage {
  47618. /** @hidden */
  47619. occlusionInternalRetryCounter: number;
  47620. /** @hidden */
  47621. isOcclusionQueryInProgress: boolean;
  47622. /** @hidden */
  47623. isOccluded: boolean;
  47624. /** @hidden */
  47625. occlusionRetryCount: number;
  47626. /** @hidden */
  47627. occlusionType: number;
  47628. /** @hidden */
  47629. occlusionQueryAlgorithmType: number;
  47630. }
  47631. interface Engine {
  47632. /**
  47633. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47634. * @return the new query
  47635. */
  47636. createQuery(): WebGLQuery;
  47637. /**
  47638. * Delete and release a webGL query
  47639. * @param query defines the query to delete
  47640. * @return the current engine
  47641. */
  47642. deleteQuery(query: WebGLQuery): Engine;
  47643. /**
  47644. * Check if a given query has resolved and got its value
  47645. * @param query defines the query to check
  47646. * @returns true if the query got its value
  47647. */
  47648. isQueryResultAvailable(query: WebGLQuery): boolean;
  47649. /**
  47650. * Gets the value of a given query
  47651. * @param query defines the query to check
  47652. * @returns the value of the query
  47653. */
  47654. getQueryResult(query: WebGLQuery): number;
  47655. /**
  47656. * Initiates an occlusion query
  47657. * @param algorithmType defines the algorithm to use
  47658. * @param query defines the query to use
  47659. * @returns the current engine
  47660. * @see http://doc.babylonjs.com/features/occlusionquery
  47661. */
  47662. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47663. /**
  47664. * Ends an occlusion query
  47665. * @see http://doc.babylonjs.com/features/occlusionquery
  47666. * @param algorithmType defines the algorithm to use
  47667. * @returns the current engine
  47668. */
  47669. endOcclusionQuery(algorithmType: number): Engine;
  47670. /**
  47671. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47672. * Please note that only one query can be issued at a time
  47673. * @returns a time token used to track the time span
  47674. */
  47675. startTimeQuery(): Nullable<_TimeToken>;
  47676. /**
  47677. * Ends a time query
  47678. * @param token defines the token used to measure the time span
  47679. * @returns the time spent (in ns)
  47680. */
  47681. endTimeQuery(token: _TimeToken): int;
  47682. /** @hidden */
  47683. _currentNonTimestampToken: Nullable<_TimeToken>;
  47684. /** @hidden */
  47685. _createTimeQuery(): WebGLQuery;
  47686. /** @hidden */
  47687. _deleteTimeQuery(query: WebGLQuery): void;
  47688. /** @hidden */
  47689. _getGlAlgorithmType(algorithmType: number): number;
  47690. /** @hidden */
  47691. _getTimeQueryResult(query: WebGLQuery): any;
  47692. /** @hidden */
  47693. _getTimeQueryAvailability(query: WebGLQuery): any;
  47694. }
  47695. interface AbstractMesh {
  47696. /**
  47697. * Backing filed
  47698. * @hidden
  47699. */
  47700. __occlusionDataStorage: _OcclusionDataStorage;
  47701. /**
  47702. * Access property
  47703. * @hidden
  47704. */
  47705. _occlusionDataStorage: _OcclusionDataStorage;
  47706. /**
  47707. * 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.
  47708. * The default value is -1 which means don't break the query and wait till the result
  47709. * @see http://doc.babylonjs.com/features/occlusionquery
  47710. */
  47711. occlusionRetryCount: number;
  47712. /**
  47713. * 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:
  47714. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47715. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47716. * * 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.
  47717. * @see http://doc.babylonjs.com/features/occlusionquery
  47718. */
  47719. occlusionType: number;
  47720. /**
  47721. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47722. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47723. * * 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.
  47724. * @see http://doc.babylonjs.com/features/occlusionquery
  47725. */
  47726. occlusionQueryAlgorithmType: number;
  47727. /**
  47728. * 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
  47729. * @see http://doc.babylonjs.com/features/occlusionquery
  47730. */
  47731. isOccluded: boolean;
  47732. /**
  47733. * Flag to check the progress status of the query
  47734. * @see http://doc.babylonjs.com/features/occlusionquery
  47735. */
  47736. isOcclusionQueryInProgress: boolean;
  47737. }
  47738. }
  47739. declare module BABYLON {
  47740. /** @hidden */
  47741. export var _forceTransformFeedbackToBundle: boolean;
  47742. interface Engine {
  47743. /**
  47744. * Creates a webGL transform feedback object
  47745. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47746. * @returns the webGL transform feedback object
  47747. */
  47748. createTransformFeedback(): WebGLTransformFeedback;
  47749. /**
  47750. * Delete a webGL transform feedback object
  47751. * @param value defines the webGL transform feedback object to delete
  47752. */
  47753. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47754. /**
  47755. * Bind a webGL transform feedback object to the webgl context
  47756. * @param value defines the webGL transform feedback object to bind
  47757. */
  47758. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47759. /**
  47760. * Begins a transform feedback operation
  47761. * @param usePoints defines if points or triangles must be used
  47762. */
  47763. beginTransformFeedback(usePoints: boolean): void;
  47764. /**
  47765. * Ends a transform feedback operation
  47766. */
  47767. endTransformFeedback(): void;
  47768. /**
  47769. * Specify the varyings to use with transform feedback
  47770. * @param program defines the associated webGL program
  47771. * @param value defines the list of strings representing the varying names
  47772. */
  47773. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47774. /**
  47775. * Bind a webGL buffer for a transform feedback operation
  47776. * @param value defines the webGL buffer to bind
  47777. */
  47778. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47779. }
  47780. }
  47781. declare module BABYLON {
  47782. /**
  47783. * Creation options of the multi render target texture.
  47784. */
  47785. export interface IMultiRenderTargetOptions {
  47786. /**
  47787. * Define if the texture needs to create mip maps after render.
  47788. */
  47789. generateMipMaps?: boolean;
  47790. /**
  47791. * Define the types of all the draw buffers we want to create
  47792. */
  47793. types?: number[];
  47794. /**
  47795. * Define the sampling modes of all the draw buffers we want to create
  47796. */
  47797. samplingModes?: number[];
  47798. /**
  47799. * Define if a depth buffer is required
  47800. */
  47801. generateDepthBuffer?: boolean;
  47802. /**
  47803. * Define if a stencil buffer is required
  47804. */
  47805. generateStencilBuffer?: boolean;
  47806. /**
  47807. * Define if a depth texture is required instead of a depth buffer
  47808. */
  47809. generateDepthTexture?: boolean;
  47810. /**
  47811. * Define the number of desired draw buffers
  47812. */
  47813. textureCount?: number;
  47814. /**
  47815. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47816. */
  47817. doNotChangeAspectRatio?: boolean;
  47818. /**
  47819. * Define the default type of the buffers we are creating
  47820. */
  47821. defaultType?: number;
  47822. }
  47823. /**
  47824. * A multi render target, like a render target provides the ability to render to a texture.
  47825. * Unlike the render target, it can render to several draw buffers in one draw.
  47826. * This is specially interesting in deferred rendering or for any effects requiring more than
  47827. * just one color from a single pass.
  47828. */
  47829. export class MultiRenderTarget extends RenderTargetTexture {
  47830. private _internalTextures;
  47831. private _textures;
  47832. private _multiRenderTargetOptions;
  47833. /**
  47834. * Get if draw buffers are currently supported by the used hardware and browser.
  47835. */
  47836. get isSupported(): boolean;
  47837. /**
  47838. * Get the list of textures generated by the multi render target.
  47839. */
  47840. get textures(): Texture[];
  47841. /**
  47842. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47843. */
  47844. get depthTexture(): Texture;
  47845. /**
  47846. * Set the wrapping mode on U of all the textures we are rendering to.
  47847. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47848. */
  47849. set wrapU(wrap: number);
  47850. /**
  47851. * Set the wrapping mode on V of all the textures we are rendering to.
  47852. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47853. */
  47854. set wrapV(wrap: number);
  47855. /**
  47856. * Instantiate a new multi render target texture.
  47857. * A multi render target, like a render target provides the ability to render to a texture.
  47858. * Unlike the render target, it can render to several draw buffers in one draw.
  47859. * This is specially interesting in deferred rendering or for any effects requiring more than
  47860. * just one color from a single pass.
  47861. * @param name Define the name of the texture
  47862. * @param size Define the size of the buffers to render to
  47863. * @param count Define the number of target we are rendering into
  47864. * @param scene Define the scene the texture belongs to
  47865. * @param options Define the options used to create the multi render target
  47866. */
  47867. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47868. /** @hidden */
  47869. _rebuild(): void;
  47870. private _createInternalTextures;
  47871. private _createTextures;
  47872. /**
  47873. * Define the number of samples used if MSAA is enabled.
  47874. */
  47875. get samples(): number;
  47876. set samples(value: number);
  47877. /**
  47878. * Resize all the textures in the multi render target.
  47879. * Be carrefull as it will recreate all the data in the new texture.
  47880. * @param size Define the new size
  47881. */
  47882. resize(size: any): void;
  47883. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47884. /**
  47885. * Dispose the render targets and their associated resources
  47886. */
  47887. dispose(): void;
  47888. /**
  47889. * Release all the underlying texture used as draw buffers.
  47890. */
  47891. releaseInternalTextures(): void;
  47892. }
  47893. }
  47894. declare module BABYLON {
  47895. interface ThinEngine {
  47896. /**
  47897. * Unbind a list of render target textures from the webGL context
  47898. * This is used only when drawBuffer extension or webGL2 are active
  47899. * @param textures defines the render target textures to unbind
  47900. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47901. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47902. */
  47903. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47904. /**
  47905. * Create a multi render target texture
  47906. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47907. * @param size defines the size of the texture
  47908. * @param options defines the creation options
  47909. * @returns the cube texture as an InternalTexture
  47910. */
  47911. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47912. /**
  47913. * Update the sample count for a given multiple render target texture
  47914. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47915. * @param textures defines the textures to update
  47916. * @param samples defines the sample count to set
  47917. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47918. */
  47919. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47920. }
  47921. }
  47922. declare module BABYLON {
  47923. /**
  47924. * Class used to define an additional view for the engine
  47925. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47926. */
  47927. export class EngineView {
  47928. /** Defines the canvas where to render the view */
  47929. target: HTMLCanvasElement;
  47930. /** Defines an optional camera used to render the view (will use active camera else) */
  47931. camera?: Camera;
  47932. }
  47933. interface Engine {
  47934. /**
  47935. * Gets or sets the HTML element to use for attaching events
  47936. */
  47937. inputElement: Nullable<HTMLElement>;
  47938. /**
  47939. * Gets the current engine view
  47940. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47941. */
  47942. activeView: Nullable<EngineView>;
  47943. /** Gets or sets the list of views */
  47944. views: EngineView[];
  47945. /**
  47946. * Register a new child canvas
  47947. * @param canvas defines the canvas to register
  47948. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47949. * @returns the associated view
  47950. */
  47951. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47952. /**
  47953. * Remove a registered child canvas
  47954. * @param canvas defines the canvas to remove
  47955. * @returns the current engine
  47956. */
  47957. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47958. }
  47959. }
  47960. declare module BABYLON {
  47961. interface Engine {
  47962. /** @hidden */
  47963. _excludedCompressedTextures: string[];
  47964. /** @hidden */
  47965. _textureFormatInUse: string;
  47966. /**
  47967. * Gets the list of texture formats supported
  47968. */
  47969. readonly texturesSupported: Array<string>;
  47970. /**
  47971. * Gets the texture format in use
  47972. */
  47973. readonly textureFormatInUse: Nullable<string>;
  47974. /**
  47975. * Set the compressed texture extensions or file names to skip.
  47976. *
  47977. * @param skippedFiles defines the list of those texture files you want to skip
  47978. * Example: [".dds", ".env", "myfile.png"]
  47979. */
  47980. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47981. /**
  47982. * Set the compressed texture format to use, based on the formats you have, and the formats
  47983. * supported by the hardware / browser.
  47984. *
  47985. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47986. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47987. * to API arguments needed to compressed textures. This puts the burden on the container
  47988. * generator to house the arcane code for determining these for current & future formats.
  47989. *
  47990. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47991. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47992. *
  47993. * Note: The result of this call is not taken into account when a texture is base64.
  47994. *
  47995. * @param formatsAvailable defines the list of those format families you have created
  47996. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47997. *
  47998. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47999. * @returns The extension selected.
  48000. */
  48001. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  48002. }
  48003. }
  48004. declare module BABYLON {
  48005. /**
  48006. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48007. */
  48008. export interface CubeMapInfo {
  48009. /**
  48010. * The pixel array for the front face.
  48011. * This is stored in format, left to right, up to down format.
  48012. */
  48013. front: Nullable<ArrayBufferView>;
  48014. /**
  48015. * The pixel array for the back face.
  48016. * This is stored in format, left to right, up to down format.
  48017. */
  48018. back: Nullable<ArrayBufferView>;
  48019. /**
  48020. * The pixel array for the left face.
  48021. * This is stored in format, left to right, up to down format.
  48022. */
  48023. left: Nullable<ArrayBufferView>;
  48024. /**
  48025. * The pixel array for the right face.
  48026. * This is stored in format, left to right, up to down format.
  48027. */
  48028. right: Nullable<ArrayBufferView>;
  48029. /**
  48030. * The pixel array for the up face.
  48031. * This is stored in format, left to right, up to down format.
  48032. */
  48033. up: Nullable<ArrayBufferView>;
  48034. /**
  48035. * The pixel array for the down face.
  48036. * This is stored in format, left to right, up to down format.
  48037. */
  48038. down: Nullable<ArrayBufferView>;
  48039. /**
  48040. * The size of the cubemap stored.
  48041. *
  48042. * Each faces will be size * size pixels.
  48043. */
  48044. size: number;
  48045. /**
  48046. * The format of the texture.
  48047. *
  48048. * RGBA, RGB.
  48049. */
  48050. format: number;
  48051. /**
  48052. * The type of the texture data.
  48053. *
  48054. * UNSIGNED_INT, FLOAT.
  48055. */
  48056. type: number;
  48057. /**
  48058. * Specifies whether the texture is in gamma space.
  48059. */
  48060. gammaSpace: boolean;
  48061. }
  48062. /**
  48063. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48064. */
  48065. export class PanoramaToCubeMapTools {
  48066. private static FACE_LEFT;
  48067. private static FACE_RIGHT;
  48068. private static FACE_FRONT;
  48069. private static FACE_BACK;
  48070. private static FACE_DOWN;
  48071. private static FACE_UP;
  48072. /**
  48073. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48074. *
  48075. * @param float32Array The source data.
  48076. * @param inputWidth The width of the input panorama.
  48077. * @param inputHeight The height of the input panorama.
  48078. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48079. * @return The cubemap data
  48080. */
  48081. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48082. private static CreateCubemapTexture;
  48083. private static CalcProjectionSpherical;
  48084. }
  48085. }
  48086. declare module BABYLON {
  48087. /**
  48088. * Helper class dealing with the extraction of spherical polynomial dataArray
  48089. * from a cube map.
  48090. */
  48091. export class CubeMapToSphericalPolynomialTools {
  48092. private static FileFaces;
  48093. /**
  48094. * Converts a texture to the according Spherical Polynomial data.
  48095. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48096. *
  48097. * @param texture The texture to extract the information from.
  48098. * @return The Spherical Polynomial data.
  48099. */
  48100. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48101. /**
  48102. * Converts a cubemap to the according Spherical Polynomial data.
  48103. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48104. *
  48105. * @param cubeInfo The Cube map to extract the information from.
  48106. * @return The Spherical Polynomial data.
  48107. */
  48108. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48109. }
  48110. }
  48111. declare module BABYLON {
  48112. interface BaseTexture {
  48113. /**
  48114. * Get the polynomial representation of the texture data.
  48115. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48116. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48117. */
  48118. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48119. }
  48120. }
  48121. declare module BABYLON {
  48122. /** @hidden */
  48123. export var rgbdEncodePixelShader: {
  48124. name: string;
  48125. shader: string;
  48126. };
  48127. }
  48128. declare module BABYLON {
  48129. /** @hidden */
  48130. export var rgbdDecodePixelShader: {
  48131. name: string;
  48132. shader: string;
  48133. };
  48134. }
  48135. declare module BABYLON {
  48136. /**
  48137. * Raw texture data and descriptor sufficient for WebGL texture upload
  48138. */
  48139. export interface EnvironmentTextureInfo {
  48140. /**
  48141. * Version of the environment map
  48142. */
  48143. version: number;
  48144. /**
  48145. * Width of image
  48146. */
  48147. width: number;
  48148. /**
  48149. * Irradiance information stored in the file.
  48150. */
  48151. irradiance: any;
  48152. /**
  48153. * Specular information stored in the file.
  48154. */
  48155. specular: any;
  48156. }
  48157. /**
  48158. * Defines One Image in the file. It requires only the position in the file
  48159. * as well as the length.
  48160. */
  48161. interface BufferImageData {
  48162. /**
  48163. * Length of the image data.
  48164. */
  48165. length: number;
  48166. /**
  48167. * Position of the data from the null terminator delimiting the end of the JSON.
  48168. */
  48169. position: number;
  48170. }
  48171. /**
  48172. * Defines the specular data enclosed in the file.
  48173. * This corresponds to the version 1 of the data.
  48174. */
  48175. export interface EnvironmentTextureSpecularInfoV1 {
  48176. /**
  48177. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48178. */
  48179. specularDataPosition?: number;
  48180. /**
  48181. * This contains all the images data needed to reconstruct the cubemap.
  48182. */
  48183. mipmaps: Array<BufferImageData>;
  48184. /**
  48185. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48186. */
  48187. lodGenerationScale: number;
  48188. }
  48189. /**
  48190. * Sets of helpers addressing the serialization and deserialization of environment texture
  48191. * stored in a BabylonJS env file.
  48192. * Those files are usually stored as .env files.
  48193. */
  48194. export class EnvironmentTextureTools {
  48195. /**
  48196. * Magic number identifying the env file.
  48197. */
  48198. private static _MagicBytes;
  48199. /**
  48200. * Gets the environment info from an env file.
  48201. * @param data The array buffer containing the .env bytes.
  48202. * @returns the environment file info (the json header) if successfully parsed.
  48203. */
  48204. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48205. /**
  48206. * Creates an environment texture from a loaded cube texture.
  48207. * @param texture defines the cube texture to convert in env file
  48208. * @return a promise containing the environment data if succesfull.
  48209. */
  48210. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  48211. /**
  48212. * Creates a JSON representation of the spherical data.
  48213. * @param texture defines the texture containing the polynomials
  48214. * @return the JSON representation of the spherical info
  48215. */
  48216. private static _CreateEnvTextureIrradiance;
  48217. /**
  48218. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48219. * @param data the image data
  48220. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48221. * @return the views described by info providing access to the underlying buffer
  48222. */
  48223. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48224. /**
  48225. * Uploads the texture info contained in the env file to the GPU.
  48226. * @param texture defines the internal texture to upload to
  48227. * @param data defines the data to load
  48228. * @param info defines the texture info retrieved through the GetEnvInfo method
  48229. * @returns a promise
  48230. */
  48231. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48232. private static _OnImageReadyAsync;
  48233. /**
  48234. * Uploads the levels of image data to the GPU.
  48235. * @param texture defines the internal texture to upload to
  48236. * @param imageData defines the array buffer views of image data [mipmap][face]
  48237. * @returns a promise
  48238. */
  48239. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48240. /**
  48241. * Uploads spherical polynomials information to the texture.
  48242. * @param texture defines the texture we are trying to upload the information to
  48243. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48244. */
  48245. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48246. /** @hidden */
  48247. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * Contains position and normal vectors for a vertex
  48253. */
  48254. export class PositionNormalVertex {
  48255. /** the position of the vertex (defaut: 0,0,0) */
  48256. position: Vector3;
  48257. /** the normal of the vertex (defaut: 0,1,0) */
  48258. normal: Vector3;
  48259. /**
  48260. * Creates a PositionNormalVertex
  48261. * @param position the position of the vertex (defaut: 0,0,0)
  48262. * @param normal the normal of the vertex (defaut: 0,1,0)
  48263. */
  48264. constructor(
  48265. /** the position of the vertex (defaut: 0,0,0) */
  48266. position?: Vector3,
  48267. /** the normal of the vertex (defaut: 0,1,0) */
  48268. normal?: Vector3);
  48269. /**
  48270. * Clones the PositionNormalVertex
  48271. * @returns the cloned PositionNormalVertex
  48272. */
  48273. clone(): PositionNormalVertex;
  48274. }
  48275. /**
  48276. * Contains position, normal and uv vectors for a vertex
  48277. */
  48278. export class PositionNormalTextureVertex {
  48279. /** the position of the vertex (defaut: 0,0,0) */
  48280. position: Vector3;
  48281. /** the normal of the vertex (defaut: 0,1,0) */
  48282. normal: Vector3;
  48283. /** the uv of the vertex (default: 0,0) */
  48284. uv: Vector2;
  48285. /**
  48286. * Creates a PositionNormalTextureVertex
  48287. * @param position the position of the vertex (defaut: 0,0,0)
  48288. * @param normal the normal of the vertex (defaut: 0,1,0)
  48289. * @param uv the uv of the vertex (default: 0,0)
  48290. */
  48291. constructor(
  48292. /** the position of the vertex (defaut: 0,0,0) */
  48293. position?: Vector3,
  48294. /** the normal of the vertex (defaut: 0,1,0) */
  48295. normal?: Vector3,
  48296. /** the uv of the vertex (default: 0,0) */
  48297. uv?: Vector2);
  48298. /**
  48299. * Clones the PositionNormalTextureVertex
  48300. * @returns the cloned PositionNormalTextureVertex
  48301. */
  48302. clone(): PositionNormalTextureVertex;
  48303. }
  48304. }
  48305. declare module BABYLON {
  48306. /** @hidden */
  48307. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48308. private _genericAttributeLocation;
  48309. private _varyingLocationCount;
  48310. private _varyingLocationMap;
  48311. private _replacements;
  48312. private _textureCount;
  48313. private _uniforms;
  48314. lineProcessor(line: string): string;
  48315. attributeProcessor(attribute: string): string;
  48316. varyingProcessor(varying: string, isFragment: boolean): string;
  48317. uniformProcessor(uniform: string): string;
  48318. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48319. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48320. }
  48321. }
  48322. declare module BABYLON {
  48323. /**
  48324. * Container for accessors for natively-stored mesh data buffers.
  48325. */
  48326. class NativeDataBuffer extends DataBuffer {
  48327. /**
  48328. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48329. */
  48330. nativeIndexBuffer?: any;
  48331. /**
  48332. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48333. */
  48334. nativeVertexBuffer?: any;
  48335. }
  48336. /** @hidden */
  48337. class NativeTexture extends InternalTexture {
  48338. getInternalTexture(): InternalTexture;
  48339. getViewCount(): number;
  48340. }
  48341. /** @hidden */
  48342. export class NativeEngine extends Engine {
  48343. private readonly _native;
  48344. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48345. private readonly INVALID_HANDLE;
  48346. getHardwareScalingLevel(): number;
  48347. constructor();
  48348. dispose(): void;
  48349. /**
  48350. * Can be used to override the current requestAnimationFrame requester.
  48351. * @hidden
  48352. */
  48353. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48354. /**
  48355. * Override default engine behavior.
  48356. * @param color
  48357. * @param backBuffer
  48358. * @param depth
  48359. * @param stencil
  48360. */
  48361. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48362. /**
  48363. * Gets host document
  48364. * @returns the host document object
  48365. */
  48366. getHostDocument(): Nullable<Document>;
  48367. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48368. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48369. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48370. recordVertexArrayObject(vertexBuffers: {
  48371. [key: string]: VertexBuffer;
  48372. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48373. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48374. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48375. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48376. /**
  48377. * Draw a list of indexed primitives
  48378. * @param fillMode defines the primitive to use
  48379. * @param indexStart defines the starting index
  48380. * @param indexCount defines the number of index to draw
  48381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48382. */
  48383. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48384. /**
  48385. * Draw a list of unindexed primitives
  48386. * @param fillMode defines the primitive to use
  48387. * @param verticesStart defines the index of first vertex to draw
  48388. * @param verticesCount defines the count of vertices to draw
  48389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48390. */
  48391. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48392. createPipelineContext(): IPipelineContext;
  48393. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48394. /** @hidden */
  48395. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48396. /** @hidden */
  48397. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48398. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48399. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48400. protected _setProgram(program: WebGLProgram): void;
  48401. _releaseEffect(effect: Effect): void;
  48402. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48403. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48404. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48405. bindSamplers(effect: Effect): void;
  48406. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48407. getRenderWidth(useScreen?: boolean): number;
  48408. getRenderHeight(useScreen?: boolean): number;
  48409. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48410. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48411. /**
  48412. * Set the z offset to apply to current rendering
  48413. * @param value defines the offset to apply
  48414. */
  48415. setZOffset(value: number): void;
  48416. /**
  48417. * Gets the current value of the zOffset
  48418. * @returns the current zOffset state
  48419. */
  48420. getZOffset(): number;
  48421. /**
  48422. * Enable or disable depth buffering
  48423. * @param enable defines the state to set
  48424. */
  48425. setDepthBuffer(enable: boolean): void;
  48426. /**
  48427. * Gets a boolean indicating if depth writing is enabled
  48428. * @returns the current depth writing state
  48429. */
  48430. getDepthWrite(): boolean;
  48431. /**
  48432. * Enable or disable depth writing
  48433. * @param enable defines the state to set
  48434. */
  48435. setDepthWrite(enable: boolean): void;
  48436. /**
  48437. * Enable or disable color writing
  48438. * @param enable defines the state to set
  48439. */
  48440. setColorWrite(enable: boolean): void;
  48441. /**
  48442. * Gets a boolean indicating if color writing is enabled
  48443. * @returns the current color writing state
  48444. */
  48445. getColorWrite(): boolean;
  48446. /**
  48447. * Sets alpha constants used by some alpha blending modes
  48448. * @param r defines the red component
  48449. * @param g defines the green component
  48450. * @param b defines the blue component
  48451. * @param a defines the alpha component
  48452. */
  48453. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48454. /**
  48455. * Sets the current alpha mode
  48456. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48457. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48458. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48459. */
  48460. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48461. /**
  48462. * Gets the current alpha mode
  48463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48464. * @returns the current alpha mode
  48465. */
  48466. getAlphaMode(): number;
  48467. setInt(uniform: WebGLUniformLocation, int: number): void;
  48468. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48469. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48470. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48471. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48472. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48473. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48474. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48475. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48476. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48477. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48478. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48479. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48480. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48481. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48482. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48483. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48484. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48485. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48486. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48487. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48488. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48489. wipeCaches(bruteForce?: boolean): void;
  48490. _createTexture(): WebGLTexture;
  48491. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48492. /**
  48493. * Usually called from Texture.ts.
  48494. * Passed information to create a WebGLTexture
  48495. * @param url defines a value which contains one of the following:
  48496. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48497. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48498. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48500. * @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)
  48501. * @param scene needed for loading to the correct scene
  48502. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48503. * @param onLoad optional callback to be called upon successful completion
  48504. * @param onError optional callback to be called upon failure
  48505. * @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
  48506. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48507. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48508. * @param forcedExtension defines the extension to use to pick the right loader
  48509. * @param mimeType defines an optional mime type
  48510. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48511. */
  48512. 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;
  48513. /**
  48514. * Creates a cube texture
  48515. * @param rootUrl defines the url where the files to load is located
  48516. * @param scene defines the current scene
  48517. * @param files defines the list of files to load (1 per face)
  48518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48519. * @param onLoad defines an optional callback raised when the texture is loaded
  48520. * @param onError defines an optional callback raised if there is an issue to load the texture
  48521. * @param format defines the format of the data
  48522. * @param forcedExtension defines the extension to use to pick the right loader
  48523. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48526. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48527. * @returns the cube texture as an InternalTexture
  48528. */
  48529. 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;
  48530. private _getSamplingFilter;
  48531. private static _GetNativeTextureFormat;
  48532. createRenderTargetTexture(size: number | {
  48533. width: number;
  48534. height: number;
  48535. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48536. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48537. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48538. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48539. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48540. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48541. /**
  48542. * Updates a dynamic vertex buffer.
  48543. * @param vertexBuffer the vertex buffer to update
  48544. * @param data the data used to update the vertex buffer
  48545. * @param byteOffset the byte offset of the data (optional)
  48546. * @param byteLength the byte length of the data (optional)
  48547. */
  48548. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48549. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48550. private _updateAnisotropicLevel;
  48551. private _getAddressMode;
  48552. /** @hidden */
  48553. _bindTexture(channel: number, texture: InternalTexture): void;
  48554. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48555. releaseEffects(): void;
  48556. /** @hidden */
  48557. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48558. /** @hidden */
  48559. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48560. /** @hidden */
  48561. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48562. /** @hidden */
  48563. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48564. }
  48565. }
  48566. declare module BABYLON {
  48567. /**
  48568. * Gather the list of clipboard event types as constants.
  48569. */
  48570. export class ClipboardEventTypes {
  48571. /**
  48572. * The clipboard event is fired when a copy command is active (pressed).
  48573. */
  48574. static readonly COPY: number;
  48575. /**
  48576. * The clipboard event is fired when a cut command is active (pressed).
  48577. */
  48578. static readonly CUT: number;
  48579. /**
  48580. * The clipboard event is fired when a paste command is active (pressed).
  48581. */
  48582. static readonly PASTE: number;
  48583. }
  48584. /**
  48585. * This class is used to store clipboard related info for the onClipboardObservable event.
  48586. */
  48587. export class ClipboardInfo {
  48588. /**
  48589. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48590. */
  48591. type: number;
  48592. /**
  48593. * Defines the related dom event
  48594. */
  48595. event: ClipboardEvent;
  48596. /**
  48597. *Creates an instance of ClipboardInfo.
  48598. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48599. * @param event Defines the related dom event
  48600. */
  48601. constructor(
  48602. /**
  48603. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48604. */
  48605. type: number,
  48606. /**
  48607. * Defines the related dom event
  48608. */
  48609. event: ClipboardEvent);
  48610. /**
  48611. * Get the clipboard event's type from the keycode.
  48612. * @param keyCode Defines the keyCode for the current keyboard event.
  48613. * @return {number}
  48614. */
  48615. static GetTypeFromCharacter(keyCode: number): number;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. /**
  48620. * Google Daydream controller
  48621. */
  48622. export class DaydreamController extends WebVRController {
  48623. /**
  48624. * Base Url for the controller model.
  48625. */
  48626. static MODEL_BASE_URL: string;
  48627. /**
  48628. * File name for the controller model.
  48629. */
  48630. static MODEL_FILENAME: string;
  48631. /**
  48632. * Gamepad Id prefix used to identify Daydream Controller.
  48633. */
  48634. static readonly GAMEPAD_ID_PREFIX: string;
  48635. /**
  48636. * Creates a new DaydreamController from a gamepad
  48637. * @param vrGamepad the gamepad that the controller should be created from
  48638. */
  48639. constructor(vrGamepad: any);
  48640. /**
  48641. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48642. * @param scene scene in which to add meshes
  48643. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48644. */
  48645. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48646. /**
  48647. * Called once for each button that changed state since the last frame
  48648. * @param buttonIdx Which button index changed
  48649. * @param state New state of the button
  48650. * @param changes Which properties on the state changed since last frame
  48651. */
  48652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48653. }
  48654. }
  48655. declare module BABYLON {
  48656. /**
  48657. * Gear VR Controller
  48658. */
  48659. export class GearVRController extends WebVRController {
  48660. /**
  48661. * Base Url for the controller model.
  48662. */
  48663. static MODEL_BASE_URL: string;
  48664. /**
  48665. * File name for the controller model.
  48666. */
  48667. static MODEL_FILENAME: string;
  48668. /**
  48669. * Gamepad Id prefix used to identify this controller.
  48670. */
  48671. static readonly GAMEPAD_ID_PREFIX: string;
  48672. private readonly _buttonIndexToObservableNameMap;
  48673. /**
  48674. * Creates a new GearVRController from a gamepad
  48675. * @param vrGamepad the gamepad that the controller should be created from
  48676. */
  48677. constructor(vrGamepad: any);
  48678. /**
  48679. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48680. * @param scene scene in which to add meshes
  48681. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48682. */
  48683. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48684. /**
  48685. * Called once for each button that changed state since the last frame
  48686. * @param buttonIdx Which button index changed
  48687. * @param state New state of the button
  48688. * @param changes Which properties on the state changed since last frame
  48689. */
  48690. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48691. }
  48692. }
  48693. declare module BABYLON {
  48694. /**
  48695. * Generic Controller
  48696. */
  48697. export class GenericController extends WebVRController {
  48698. /**
  48699. * Base Url for the controller model.
  48700. */
  48701. static readonly MODEL_BASE_URL: string;
  48702. /**
  48703. * File name for the controller model.
  48704. */
  48705. static readonly MODEL_FILENAME: string;
  48706. /**
  48707. * Creates a new GenericController from a gamepad
  48708. * @param vrGamepad the gamepad that the controller should be created from
  48709. */
  48710. constructor(vrGamepad: any);
  48711. /**
  48712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48713. * @param scene scene in which to add meshes
  48714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48715. */
  48716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48717. /**
  48718. * Called once for each button that changed state since the last frame
  48719. * @param buttonIdx Which button index changed
  48720. * @param state New state of the button
  48721. * @param changes Which properties on the state changed since last frame
  48722. */
  48723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48724. }
  48725. }
  48726. declare module BABYLON {
  48727. /**
  48728. * Oculus Touch Controller
  48729. */
  48730. export class OculusTouchController extends WebVRController {
  48731. /**
  48732. * Base Url for the controller model.
  48733. */
  48734. static MODEL_BASE_URL: string;
  48735. /**
  48736. * File name for the left controller model.
  48737. */
  48738. static MODEL_LEFT_FILENAME: string;
  48739. /**
  48740. * File name for the right controller model.
  48741. */
  48742. static MODEL_RIGHT_FILENAME: string;
  48743. /**
  48744. * Base Url for the Quest controller model.
  48745. */
  48746. static QUEST_MODEL_BASE_URL: string;
  48747. /**
  48748. * @hidden
  48749. * If the controllers are running on a device that needs the updated Quest controller models
  48750. */
  48751. static _IsQuest: boolean;
  48752. /**
  48753. * Fired when the secondary trigger on this controller is modified
  48754. */
  48755. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48756. /**
  48757. * Fired when the thumb rest on this controller is modified
  48758. */
  48759. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48760. /**
  48761. * Creates a new OculusTouchController from a gamepad
  48762. * @param vrGamepad the gamepad that the controller should be created from
  48763. */
  48764. constructor(vrGamepad: any);
  48765. /**
  48766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48767. * @param scene scene in which to add meshes
  48768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48769. */
  48770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48771. /**
  48772. * Fired when the A button on this controller is modified
  48773. */
  48774. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48775. /**
  48776. * Fired when the B button on this controller is modified
  48777. */
  48778. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48779. /**
  48780. * Fired when the X button on this controller is modified
  48781. */
  48782. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48783. /**
  48784. * Fired when the Y button on this controller is modified
  48785. */
  48786. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48787. /**
  48788. * Called once for each button that changed state since the last frame
  48789. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48790. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48791. * 2) secondary trigger (same)
  48792. * 3) A (right) X (left), touch, pressed = value
  48793. * 4) B / Y
  48794. * 5) thumb rest
  48795. * @param buttonIdx Which button index changed
  48796. * @param state New state of the button
  48797. * @param changes Which properties on the state changed since last frame
  48798. */
  48799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48800. }
  48801. }
  48802. declare module BABYLON {
  48803. /**
  48804. * Vive Controller
  48805. */
  48806. export class ViveController extends WebVRController {
  48807. /**
  48808. * Base Url for the controller model.
  48809. */
  48810. static MODEL_BASE_URL: string;
  48811. /**
  48812. * File name for the controller model.
  48813. */
  48814. static MODEL_FILENAME: string;
  48815. /**
  48816. * Creates a new ViveController from a gamepad
  48817. * @param vrGamepad the gamepad that the controller should be created from
  48818. */
  48819. constructor(vrGamepad: any);
  48820. /**
  48821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48822. * @param scene scene in which to add meshes
  48823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48824. */
  48825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48826. /**
  48827. * Fired when the left button on this controller is modified
  48828. */
  48829. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48830. /**
  48831. * Fired when the right button on this controller is modified
  48832. */
  48833. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48834. /**
  48835. * Fired when the menu button on this controller is modified
  48836. */
  48837. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48838. /**
  48839. * Called once for each button that changed state since the last frame
  48840. * Vive mapping:
  48841. * 0: touchpad
  48842. * 1: trigger
  48843. * 2: left AND right buttons
  48844. * 3: menu button
  48845. * @param buttonIdx Which button index changed
  48846. * @param state New state of the button
  48847. * @param changes Which properties on the state changed since last frame
  48848. */
  48849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48850. }
  48851. }
  48852. declare module BABYLON {
  48853. /**
  48854. * Defines the WindowsMotionController object that the state of the windows motion controller
  48855. */
  48856. export class WindowsMotionController extends WebVRController {
  48857. /**
  48858. * The base url used to load the left and right controller models
  48859. */
  48860. static MODEL_BASE_URL: string;
  48861. /**
  48862. * The name of the left controller model file
  48863. */
  48864. static MODEL_LEFT_FILENAME: string;
  48865. /**
  48866. * The name of the right controller model file
  48867. */
  48868. static MODEL_RIGHT_FILENAME: string;
  48869. /**
  48870. * The controller name prefix for this controller type
  48871. */
  48872. static readonly GAMEPAD_ID_PREFIX: string;
  48873. /**
  48874. * The controller id pattern for this controller type
  48875. */
  48876. private static readonly GAMEPAD_ID_PATTERN;
  48877. private _loadedMeshInfo;
  48878. protected readonly _mapping: {
  48879. buttons: string[];
  48880. buttonMeshNames: {
  48881. trigger: string;
  48882. menu: string;
  48883. grip: string;
  48884. thumbstick: string;
  48885. trackpad: string;
  48886. };
  48887. buttonObservableNames: {
  48888. trigger: string;
  48889. menu: string;
  48890. grip: string;
  48891. thumbstick: string;
  48892. trackpad: string;
  48893. };
  48894. axisMeshNames: string[];
  48895. pointingPoseMeshName: string;
  48896. };
  48897. /**
  48898. * Fired when the trackpad on this controller is clicked
  48899. */
  48900. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48901. /**
  48902. * Fired when the trackpad on this controller is modified
  48903. */
  48904. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48905. /**
  48906. * The current x and y values of this controller's trackpad
  48907. */
  48908. trackpad: StickValues;
  48909. /**
  48910. * Creates a new WindowsMotionController from a gamepad
  48911. * @param vrGamepad the gamepad that the controller should be created from
  48912. */
  48913. constructor(vrGamepad: any);
  48914. /**
  48915. * Fired when the trigger on this controller is modified
  48916. */
  48917. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48918. /**
  48919. * Fired when the menu button on this controller is modified
  48920. */
  48921. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48922. /**
  48923. * Fired when the grip button on this controller is modified
  48924. */
  48925. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48926. /**
  48927. * Fired when the thumbstick button on this controller is modified
  48928. */
  48929. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48930. /**
  48931. * Fired when the touchpad button on this controller is modified
  48932. */
  48933. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48934. /**
  48935. * Fired when the touchpad values on this controller are modified
  48936. */
  48937. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48938. protected _updateTrackpad(): void;
  48939. /**
  48940. * Called once per frame by the engine.
  48941. */
  48942. update(): void;
  48943. /**
  48944. * Called once for each button that changed state since the last frame
  48945. * @param buttonIdx Which button index changed
  48946. * @param state New state of the button
  48947. * @param changes Which properties on the state changed since last frame
  48948. */
  48949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48950. /**
  48951. * Moves the buttons on the controller mesh based on their current state
  48952. * @param buttonName the name of the button to move
  48953. * @param buttonValue the value of the button which determines the buttons new position
  48954. */
  48955. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48956. /**
  48957. * Moves the axis on the controller mesh based on its current state
  48958. * @param axis the index of the axis
  48959. * @param axisValue the value of the axis which determines the meshes new position
  48960. * @hidden
  48961. */
  48962. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48963. /**
  48964. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48965. * @param scene scene in which to add meshes
  48966. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48967. */
  48968. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48969. /**
  48970. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48971. * can be transformed by button presses and axes values, based on this._mapping.
  48972. *
  48973. * @param scene scene in which the meshes exist
  48974. * @param meshes list of meshes that make up the controller model to process
  48975. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48976. */
  48977. private processModel;
  48978. private createMeshInfo;
  48979. /**
  48980. * Gets the ray of the controller in the direction the controller is pointing
  48981. * @param length the length the resulting ray should be
  48982. * @returns a ray in the direction the controller is pointing
  48983. */
  48984. getForwardRay(length?: number): Ray;
  48985. /**
  48986. * Disposes of the controller
  48987. */
  48988. dispose(): void;
  48989. }
  48990. /**
  48991. * This class represents a new windows motion controller in XR.
  48992. */
  48993. export class XRWindowsMotionController extends WindowsMotionController {
  48994. /**
  48995. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48996. */
  48997. protected readonly _mapping: {
  48998. buttons: string[];
  48999. buttonMeshNames: {
  49000. trigger: string;
  49001. menu: string;
  49002. grip: string;
  49003. thumbstick: string;
  49004. trackpad: string;
  49005. };
  49006. buttonObservableNames: {
  49007. trigger: string;
  49008. menu: string;
  49009. grip: string;
  49010. thumbstick: string;
  49011. trackpad: string;
  49012. };
  49013. axisMeshNames: string[];
  49014. pointingPoseMeshName: string;
  49015. };
  49016. /**
  49017. * Construct a new XR-Based windows motion controller
  49018. *
  49019. * @param gamepadInfo the gamepad object from the browser
  49020. */
  49021. constructor(gamepadInfo: any);
  49022. /**
  49023. * holds the thumbstick values (X,Y)
  49024. */
  49025. thumbstickValues: StickValues;
  49026. /**
  49027. * Fired when the thumbstick on this controller is clicked
  49028. */
  49029. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49030. /**
  49031. * Fired when the thumbstick on this controller is modified
  49032. */
  49033. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49034. /**
  49035. * Fired when the touchpad button on this controller is modified
  49036. */
  49037. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49038. /**
  49039. * Fired when the touchpad values on this controller are modified
  49040. */
  49041. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49042. /**
  49043. * Fired when the thumbstick button on this controller is modified
  49044. * here to prevent breaking changes
  49045. */
  49046. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49047. /**
  49048. * updating the thumbstick(!) and not the trackpad.
  49049. * This is named this way due to the difference between WebVR and XR and to avoid
  49050. * changing the parent class.
  49051. */
  49052. protected _updateTrackpad(): void;
  49053. /**
  49054. * Disposes the class with joy
  49055. */
  49056. dispose(): void;
  49057. }
  49058. }
  49059. declare module BABYLON {
  49060. /**
  49061. * Class containing static functions to help procedurally build meshes
  49062. */
  49063. export class PolyhedronBuilder {
  49064. /**
  49065. * Creates a polyhedron mesh
  49066. * * 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
  49067. * * The parameter `size` (positive float, default 1) sets the polygon size
  49068. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49069. * * 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`
  49070. * * 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
  49071. * * 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)`)
  49072. * * 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
  49073. * * 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
  49074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49075. * * 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
  49076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49077. * @param name defines the name of the mesh
  49078. * @param options defines the options used to create the mesh
  49079. * @param scene defines the hosting scene
  49080. * @returns the polyhedron mesh
  49081. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49082. */
  49083. static CreatePolyhedron(name: string, options: {
  49084. type?: number;
  49085. size?: number;
  49086. sizeX?: number;
  49087. sizeY?: number;
  49088. sizeZ?: number;
  49089. custom?: any;
  49090. faceUV?: Vector4[];
  49091. faceColors?: Color4[];
  49092. flat?: boolean;
  49093. updatable?: boolean;
  49094. sideOrientation?: number;
  49095. frontUVs?: Vector4;
  49096. backUVs?: Vector4;
  49097. }, scene?: Nullable<Scene>): Mesh;
  49098. }
  49099. }
  49100. declare module BABYLON {
  49101. /**
  49102. * Gizmo that enables scaling a mesh along 3 axis
  49103. */
  49104. export class ScaleGizmo extends Gizmo {
  49105. /**
  49106. * Internal gizmo used for interactions on the x axis
  49107. */
  49108. xGizmo: AxisScaleGizmo;
  49109. /**
  49110. * Internal gizmo used for interactions on the y axis
  49111. */
  49112. yGizmo: AxisScaleGizmo;
  49113. /**
  49114. * Internal gizmo used for interactions on the z axis
  49115. */
  49116. zGizmo: AxisScaleGizmo;
  49117. /**
  49118. * Internal gizmo used to scale all axis equally
  49119. */
  49120. uniformScaleGizmo: AxisScaleGizmo;
  49121. private _meshAttached;
  49122. private _updateGizmoRotationToMatchAttachedMesh;
  49123. private _snapDistance;
  49124. private _scaleRatio;
  49125. private _uniformScalingMesh;
  49126. private _octahedron;
  49127. private _sensitivity;
  49128. /** Fires an event when any of it's sub gizmos are dragged */
  49129. onDragStartObservable: Observable<unknown>;
  49130. /** Fires an event when any of it's sub gizmos are released from dragging */
  49131. onDragEndObservable: Observable<unknown>;
  49132. get attachedMesh(): Nullable<AbstractMesh>;
  49133. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49134. /**
  49135. * Creates a ScaleGizmo
  49136. * @param gizmoLayer The utility layer the gizmo will be added to
  49137. */
  49138. constructor(gizmoLayer?: UtilityLayerRenderer);
  49139. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49140. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49141. /**
  49142. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49143. */
  49144. set snapDistance(value: number);
  49145. get snapDistance(): number;
  49146. /**
  49147. * Ratio for the scale of the gizmo (Default: 1)
  49148. */
  49149. set scaleRatio(value: number);
  49150. get scaleRatio(): number;
  49151. /**
  49152. * Sensitivity factor for dragging (Default: 1)
  49153. */
  49154. set sensitivity(value: number);
  49155. get sensitivity(): number;
  49156. /**
  49157. * Disposes of the gizmo
  49158. */
  49159. dispose(): void;
  49160. }
  49161. }
  49162. declare module BABYLON {
  49163. /**
  49164. * Single axis scale gizmo
  49165. */
  49166. export class AxisScaleGizmo extends Gizmo {
  49167. /**
  49168. * Drag behavior responsible for the gizmos dragging interactions
  49169. */
  49170. dragBehavior: PointerDragBehavior;
  49171. private _pointerObserver;
  49172. /**
  49173. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49174. */
  49175. snapDistance: number;
  49176. /**
  49177. * Event that fires each time the gizmo snaps to a new location.
  49178. * * snapDistance is the the change in distance
  49179. */
  49180. onSnapObservable: Observable<{
  49181. snapDistance: number;
  49182. }>;
  49183. /**
  49184. * If the scaling operation should be done on all axis (default: false)
  49185. */
  49186. uniformScaling: boolean;
  49187. /**
  49188. * Custom sensitivity value for the drag strength
  49189. */
  49190. sensitivity: number;
  49191. private _isEnabled;
  49192. private _parent;
  49193. private _arrow;
  49194. private _coloredMaterial;
  49195. private _hoverMaterial;
  49196. /**
  49197. * Creates an AxisScaleGizmo
  49198. * @param gizmoLayer The utility layer the gizmo will be added to
  49199. * @param dragAxis The axis which the gizmo will be able to scale on
  49200. * @param color The color of the gizmo
  49201. */
  49202. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49203. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49204. /**
  49205. * If the gizmo is enabled
  49206. */
  49207. set isEnabled(value: boolean);
  49208. get isEnabled(): boolean;
  49209. /**
  49210. * Disposes of the gizmo
  49211. */
  49212. dispose(): void;
  49213. /**
  49214. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49215. * @param mesh The mesh to replace the default mesh of the gizmo
  49216. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49217. */
  49218. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49219. }
  49220. }
  49221. declare module BABYLON {
  49222. /**
  49223. * Bounding box gizmo
  49224. */
  49225. export class BoundingBoxGizmo extends Gizmo {
  49226. private _lineBoundingBox;
  49227. private _rotateSpheresParent;
  49228. private _scaleBoxesParent;
  49229. private _boundingDimensions;
  49230. private _renderObserver;
  49231. private _pointerObserver;
  49232. private _scaleDragSpeed;
  49233. private _tmpQuaternion;
  49234. private _tmpVector;
  49235. private _tmpRotationMatrix;
  49236. /**
  49237. * 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)
  49238. */
  49239. ignoreChildren: boolean;
  49240. /**
  49241. * 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)
  49242. */
  49243. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49244. /**
  49245. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49246. */
  49247. rotationSphereSize: number;
  49248. /**
  49249. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49250. */
  49251. scaleBoxSize: number;
  49252. /**
  49253. * 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)
  49254. */
  49255. fixedDragMeshScreenSize: boolean;
  49256. /**
  49257. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49258. */
  49259. fixedDragMeshScreenSizeDistanceFactor: number;
  49260. /**
  49261. * Fired when a rotation sphere or scale box is dragged
  49262. */
  49263. onDragStartObservable: Observable<{}>;
  49264. /**
  49265. * Fired when a scale box is dragged
  49266. */
  49267. onScaleBoxDragObservable: Observable<{}>;
  49268. /**
  49269. * Fired when a scale box drag is ended
  49270. */
  49271. onScaleBoxDragEndObservable: Observable<{}>;
  49272. /**
  49273. * Fired when a rotation sphere is dragged
  49274. */
  49275. onRotationSphereDragObservable: Observable<{}>;
  49276. /**
  49277. * Fired when a rotation sphere drag is ended
  49278. */
  49279. onRotationSphereDragEndObservable: Observable<{}>;
  49280. /**
  49281. * 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)
  49282. */
  49283. scalePivot: Nullable<Vector3>;
  49284. /**
  49285. * Mesh used as a pivot to rotate the attached mesh
  49286. */
  49287. private _anchorMesh;
  49288. private _existingMeshScale;
  49289. private _dragMesh;
  49290. private pointerDragBehavior;
  49291. private coloredMaterial;
  49292. private hoverColoredMaterial;
  49293. /**
  49294. * Sets the color of the bounding box gizmo
  49295. * @param color the color to set
  49296. */
  49297. setColor(color: Color3): void;
  49298. /**
  49299. * Creates an BoundingBoxGizmo
  49300. * @param gizmoLayer The utility layer the gizmo will be added to
  49301. * @param color The color of the gizmo
  49302. */
  49303. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49305. private _selectNode;
  49306. /**
  49307. * Updates the bounding box information for the Gizmo
  49308. */
  49309. updateBoundingBox(): void;
  49310. private _updateRotationSpheres;
  49311. private _updateScaleBoxes;
  49312. /**
  49313. * Enables rotation on the specified axis and disables rotation on the others
  49314. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49315. */
  49316. setEnabledRotationAxis(axis: string): void;
  49317. /**
  49318. * Enables/disables scaling
  49319. * @param enable if scaling should be enabled
  49320. * @param homogeneousScaling defines if scaling should only be homogeneous
  49321. */
  49322. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49323. private _updateDummy;
  49324. /**
  49325. * Enables a pointer drag behavior on the bounding box of the gizmo
  49326. */
  49327. enableDragBehavior(): void;
  49328. /**
  49329. * Disposes of the gizmo
  49330. */
  49331. dispose(): void;
  49332. /**
  49333. * 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)
  49334. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49335. * @returns the bounding box mesh with the passed in mesh as a child
  49336. */
  49337. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49338. /**
  49339. * CustomMeshes are not supported by this gizmo
  49340. * @param mesh The mesh to replace the default mesh of the gizmo
  49341. */
  49342. setCustomMesh(mesh: Mesh): void;
  49343. }
  49344. }
  49345. declare module BABYLON {
  49346. /**
  49347. * Single plane rotation gizmo
  49348. */
  49349. export class PlaneRotationGizmo extends Gizmo {
  49350. /**
  49351. * Drag behavior responsible for the gizmos dragging interactions
  49352. */
  49353. dragBehavior: PointerDragBehavior;
  49354. private _pointerObserver;
  49355. /**
  49356. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49357. */
  49358. snapDistance: number;
  49359. /**
  49360. * Event that fires each time the gizmo snaps to a new location.
  49361. * * snapDistance is the the change in distance
  49362. */
  49363. onSnapObservable: Observable<{
  49364. snapDistance: number;
  49365. }>;
  49366. private _isEnabled;
  49367. private _parent;
  49368. /**
  49369. * Creates a PlaneRotationGizmo
  49370. * @param gizmoLayer The utility layer the gizmo will be added to
  49371. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49372. * @param color The color of the gizmo
  49373. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49374. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49375. */
  49376. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49377. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49378. /**
  49379. * If the gizmo is enabled
  49380. */
  49381. set isEnabled(value: boolean);
  49382. get isEnabled(): boolean;
  49383. /**
  49384. * Disposes of the gizmo
  49385. */
  49386. dispose(): void;
  49387. }
  49388. }
  49389. declare module BABYLON {
  49390. /**
  49391. * Gizmo that enables rotating a mesh along 3 axis
  49392. */
  49393. export class RotationGizmo extends Gizmo {
  49394. /**
  49395. * Internal gizmo used for interactions on the x axis
  49396. */
  49397. xGizmo: PlaneRotationGizmo;
  49398. /**
  49399. * Internal gizmo used for interactions on the y axis
  49400. */
  49401. yGizmo: PlaneRotationGizmo;
  49402. /**
  49403. * Internal gizmo used for interactions on the z axis
  49404. */
  49405. zGizmo: PlaneRotationGizmo;
  49406. /** Fires an event when any of it's sub gizmos are dragged */
  49407. onDragStartObservable: Observable<unknown>;
  49408. /** Fires an event when any of it's sub gizmos are released from dragging */
  49409. onDragEndObservable: Observable<unknown>;
  49410. private _meshAttached;
  49411. get attachedMesh(): Nullable<AbstractMesh>;
  49412. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49413. /**
  49414. * Creates a RotationGizmo
  49415. * @param gizmoLayer The utility layer the gizmo will be added to
  49416. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49417. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49418. */
  49419. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49420. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49421. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49422. /**
  49423. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49424. */
  49425. set snapDistance(value: number);
  49426. get snapDistance(): number;
  49427. /**
  49428. * Ratio for the scale of the gizmo (Default: 1)
  49429. */
  49430. set scaleRatio(value: number);
  49431. get scaleRatio(): number;
  49432. /**
  49433. * Disposes of the gizmo
  49434. */
  49435. dispose(): void;
  49436. /**
  49437. * CustomMeshes are not supported by this gizmo
  49438. * @param mesh The mesh to replace the default mesh of the gizmo
  49439. */
  49440. setCustomMesh(mesh: Mesh): void;
  49441. }
  49442. }
  49443. declare module BABYLON {
  49444. /**
  49445. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49446. */
  49447. export class GizmoManager implements IDisposable {
  49448. private scene;
  49449. /**
  49450. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49451. */
  49452. gizmos: {
  49453. positionGizmo: Nullable<PositionGizmo>;
  49454. rotationGizmo: Nullable<RotationGizmo>;
  49455. scaleGizmo: Nullable<ScaleGizmo>;
  49456. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49457. };
  49458. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49459. clearGizmoOnEmptyPointerEvent: boolean;
  49460. /** Fires an event when the manager is attached to a mesh */
  49461. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49462. private _gizmosEnabled;
  49463. private _pointerObserver;
  49464. private _attachedMesh;
  49465. private _boundingBoxColor;
  49466. private _defaultUtilityLayer;
  49467. private _defaultKeepDepthUtilityLayer;
  49468. /**
  49469. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49470. */
  49471. boundingBoxDragBehavior: SixDofDragBehavior;
  49472. /**
  49473. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49474. */
  49475. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49476. /**
  49477. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49478. */
  49479. usePointerToAttachGizmos: boolean;
  49480. /**
  49481. * Utility layer that the bounding box gizmo belongs to
  49482. */
  49483. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49484. /**
  49485. * Utility layer that all gizmos besides bounding box belong to
  49486. */
  49487. get utilityLayer(): UtilityLayerRenderer;
  49488. /**
  49489. * Instatiates a gizmo manager
  49490. * @param scene the scene to overlay the gizmos on top of
  49491. */
  49492. constructor(scene: Scene);
  49493. /**
  49494. * Attaches a set of gizmos to the specified mesh
  49495. * @param mesh The mesh the gizmo's should be attached to
  49496. */
  49497. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49498. /**
  49499. * If the position gizmo is enabled
  49500. */
  49501. set positionGizmoEnabled(value: boolean);
  49502. get positionGizmoEnabled(): boolean;
  49503. /**
  49504. * If the rotation gizmo is enabled
  49505. */
  49506. set rotationGizmoEnabled(value: boolean);
  49507. get rotationGizmoEnabled(): boolean;
  49508. /**
  49509. * If the scale gizmo is enabled
  49510. */
  49511. set scaleGizmoEnabled(value: boolean);
  49512. get scaleGizmoEnabled(): boolean;
  49513. /**
  49514. * If the boundingBox gizmo is enabled
  49515. */
  49516. set boundingBoxGizmoEnabled(value: boolean);
  49517. get boundingBoxGizmoEnabled(): boolean;
  49518. /**
  49519. * Disposes of the gizmo manager
  49520. */
  49521. dispose(): void;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. /**
  49526. * A directional light is defined by a direction (what a surprise!).
  49527. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49528. * 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.
  49529. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49530. */
  49531. export class DirectionalLight extends ShadowLight {
  49532. private _shadowFrustumSize;
  49533. /**
  49534. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49535. */
  49536. get shadowFrustumSize(): number;
  49537. /**
  49538. * Specifies a fix frustum size for the shadow generation.
  49539. */
  49540. set shadowFrustumSize(value: number);
  49541. private _shadowOrthoScale;
  49542. /**
  49543. * Gets the shadow projection scale against the optimal computed one.
  49544. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49545. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49546. */
  49547. get shadowOrthoScale(): number;
  49548. /**
  49549. * Sets the shadow projection scale against the optimal computed one.
  49550. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49551. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49552. */
  49553. set shadowOrthoScale(value: number);
  49554. /**
  49555. * Automatically compute the projection matrix to best fit (including all the casters)
  49556. * on each frame.
  49557. */
  49558. autoUpdateExtends: boolean;
  49559. /**
  49560. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49561. * on each frame. autoUpdateExtends must be set to true for this to work
  49562. */
  49563. autoCalcShadowZBounds: boolean;
  49564. private _orthoLeft;
  49565. private _orthoRight;
  49566. private _orthoTop;
  49567. private _orthoBottom;
  49568. /**
  49569. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49570. * The directional light is emitted from everywhere in the given direction.
  49571. * It can cast shadows.
  49572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49573. * @param name The friendly name of the light
  49574. * @param direction The direction of the light
  49575. * @param scene The scene the light belongs to
  49576. */
  49577. constructor(name: string, direction: Vector3, scene: Scene);
  49578. /**
  49579. * Returns the string "DirectionalLight".
  49580. * @return The class name
  49581. */
  49582. getClassName(): string;
  49583. /**
  49584. * Returns the integer 1.
  49585. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49586. */
  49587. getTypeID(): number;
  49588. /**
  49589. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49590. * Returns the DirectionalLight Shadow projection matrix.
  49591. */
  49592. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49593. /**
  49594. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49595. * Returns the DirectionalLight Shadow projection matrix.
  49596. */
  49597. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49598. /**
  49599. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49600. * Returns the DirectionalLight Shadow projection matrix.
  49601. */
  49602. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49603. protected _buildUniformLayout(): void;
  49604. /**
  49605. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49606. * @param effect The effect to update
  49607. * @param lightIndex The index of the light in the effect to update
  49608. * @returns The directional light
  49609. */
  49610. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49611. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49612. /**
  49613. * Gets the minZ used for shadow according to both the scene and the light.
  49614. *
  49615. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49616. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49617. * @param activeCamera The camera we are returning the min for
  49618. * @returns the depth min z
  49619. */
  49620. getDepthMinZ(activeCamera: Camera): number;
  49621. /**
  49622. * Gets the maxZ used for shadow according to both the scene and the light.
  49623. *
  49624. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49625. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49626. * @param activeCamera The camera we are returning the max for
  49627. * @returns the depth max z
  49628. */
  49629. getDepthMaxZ(activeCamera: Camera): number;
  49630. /**
  49631. * Prepares the list of defines specific to the light type.
  49632. * @param defines the list of defines
  49633. * @param lightIndex defines the index of the light for the effect
  49634. */
  49635. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49636. }
  49637. }
  49638. declare module BABYLON {
  49639. /**
  49640. * Class containing static functions to help procedurally build meshes
  49641. */
  49642. export class HemisphereBuilder {
  49643. /**
  49644. * Creates a hemisphere mesh
  49645. * @param name defines the name of the mesh
  49646. * @param options defines the options used to create the mesh
  49647. * @param scene defines the hosting scene
  49648. * @returns the hemisphere mesh
  49649. */
  49650. static CreateHemisphere(name: string, options: {
  49651. segments?: number;
  49652. diameter?: number;
  49653. sideOrientation?: number;
  49654. }, scene: any): Mesh;
  49655. }
  49656. }
  49657. declare module BABYLON {
  49658. /**
  49659. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49660. * These values define a cone of light starting from the position, emitting toward the direction.
  49661. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49662. * and the exponent defines the speed of the decay of the light with distance (reach).
  49663. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49664. */
  49665. export class SpotLight extends ShadowLight {
  49666. private _angle;
  49667. private _innerAngle;
  49668. private _cosHalfAngle;
  49669. private _lightAngleScale;
  49670. private _lightAngleOffset;
  49671. /**
  49672. * Gets the cone angle of the spot light in Radians.
  49673. */
  49674. get angle(): number;
  49675. /**
  49676. * Sets the cone angle of the spot light in Radians.
  49677. */
  49678. set angle(value: number);
  49679. /**
  49680. * Only used in gltf falloff mode, this defines the angle where
  49681. * the directional falloff will start before cutting at angle which could be seen
  49682. * as outer angle.
  49683. */
  49684. get innerAngle(): number;
  49685. /**
  49686. * Only used in gltf falloff mode, this defines the angle where
  49687. * the directional falloff will start before cutting at angle which could be seen
  49688. * as outer angle.
  49689. */
  49690. set innerAngle(value: number);
  49691. private _shadowAngleScale;
  49692. /**
  49693. * Allows scaling the angle of the light for shadow generation only.
  49694. */
  49695. get shadowAngleScale(): number;
  49696. /**
  49697. * Allows scaling the angle of the light for shadow generation only.
  49698. */
  49699. set shadowAngleScale(value: number);
  49700. /**
  49701. * The light decay speed with the distance from the emission spot.
  49702. */
  49703. exponent: number;
  49704. private _projectionTextureMatrix;
  49705. /**
  49706. * Allows reading the projecton texture
  49707. */
  49708. get projectionTextureMatrix(): Matrix;
  49709. protected _projectionTextureLightNear: number;
  49710. /**
  49711. * Gets the near clip of the Spotlight for texture projection.
  49712. */
  49713. get projectionTextureLightNear(): number;
  49714. /**
  49715. * Sets the near clip of the Spotlight for texture projection.
  49716. */
  49717. set projectionTextureLightNear(value: number);
  49718. protected _projectionTextureLightFar: number;
  49719. /**
  49720. * Gets the far clip of the Spotlight for texture projection.
  49721. */
  49722. get projectionTextureLightFar(): number;
  49723. /**
  49724. * Sets the far clip of the Spotlight for texture projection.
  49725. */
  49726. set projectionTextureLightFar(value: number);
  49727. protected _projectionTextureUpDirection: Vector3;
  49728. /**
  49729. * Gets the Up vector of the Spotlight for texture projection.
  49730. */
  49731. get projectionTextureUpDirection(): Vector3;
  49732. /**
  49733. * Sets the Up vector of the Spotlight for texture projection.
  49734. */
  49735. set projectionTextureUpDirection(value: Vector3);
  49736. private _projectionTexture;
  49737. /**
  49738. * Gets the projection texture of the light.
  49739. */
  49740. get projectionTexture(): Nullable<BaseTexture>;
  49741. /**
  49742. * Sets the projection texture of the light.
  49743. */
  49744. set projectionTexture(value: Nullable<BaseTexture>);
  49745. private _projectionTextureViewLightDirty;
  49746. private _projectionTextureProjectionLightDirty;
  49747. private _projectionTextureDirty;
  49748. private _projectionTextureViewTargetVector;
  49749. private _projectionTextureViewLightMatrix;
  49750. private _projectionTextureProjectionLightMatrix;
  49751. private _projectionTextureScalingMatrix;
  49752. /**
  49753. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49754. * It can cast shadows.
  49755. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49756. * @param name The light friendly name
  49757. * @param position The position of the spot light in the scene
  49758. * @param direction The direction of the light in the scene
  49759. * @param angle The cone angle of the light in Radians
  49760. * @param exponent The light decay speed with the distance from the emission spot
  49761. * @param scene The scene the lights belongs to
  49762. */
  49763. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49764. /**
  49765. * Returns the string "SpotLight".
  49766. * @returns the class name
  49767. */
  49768. getClassName(): string;
  49769. /**
  49770. * Returns the integer 2.
  49771. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49772. */
  49773. getTypeID(): number;
  49774. /**
  49775. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49776. */
  49777. protected _setDirection(value: Vector3): void;
  49778. /**
  49779. * Overrides the position setter to recompute the projection texture view light Matrix.
  49780. */
  49781. protected _setPosition(value: Vector3): void;
  49782. /**
  49783. * 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.
  49784. * Returns the SpotLight.
  49785. */
  49786. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49787. protected _computeProjectionTextureViewLightMatrix(): void;
  49788. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49789. /**
  49790. * Main function for light texture projection matrix computing.
  49791. */
  49792. protected _computeProjectionTextureMatrix(): void;
  49793. protected _buildUniformLayout(): void;
  49794. private _computeAngleValues;
  49795. /**
  49796. * Sets the passed Effect "effect" with the Light textures.
  49797. * @param effect The effect to update
  49798. * @param lightIndex The index of the light in the effect to update
  49799. * @returns The light
  49800. */
  49801. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49802. /**
  49803. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49804. * @param effect The effect to update
  49805. * @param lightIndex The index of the light in the effect to update
  49806. * @returns The spot light
  49807. */
  49808. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49809. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49810. /**
  49811. * Disposes the light and the associated resources.
  49812. */
  49813. dispose(): void;
  49814. /**
  49815. * Prepares the list of defines specific to the light type.
  49816. * @param defines the list of defines
  49817. * @param lightIndex defines the index of the light for the effect
  49818. */
  49819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49820. }
  49821. }
  49822. declare module BABYLON {
  49823. /**
  49824. * Gizmo that enables viewing a light
  49825. */
  49826. export class LightGizmo extends Gizmo {
  49827. private _lightMesh;
  49828. private _material;
  49829. private _cachedPosition;
  49830. private _cachedForward;
  49831. private _attachedMeshParent;
  49832. /**
  49833. * Creates a LightGizmo
  49834. * @param gizmoLayer The utility layer the gizmo will be added to
  49835. */
  49836. constructor(gizmoLayer?: UtilityLayerRenderer);
  49837. private _light;
  49838. /**
  49839. * The light that the gizmo is attached to
  49840. */
  49841. set light(light: Nullable<Light>);
  49842. get light(): Nullable<Light>;
  49843. /**
  49844. * Gets the material used to render the light gizmo
  49845. */
  49846. get material(): StandardMaterial;
  49847. /**
  49848. * @hidden
  49849. * Updates the gizmo to match the attached mesh's position/rotation
  49850. */
  49851. protected _update(): void;
  49852. private static _Scale;
  49853. /**
  49854. * Creates the lines for a light mesh
  49855. */
  49856. private static _CreateLightLines;
  49857. /**
  49858. * Disposes of the light gizmo
  49859. */
  49860. dispose(): void;
  49861. private static _CreateHemisphericLightMesh;
  49862. private static _CreatePointLightMesh;
  49863. private static _CreateSpotLightMesh;
  49864. private static _CreateDirectionalLightMesh;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /** @hidden */
  49869. export var backgroundFragmentDeclaration: {
  49870. name: string;
  49871. shader: string;
  49872. };
  49873. }
  49874. declare module BABYLON {
  49875. /** @hidden */
  49876. export var backgroundUboDeclaration: {
  49877. name: string;
  49878. shader: string;
  49879. };
  49880. }
  49881. declare module BABYLON {
  49882. /** @hidden */
  49883. export var backgroundPixelShader: {
  49884. name: string;
  49885. shader: string;
  49886. };
  49887. }
  49888. declare module BABYLON {
  49889. /** @hidden */
  49890. export var backgroundVertexDeclaration: {
  49891. name: string;
  49892. shader: string;
  49893. };
  49894. }
  49895. declare module BABYLON {
  49896. /** @hidden */
  49897. export var backgroundVertexShader: {
  49898. name: string;
  49899. shader: string;
  49900. };
  49901. }
  49902. declare module BABYLON {
  49903. /**
  49904. * Background material used to create an efficient environement around your scene.
  49905. */
  49906. export class BackgroundMaterial extends PushMaterial {
  49907. /**
  49908. * Standard reflectance value at parallel view angle.
  49909. */
  49910. static StandardReflectance0: number;
  49911. /**
  49912. * Standard reflectance value at grazing angle.
  49913. */
  49914. static StandardReflectance90: number;
  49915. protected _primaryColor: Color3;
  49916. /**
  49917. * Key light Color (multiply against the environement texture)
  49918. */
  49919. primaryColor: Color3;
  49920. protected __perceptualColor: Nullable<Color3>;
  49921. /**
  49922. * Experimental Internal Use Only.
  49923. *
  49924. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49925. * This acts as a helper to set the primary color to a more "human friendly" value.
  49926. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49927. * output color as close as possible from the chosen value.
  49928. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49929. * part of lighting setup.)
  49930. */
  49931. get _perceptualColor(): Nullable<Color3>;
  49932. set _perceptualColor(value: Nullable<Color3>);
  49933. protected _primaryColorShadowLevel: float;
  49934. /**
  49935. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49936. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49937. */
  49938. get primaryColorShadowLevel(): float;
  49939. set primaryColorShadowLevel(value: float);
  49940. protected _primaryColorHighlightLevel: float;
  49941. /**
  49942. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49943. * The primary color is used at the level chosen to define what the white area would look.
  49944. */
  49945. get primaryColorHighlightLevel(): float;
  49946. set primaryColorHighlightLevel(value: float);
  49947. protected _reflectionTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * Reflection Texture used in the material.
  49950. * Should be author in a specific way for the best result (refer to the documentation).
  49951. */
  49952. reflectionTexture: Nullable<BaseTexture>;
  49953. protected _reflectionBlur: float;
  49954. /**
  49955. * Reflection Texture level of blur.
  49956. *
  49957. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49958. * texture twice.
  49959. */
  49960. reflectionBlur: float;
  49961. protected _diffuseTexture: Nullable<BaseTexture>;
  49962. /**
  49963. * Diffuse Texture used in the material.
  49964. * Should be author in a specific way for the best result (refer to the documentation).
  49965. */
  49966. diffuseTexture: Nullable<BaseTexture>;
  49967. protected _shadowLights: Nullable<IShadowLight[]>;
  49968. /**
  49969. * Specify the list of lights casting shadow on the material.
  49970. * All scene shadow lights will be included if null.
  49971. */
  49972. shadowLights: Nullable<IShadowLight[]>;
  49973. protected _shadowLevel: float;
  49974. /**
  49975. * Helps adjusting the shadow to a softer level if required.
  49976. * 0 means black shadows and 1 means no shadows.
  49977. */
  49978. shadowLevel: float;
  49979. protected _sceneCenter: Vector3;
  49980. /**
  49981. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49982. * It is usually zero but might be interesting to modify according to your setup.
  49983. */
  49984. sceneCenter: Vector3;
  49985. protected _opacityFresnel: boolean;
  49986. /**
  49987. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49988. * This helps ensuring a nice transition when the camera goes under the ground.
  49989. */
  49990. opacityFresnel: boolean;
  49991. protected _reflectionFresnel: boolean;
  49992. /**
  49993. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49994. * This helps adding a mirror texture on the ground.
  49995. */
  49996. reflectionFresnel: boolean;
  49997. protected _reflectionFalloffDistance: number;
  49998. /**
  49999. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50000. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50001. */
  50002. reflectionFalloffDistance: number;
  50003. protected _reflectionAmount: number;
  50004. /**
  50005. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50006. */
  50007. reflectionAmount: number;
  50008. protected _reflectionReflectance0: number;
  50009. /**
  50010. * This specifies the weight of the reflection at grazing angle.
  50011. */
  50012. reflectionReflectance0: number;
  50013. protected _reflectionReflectance90: number;
  50014. /**
  50015. * This specifies the weight of the reflection at a perpendicular point of view.
  50016. */
  50017. reflectionReflectance90: number;
  50018. /**
  50019. * Sets the reflection reflectance fresnel values according to the default standard
  50020. * empirically know to work well :-)
  50021. */
  50022. set reflectionStandardFresnelWeight(value: number);
  50023. protected _useRGBColor: boolean;
  50024. /**
  50025. * Helps to directly use the maps channels instead of their level.
  50026. */
  50027. useRGBColor: boolean;
  50028. protected _enableNoise: boolean;
  50029. /**
  50030. * This helps reducing the banding effect that could occur on the background.
  50031. */
  50032. enableNoise: boolean;
  50033. /**
  50034. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50035. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50036. * Recommended to be keep at 1.0 except for special cases.
  50037. */
  50038. get fovMultiplier(): number;
  50039. set fovMultiplier(value: number);
  50040. private _fovMultiplier;
  50041. /**
  50042. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50043. */
  50044. useEquirectangularFOV: boolean;
  50045. private _maxSimultaneousLights;
  50046. /**
  50047. * Number of Simultaneous lights allowed on the material.
  50048. */
  50049. maxSimultaneousLights: int;
  50050. /**
  50051. * Default configuration related to image processing available in the Background Material.
  50052. */
  50053. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50054. /**
  50055. * Keep track of the image processing observer to allow dispose and replace.
  50056. */
  50057. private _imageProcessingObserver;
  50058. /**
  50059. * Attaches a new image processing configuration to the PBR Material.
  50060. * @param configuration (if null the scene configuration will be use)
  50061. */
  50062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50063. /**
  50064. * Gets the image processing configuration used either in this material.
  50065. */
  50066. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50067. /**
  50068. * Sets the Default image processing configuration used either in the this material.
  50069. *
  50070. * If sets to null, the scene one is in use.
  50071. */
  50072. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50073. /**
  50074. * Gets wether the color curves effect is enabled.
  50075. */
  50076. get cameraColorCurvesEnabled(): boolean;
  50077. /**
  50078. * Sets wether the color curves effect is enabled.
  50079. */
  50080. set cameraColorCurvesEnabled(value: boolean);
  50081. /**
  50082. * Gets wether the color grading effect is enabled.
  50083. */
  50084. get cameraColorGradingEnabled(): boolean;
  50085. /**
  50086. * Gets wether the color grading effect is enabled.
  50087. */
  50088. set cameraColorGradingEnabled(value: boolean);
  50089. /**
  50090. * Gets wether tonemapping is enabled or not.
  50091. */
  50092. get cameraToneMappingEnabled(): boolean;
  50093. /**
  50094. * Sets wether tonemapping is enabled or not
  50095. */
  50096. set cameraToneMappingEnabled(value: boolean);
  50097. /**
  50098. * The camera exposure used on this material.
  50099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50100. * This corresponds to a photographic exposure.
  50101. */
  50102. get cameraExposure(): float;
  50103. /**
  50104. * The camera exposure used on this material.
  50105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50106. * This corresponds to a photographic exposure.
  50107. */
  50108. set cameraExposure(value: float);
  50109. /**
  50110. * Gets The camera contrast used on this material.
  50111. */
  50112. get cameraContrast(): float;
  50113. /**
  50114. * Sets The camera contrast used on this material.
  50115. */
  50116. set cameraContrast(value: float);
  50117. /**
  50118. * Gets the Color Grading 2D Lookup Texture.
  50119. */
  50120. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50121. /**
  50122. * Sets the Color Grading 2D Lookup Texture.
  50123. */
  50124. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50125. /**
  50126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50128. * 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;
  50129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50130. */
  50131. get cameraColorCurves(): Nullable<ColorCurves>;
  50132. /**
  50133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50135. * 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;
  50136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50137. */
  50138. set cameraColorCurves(value: Nullable<ColorCurves>);
  50139. /**
  50140. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50141. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50142. */
  50143. switchToBGR: boolean;
  50144. private _renderTargets;
  50145. private _reflectionControls;
  50146. private _white;
  50147. private _primaryShadowColor;
  50148. private _primaryHighlightColor;
  50149. /**
  50150. * Instantiates a Background Material in the given scene
  50151. * @param name The friendly name of the material
  50152. * @param scene The scene to add the material to
  50153. */
  50154. constructor(name: string, scene: Scene);
  50155. /**
  50156. * Gets a boolean indicating that current material needs to register RTT
  50157. */
  50158. get hasRenderTargetTextures(): boolean;
  50159. /**
  50160. * The entire material has been created in order to prevent overdraw.
  50161. * @returns false
  50162. */
  50163. needAlphaTesting(): boolean;
  50164. /**
  50165. * The entire material has been created in order to prevent overdraw.
  50166. * @returns true if blending is enable
  50167. */
  50168. needAlphaBlending(): boolean;
  50169. /**
  50170. * Checks wether the material is ready to be rendered for a given mesh.
  50171. * @param mesh The mesh to render
  50172. * @param subMesh The submesh to check against
  50173. * @param useInstances Specify wether or not the material is used with instances
  50174. * @returns true if all the dependencies are ready (Textures, Effects...)
  50175. */
  50176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50177. /**
  50178. * Compute the primary color according to the chosen perceptual color.
  50179. */
  50180. private _computePrimaryColorFromPerceptualColor;
  50181. /**
  50182. * Compute the highlights and shadow colors according to their chosen levels.
  50183. */
  50184. private _computePrimaryColors;
  50185. /**
  50186. * Build the uniform buffer used in the material.
  50187. */
  50188. buildUniformLayout(): void;
  50189. /**
  50190. * Unbind the material.
  50191. */
  50192. unbind(): void;
  50193. /**
  50194. * Bind only the world matrix to the material.
  50195. * @param world The world matrix to bind.
  50196. */
  50197. bindOnlyWorldMatrix(world: Matrix): void;
  50198. /**
  50199. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50200. * @param world The world matrix to bind.
  50201. * @param subMesh The submesh to bind for.
  50202. */
  50203. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50204. /**
  50205. * Checks to see if a texture is used in the material.
  50206. * @param texture - Base texture to use.
  50207. * @returns - Boolean specifying if a texture is used in the material.
  50208. */
  50209. hasTexture(texture: BaseTexture): boolean;
  50210. /**
  50211. * Dispose the material.
  50212. * @param forceDisposeEffect Force disposal of the associated effect.
  50213. * @param forceDisposeTextures Force disposal of the associated textures.
  50214. */
  50215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50216. /**
  50217. * Clones the material.
  50218. * @param name The cloned name.
  50219. * @returns The cloned material.
  50220. */
  50221. clone(name: string): BackgroundMaterial;
  50222. /**
  50223. * Serializes the current material to its JSON representation.
  50224. * @returns The JSON representation.
  50225. */
  50226. serialize(): any;
  50227. /**
  50228. * Gets the class name of the material
  50229. * @returns "BackgroundMaterial"
  50230. */
  50231. getClassName(): string;
  50232. /**
  50233. * Parse a JSON input to create back a background material.
  50234. * @param source The JSON data to parse
  50235. * @param scene The scene to create the parsed material in
  50236. * @param rootUrl The root url of the assets the material depends upon
  50237. * @returns the instantiated BackgroundMaterial.
  50238. */
  50239. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * Represents the different options available during the creation of
  50245. * a Environment helper.
  50246. *
  50247. * This can control the default ground, skybox and image processing setup of your scene.
  50248. */
  50249. export interface IEnvironmentHelperOptions {
  50250. /**
  50251. * Specifies whether or not to create a ground.
  50252. * True by default.
  50253. */
  50254. createGround: boolean;
  50255. /**
  50256. * Specifies the ground size.
  50257. * 15 by default.
  50258. */
  50259. groundSize: number;
  50260. /**
  50261. * The texture used on the ground for the main color.
  50262. * Comes from the BabylonJS CDN by default.
  50263. *
  50264. * Remarks: Can be either a texture or a url.
  50265. */
  50266. groundTexture: string | BaseTexture;
  50267. /**
  50268. * The color mixed in the ground texture by default.
  50269. * BabylonJS clearColor by default.
  50270. */
  50271. groundColor: Color3;
  50272. /**
  50273. * Specifies the ground opacity.
  50274. * 1 by default.
  50275. */
  50276. groundOpacity: number;
  50277. /**
  50278. * Enables the ground to receive shadows.
  50279. * True by default.
  50280. */
  50281. enableGroundShadow: boolean;
  50282. /**
  50283. * Helps preventing the shadow to be fully black on the ground.
  50284. * 0.5 by default.
  50285. */
  50286. groundShadowLevel: number;
  50287. /**
  50288. * Creates a mirror texture attach to the ground.
  50289. * false by default.
  50290. */
  50291. enableGroundMirror: boolean;
  50292. /**
  50293. * Specifies the ground mirror size ratio.
  50294. * 0.3 by default as the default kernel is 64.
  50295. */
  50296. groundMirrorSizeRatio: number;
  50297. /**
  50298. * Specifies the ground mirror blur kernel size.
  50299. * 64 by default.
  50300. */
  50301. groundMirrorBlurKernel: number;
  50302. /**
  50303. * Specifies the ground mirror visibility amount.
  50304. * 1 by default
  50305. */
  50306. groundMirrorAmount: number;
  50307. /**
  50308. * Specifies the ground mirror reflectance weight.
  50309. * This uses the standard weight of the background material to setup the fresnel effect
  50310. * of the mirror.
  50311. * 1 by default.
  50312. */
  50313. groundMirrorFresnelWeight: number;
  50314. /**
  50315. * Specifies the ground mirror Falloff distance.
  50316. * This can helps reducing the size of the reflection.
  50317. * 0 by Default.
  50318. */
  50319. groundMirrorFallOffDistance: number;
  50320. /**
  50321. * Specifies the ground mirror texture type.
  50322. * Unsigned Int by Default.
  50323. */
  50324. groundMirrorTextureType: number;
  50325. /**
  50326. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50327. * the shown objects.
  50328. */
  50329. groundYBias: number;
  50330. /**
  50331. * Specifies whether or not to create a skybox.
  50332. * True by default.
  50333. */
  50334. createSkybox: boolean;
  50335. /**
  50336. * Specifies the skybox size.
  50337. * 20 by default.
  50338. */
  50339. skyboxSize: number;
  50340. /**
  50341. * The texture used on the skybox for the main color.
  50342. * Comes from the BabylonJS CDN by default.
  50343. *
  50344. * Remarks: Can be either a texture or a url.
  50345. */
  50346. skyboxTexture: string | BaseTexture;
  50347. /**
  50348. * The color mixed in the skybox texture by default.
  50349. * BabylonJS clearColor by default.
  50350. */
  50351. skyboxColor: Color3;
  50352. /**
  50353. * The background rotation around the Y axis of the scene.
  50354. * This helps aligning the key lights of your scene with the background.
  50355. * 0 by default.
  50356. */
  50357. backgroundYRotation: number;
  50358. /**
  50359. * Compute automatically the size of the elements to best fit with the scene.
  50360. */
  50361. sizeAuto: boolean;
  50362. /**
  50363. * Default position of the rootMesh if autoSize is not true.
  50364. */
  50365. rootPosition: Vector3;
  50366. /**
  50367. * Sets up the image processing in the scene.
  50368. * true by default.
  50369. */
  50370. setupImageProcessing: boolean;
  50371. /**
  50372. * The texture used as your environment texture in the scene.
  50373. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50374. *
  50375. * Remarks: Can be either a texture or a url.
  50376. */
  50377. environmentTexture: string | BaseTexture;
  50378. /**
  50379. * The value of the exposure to apply to the scene.
  50380. * 0.6 by default if setupImageProcessing is true.
  50381. */
  50382. cameraExposure: number;
  50383. /**
  50384. * The value of the contrast to apply to the scene.
  50385. * 1.6 by default if setupImageProcessing is true.
  50386. */
  50387. cameraContrast: number;
  50388. /**
  50389. * Specifies whether or not tonemapping should be enabled in the scene.
  50390. * true by default if setupImageProcessing is true.
  50391. */
  50392. toneMappingEnabled: boolean;
  50393. }
  50394. /**
  50395. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50396. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50397. * It also helps with the default setup of your imageProcessing configuration.
  50398. */
  50399. export class EnvironmentHelper {
  50400. /**
  50401. * Default ground texture URL.
  50402. */
  50403. private static _groundTextureCDNUrl;
  50404. /**
  50405. * Default skybox texture URL.
  50406. */
  50407. private static _skyboxTextureCDNUrl;
  50408. /**
  50409. * Default environment texture URL.
  50410. */
  50411. private static _environmentTextureCDNUrl;
  50412. /**
  50413. * Creates the default options for the helper.
  50414. */
  50415. private static _getDefaultOptions;
  50416. private _rootMesh;
  50417. /**
  50418. * Gets the root mesh created by the helper.
  50419. */
  50420. get rootMesh(): Mesh;
  50421. private _skybox;
  50422. /**
  50423. * Gets the skybox created by the helper.
  50424. */
  50425. get skybox(): Nullable<Mesh>;
  50426. private _skyboxTexture;
  50427. /**
  50428. * Gets the skybox texture created by the helper.
  50429. */
  50430. get skyboxTexture(): Nullable<BaseTexture>;
  50431. private _skyboxMaterial;
  50432. /**
  50433. * Gets the skybox material created by the helper.
  50434. */
  50435. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50436. private _ground;
  50437. /**
  50438. * Gets the ground mesh created by the helper.
  50439. */
  50440. get ground(): Nullable<Mesh>;
  50441. private _groundTexture;
  50442. /**
  50443. * Gets the ground texture created by the helper.
  50444. */
  50445. get groundTexture(): Nullable<BaseTexture>;
  50446. private _groundMirror;
  50447. /**
  50448. * Gets the ground mirror created by the helper.
  50449. */
  50450. get groundMirror(): Nullable<MirrorTexture>;
  50451. /**
  50452. * Gets the ground mirror render list to helps pushing the meshes
  50453. * you wish in the ground reflection.
  50454. */
  50455. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50456. private _groundMaterial;
  50457. /**
  50458. * Gets the ground material created by the helper.
  50459. */
  50460. get groundMaterial(): Nullable<BackgroundMaterial>;
  50461. /**
  50462. * Stores the creation options.
  50463. */
  50464. private readonly _scene;
  50465. private _options;
  50466. /**
  50467. * This observable will be notified with any error during the creation of the environment,
  50468. * mainly texture creation errors.
  50469. */
  50470. onErrorObservable: Observable<{
  50471. message?: string;
  50472. exception?: any;
  50473. }>;
  50474. /**
  50475. * constructor
  50476. * @param options Defines the options we want to customize the helper
  50477. * @param scene The scene to add the material to
  50478. */
  50479. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50480. /**
  50481. * Updates the background according to the new options
  50482. * @param options
  50483. */
  50484. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50485. /**
  50486. * Sets the primary color of all the available elements.
  50487. * @param color the main color to affect to the ground and the background
  50488. */
  50489. setMainColor(color: Color3): void;
  50490. /**
  50491. * Setup the image processing according to the specified options.
  50492. */
  50493. private _setupImageProcessing;
  50494. /**
  50495. * Setup the environment texture according to the specified options.
  50496. */
  50497. private _setupEnvironmentTexture;
  50498. /**
  50499. * Setup the background according to the specified options.
  50500. */
  50501. private _setupBackground;
  50502. /**
  50503. * Get the scene sizes according to the setup.
  50504. */
  50505. private _getSceneSize;
  50506. /**
  50507. * Setup the ground according to the specified options.
  50508. */
  50509. private _setupGround;
  50510. /**
  50511. * Setup the ground material according to the specified options.
  50512. */
  50513. private _setupGroundMaterial;
  50514. /**
  50515. * Setup the ground diffuse texture according to the specified options.
  50516. */
  50517. private _setupGroundDiffuseTexture;
  50518. /**
  50519. * Setup the ground mirror texture according to the specified options.
  50520. */
  50521. private _setupGroundMirrorTexture;
  50522. /**
  50523. * Setup the ground to receive the mirror texture.
  50524. */
  50525. private _setupMirrorInGroundMaterial;
  50526. /**
  50527. * Setup the skybox according to the specified options.
  50528. */
  50529. private _setupSkybox;
  50530. /**
  50531. * Setup the skybox material according to the specified options.
  50532. */
  50533. private _setupSkyboxMaterial;
  50534. /**
  50535. * Setup the skybox reflection texture according to the specified options.
  50536. */
  50537. private _setupSkyboxReflectionTexture;
  50538. private _errorHandler;
  50539. /**
  50540. * Dispose all the elements created by the Helper.
  50541. */
  50542. dispose(): void;
  50543. }
  50544. }
  50545. declare module BABYLON {
  50546. /**
  50547. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50548. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50549. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50550. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50551. */
  50552. export class PhotoDome extends TransformNode {
  50553. /**
  50554. * Define the image as a Monoscopic panoramic 360 image.
  50555. */
  50556. static readonly MODE_MONOSCOPIC: number;
  50557. /**
  50558. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50559. */
  50560. static readonly MODE_TOPBOTTOM: number;
  50561. /**
  50562. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50563. */
  50564. static readonly MODE_SIDEBYSIDE: number;
  50565. private _useDirectMapping;
  50566. /**
  50567. * The texture being displayed on the sphere
  50568. */
  50569. protected _photoTexture: Texture;
  50570. /**
  50571. * Gets or sets the texture being displayed on the sphere
  50572. */
  50573. get photoTexture(): Texture;
  50574. set photoTexture(value: Texture);
  50575. /**
  50576. * Observable raised when an error occured while loading the 360 image
  50577. */
  50578. onLoadErrorObservable: Observable<string>;
  50579. /**
  50580. * The skybox material
  50581. */
  50582. protected _material: BackgroundMaterial;
  50583. /**
  50584. * The surface used for the skybox
  50585. */
  50586. protected _mesh: Mesh;
  50587. /**
  50588. * Gets the mesh used for the skybox.
  50589. */
  50590. get mesh(): Mesh;
  50591. /**
  50592. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50593. * Also see the options.resolution property.
  50594. */
  50595. get fovMultiplier(): number;
  50596. set fovMultiplier(value: number);
  50597. private _imageMode;
  50598. /**
  50599. * Gets or set the current video mode for the video. It can be:
  50600. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50601. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50602. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50603. */
  50604. get imageMode(): number;
  50605. set imageMode(value: number);
  50606. /**
  50607. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50608. * @param name Element's name, child elements will append suffixes for their own names.
  50609. * @param urlsOfPhoto defines the url of the photo to display
  50610. * @param options defines an object containing optional or exposed sub element properties
  50611. * @param onError defines a callback called when an error occured while loading the texture
  50612. */
  50613. constructor(name: string, urlOfPhoto: string, options: {
  50614. resolution?: number;
  50615. size?: number;
  50616. useDirectMapping?: boolean;
  50617. faceForward?: boolean;
  50618. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50619. private _onBeforeCameraRenderObserver;
  50620. private _changeImageMode;
  50621. /**
  50622. * Releases resources associated with this node.
  50623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50625. */
  50626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50627. }
  50628. }
  50629. declare module BABYLON {
  50630. /**
  50631. * Class used to host RGBD texture specific utilities
  50632. */
  50633. export class RGBDTextureTools {
  50634. /**
  50635. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50636. * @param texture the texture to expand.
  50637. */
  50638. static ExpandRGBDTexture(texture: Texture): void;
  50639. }
  50640. }
  50641. declare module BABYLON {
  50642. /**
  50643. * Class used to host texture specific utilities
  50644. */
  50645. export class BRDFTextureTools {
  50646. /**
  50647. * Prevents texture cache collision
  50648. */
  50649. private static _instanceNumber;
  50650. /**
  50651. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50652. * @param scene defines the hosting scene
  50653. * @returns the environment BRDF texture
  50654. */
  50655. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50656. private static _environmentBRDFBase64Texture;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * @hidden
  50662. */
  50663. export interface IMaterialClearCoatDefines {
  50664. CLEARCOAT: boolean;
  50665. CLEARCOAT_DEFAULTIOR: boolean;
  50666. CLEARCOAT_TEXTURE: boolean;
  50667. CLEARCOAT_TEXTUREDIRECTUV: number;
  50668. CLEARCOAT_BUMP: boolean;
  50669. CLEARCOAT_BUMPDIRECTUV: number;
  50670. CLEARCOAT_TINT: boolean;
  50671. CLEARCOAT_TINT_TEXTURE: boolean;
  50672. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50673. /** @hidden */
  50674. _areTexturesDirty: boolean;
  50675. }
  50676. /**
  50677. * Define the code related to the clear coat parameters of the pbr material.
  50678. */
  50679. export class PBRClearCoatConfiguration {
  50680. /**
  50681. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50682. * The default fits with a polyurethane material.
  50683. */
  50684. private static readonly _DefaultIndexOfRefraction;
  50685. private _isEnabled;
  50686. /**
  50687. * Defines if the clear coat is enabled in the material.
  50688. */
  50689. isEnabled: boolean;
  50690. /**
  50691. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50692. */
  50693. intensity: number;
  50694. /**
  50695. * Defines the clear coat layer roughness.
  50696. */
  50697. roughness: number;
  50698. private _indexOfRefraction;
  50699. /**
  50700. * Defines the index of refraction of the clear coat.
  50701. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50702. * The default fits with a polyurethane material.
  50703. * Changing the default value is more performance intensive.
  50704. */
  50705. indexOfRefraction: number;
  50706. private _texture;
  50707. /**
  50708. * Stores the clear coat values in a texture.
  50709. */
  50710. texture: Nullable<BaseTexture>;
  50711. private _bumpTexture;
  50712. /**
  50713. * Define the clear coat specific bump texture.
  50714. */
  50715. bumpTexture: Nullable<BaseTexture>;
  50716. private _isTintEnabled;
  50717. /**
  50718. * Defines if the clear coat tint is enabled in the material.
  50719. */
  50720. isTintEnabled: boolean;
  50721. /**
  50722. * Defines the clear coat tint of the material.
  50723. * This is only use if tint is enabled
  50724. */
  50725. tintColor: Color3;
  50726. /**
  50727. * Defines the distance at which the tint color should be found in the
  50728. * clear coat media.
  50729. * This is only use if tint is enabled
  50730. */
  50731. tintColorAtDistance: number;
  50732. /**
  50733. * Defines the clear coat layer thickness.
  50734. * This is only use if tint is enabled
  50735. */
  50736. tintThickness: number;
  50737. private _tintTexture;
  50738. /**
  50739. * Stores the clear tint values in a texture.
  50740. * rgb is tint
  50741. * a is a thickness factor
  50742. */
  50743. tintTexture: Nullable<BaseTexture>;
  50744. /** @hidden */
  50745. private _internalMarkAllSubMeshesAsTexturesDirty;
  50746. /** @hidden */
  50747. _markAllSubMeshesAsTexturesDirty(): void;
  50748. /**
  50749. * Instantiate a new istance of clear coat configuration.
  50750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50751. */
  50752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50753. /**
  50754. * Gets wehter the submesh is ready to be used or not.
  50755. * @param defines the list of "defines" to update.
  50756. * @param scene defines the scene the material belongs to.
  50757. * @param engine defines the engine the material belongs to.
  50758. * @param disableBumpMap defines wether the material disables bump or not.
  50759. * @returns - boolean indicating that the submesh is ready or not.
  50760. */
  50761. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50762. /**
  50763. * Checks to see if a texture is used in the material.
  50764. * @param defines the list of "defines" to update.
  50765. * @param scene defines the scene to the material belongs to.
  50766. */
  50767. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50768. /**
  50769. * Binds the material data.
  50770. * @param uniformBuffer defines the Uniform buffer to fill in.
  50771. * @param scene defines the scene the material belongs to.
  50772. * @param engine defines the engine the material belongs to.
  50773. * @param disableBumpMap defines wether the material disables bump or not.
  50774. * @param isFrozen defines wether the material is frozen or not.
  50775. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50776. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50777. */
  50778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50779. /**
  50780. * Checks to see if a texture is used in the material.
  50781. * @param texture - Base texture to use.
  50782. * @returns - Boolean specifying if a texture is used in the material.
  50783. */
  50784. hasTexture(texture: BaseTexture): boolean;
  50785. /**
  50786. * Returns an array of the actively used textures.
  50787. * @param activeTextures Array of BaseTextures
  50788. */
  50789. getActiveTextures(activeTextures: BaseTexture[]): void;
  50790. /**
  50791. * Returns the animatable textures.
  50792. * @param animatables Array of animatable textures.
  50793. */
  50794. getAnimatables(animatables: IAnimatable[]): void;
  50795. /**
  50796. * Disposes the resources of the material.
  50797. * @param forceDisposeTextures - Forces the disposal of all textures.
  50798. */
  50799. dispose(forceDisposeTextures?: boolean): void;
  50800. /**
  50801. * Get the current class name of the texture useful for serialization or dynamic coding.
  50802. * @returns "PBRClearCoatConfiguration"
  50803. */
  50804. getClassName(): string;
  50805. /**
  50806. * Add fallbacks to the effect fallbacks list.
  50807. * @param defines defines the Base texture to use.
  50808. * @param fallbacks defines the current fallback list.
  50809. * @param currentRank defines the current fallback rank.
  50810. * @returns the new fallback rank.
  50811. */
  50812. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50813. /**
  50814. * Add the required uniforms to the current list.
  50815. * @param uniforms defines the current uniform list.
  50816. */
  50817. static AddUniforms(uniforms: string[]): void;
  50818. /**
  50819. * Add the required samplers to the current list.
  50820. * @param samplers defines the current sampler list.
  50821. */
  50822. static AddSamplers(samplers: string[]): void;
  50823. /**
  50824. * Add the required uniforms to the current buffer.
  50825. * @param uniformBuffer defines the current uniform buffer.
  50826. */
  50827. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50828. /**
  50829. * Makes a duplicate of the current configuration into another one.
  50830. * @param clearCoatConfiguration define the config where to copy the info
  50831. */
  50832. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50833. /**
  50834. * Serializes this clear coat configuration.
  50835. * @returns - An object with the serialized config.
  50836. */
  50837. serialize(): any;
  50838. /**
  50839. * Parses a anisotropy Configuration from a serialized object.
  50840. * @param source - Serialized object.
  50841. * @param scene Defines the scene we are parsing for
  50842. * @param rootUrl Defines the rootUrl to load from
  50843. */
  50844. parse(source: any, scene: Scene, rootUrl: string): void;
  50845. }
  50846. }
  50847. declare module BABYLON {
  50848. /**
  50849. * @hidden
  50850. */
  50851. export interface IMaterialAnisotropicDefines {
  50852. ANISOTROPIC: boolean;
  50853. ANISOTROPIC_TEXTURE: boolean;
  50854. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50855. MAINUV1: boolean;
  50856. _areTexturesDirty: boolean;
  50857. _needUVs: boolean;
  50858. }
  50859. /**
  50860. * Define the code related to the anisotropic parameters of the pbr material.
  50861. */
  50862. export class PBRAnisotropicConfiguration {
  50863. private _isEnabled;
  50864. /**
  50865. * Defines if the anisotropy is enabled in the material.
  50866. */
  50867. isEnabled: boolean;
  50868. /**
  50869. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50870. */
  50871. intensity: number;
  50872. /**
  50873. * Defines if the effect is along the tangents, bitangents or in between.
  50874. * By default, the effect is "strectching" the highlights along the tangents.
  50875. */
  50876. direction: Vector2;
  50877. private _texture;
  50878. /**
  50879. * Stores the anisotropy values in a texture.
  50880. * rg is direction (like normal from -1 to 1)
  50881. * b is a intensity
  50882. */
  50883. texture: Nullable<BaseTexture>;
  50884. /** @hidden */
  50885. private _internalMarkAllSubMeshesAsTexturesDirty;
  50886. /** @hidden */
  50887. _markAllSubMeshesAsTexturesDirty(): void;
  50888. /**
  50889. * Instantiate a new istance of anisotropy configuration.
  50890. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50891. */
  50892. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50893. /**
  50894. * Specifies that the submesh is ready to be used.
  50895. * @param defines the list of "defines" to update.
  50896. * @param scene defines the scene the material belongs to.
  50897. * @returns - boolean indicating that the submesh is ready or not.
  50898. */
  50899. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50900. /**
  50901. * Checks to see if a texture is used in the material.
  50902. * @param defines the list of "defines" to update.
  50903. * @param mesh the mesh we are preparing the defines for.
  50904. * @param scene defines the scene the material belongs to.
  50905. */
  50906. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50907. /**
  50908. * Binds the material data.
  50909. * @param uniformBuffer defines the Uniform buffer to fill in.
  50910. * @param scene defines the scene the material belongs to.
  50911. * @param isFrozen defines wether the material is frozen or not.
  50912. */
  50913. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50914. /**
  50915. * Checks to see if a texture is used in the material.
  50916. * @param texture - Base texture to use.
  50917. * @returns - Boolean specifying if a texture is used in the material.
  50918. */
  50919. hasTexture(texture: BaseTexture): boolean;
  50920. /**
  50921. * Returns an array of the actively used textures.
  50922. * @param activeTextures Array of BaseTextures
  50923. */
  50924. getActiveTextures(activeTextures: BaseTexture[]): void;
  50925. /**
  50926. * Returns the animatable textures.
  50927. * @param animatables Array of animatable textures.
  50928. */
  50929. getAnimatables(animatables: IAnimatable[]): void;
  50930. /**
  50931. * Disposes the resources of the material.
  50932. * @param forceDisposeTextures - Forces the disposal of all textures.
  50933. */
  50934. dispose(forceDisposeTextures?: boolean): void;
  50935. /**
  50936. * Get the current class name of the texture useful for serialization or dynamic coding.
  50937. * @returns "PBRAnisotropicConfiguration"
  50938. */
  50939. getClassName(): string;
  50940. /**
  50941. * Add fallbacks to the effect fallbacks list.
  50942. * @param defines defines the Base texture to use.
  50943. * @param fallbacks defines the current fallback list.
  50944. * @param currentRank defines the current fallback rank.
  50945. * @returns the new fallback rank.
  50946. */
  50947. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50948. /**
  50949. * Add the required uniforms to the current list.
  50950. * @param uniforms defines the current uniform list.
  50951. */
  50952. static AddUniforms(uniforms: string[]): void;
  50953. /**
  50954. * Add the required uniforms to the current buffer.
  50955. * @param uniformBuffer defines the current uniform buffer.
  50956. */
  50957. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50958. /**
  50959. * Add the required samplers to the current list.
  50960. * @param samplers defines the current sampler list.
  50961. */
  50962. static AddSamplers(samplers: string[]): void;
  50963. /**
  50964. * Makes a duplicate of the current configuration into another one.
  50965. * @param anisotropicConfiguration define the config where to copy the info
  50966. */
  50967. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50968. /**
  50969. * Serializes this anisotropy configuration.
  50970. * @returns - An object with the serialized config.
  50971. */
  50972. serialize(): any;
  50973. /**
  50974. * Parses a anisotropy Configuration from a serialized object.
  50975. * @param source - Serialized object.
  50976. * @param scene Defines the scene we are parsing for
  50977. * @param rootUrl Defines the rootUrl to load from
  50978. */
  50979. parse(source: any, scene: Scene, rootUrl: string): void;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /**
  50984. * @hidden
  50985. */
  50986. export interface IMaterialBRDFDefines {
  50987. BRDF_V_HEIGHT_CORRELATED: boolean;
  50988. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50989. SPHERICAL_HARMONICS: boolean;
  50990. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50991. /** @hidden */
  50992. _areMiscDirty: boolean;
  50993. }
  50994. /**
  50995. * Define the code related to the BRDF parameters of the pbr material.
  50996. */
  50997. export class PBRBRDFConfiguration {
  50998. /**
  50999. * Default value used for the energy conservation.
  51000. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51001. */
  51002. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51003. /**
  51004. * Default value used for the Smith Visibility Height Correlated mode.
  51005. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51006. */
  51007. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51008. /**
  51009. * Default value used for the IBL diffuse part.
  51010. * This can help switching back to the polynomials mode globally which is a tiny bit
  51011. * less GPU intensive at the drawback of a lower quality.
  51012. */
  51013. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51014. /**
  51015. * Default value used for activating energy conservation for the specular workflow.
  51016. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51017. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51018. */
  51019. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51020. private _useEnergyConservation;
  51021. /**
  51022. * Defines if the material uses energy conservation.
  51023. */
  51024. useEnergyConservation: boolean;
  51025. private _useSmithVisibilityHeightCorrelated;
  51026. /**
  51027. * LEGACY Mode set to false
  51028. * Defines if the material uses height smith correlated visibility term.
  51029. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51030. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51031. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51032. * Not relying on height correlated will also disable energy conservation.
  51033. */
  51034. useSmithVisibilityHeightCorrelated: boolean;
  51035. private _useSphericalHarmonics;
  51036. /**
  51037. * LEGACY Mode set to false
  51038. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51039. * diffuse part of the IBL.
  51040. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51041. * to the ground truth.
  51042. */
  51043. useSphericalHarmonics: boolean;
  51044. private _useSpecularGlossinessInputEnergyConservation;
  51045. /**
  51046. * Defines if the material uses energy conservation, when the specular workflow is active.
  51047. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51048. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51049. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51050. */
  51051. useSpecularGlossinessInputEnergyConservation: boolean;
  51052. /** @hidden */
  51053. private _internalMarkAllSubMeshesAsMiscDirty;
  51054. /** @hidden */
  51055. _markAllSubMeshesAsMiscDirty(): void;
  51056. /**
  51057. * Instantiate a new istance of clear coat configuration.
  51058. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51059. */
  51060. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51061. /**
  51062. * Checks to see if a texture is used in the material.
  51063. * @param defines the list of "defines" to update.
  51064. */
  51065. prepareDefines(defines: IMaterialBRDFDefines): void;
  51066. /**
  51067. * Get the current class name of the texture useful for serialization or dynamic coding.
  51068. * @returns "PBRClearCoatConfiguration"
  51069. */
  51070. getClassName(): string;
  51071. /**
  51072. * Makes a duplicate of the current configuration into another one.
  51073. * @param brdfConfiguration define the config where to copy the info
  51074. */
  51075. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51076. /**
  51077. * Serializes this BRDF configuration.
  51078. * @returns - An object with the serialized config.
  51079. */
  51080. serialize(): any;
  51081. /**
  51082. * Parses a anisotropy Configuration from a serialized object.
  51083. * @param source - Serialized object.
  51084. * @param scene Defines the scene we are parsing for
  51085. * @param rootUrl Defines the rootUrl to load from
  51086. */
  51087. parse(source: any, scene: Scene, rootUrl: string): void;
  51088. }
  51089. }
  51090. declare module BABYLON {
  51091. /**
  51092. * @hidden
  51093. */
  51094. export interface IMaterialSheenDefines {
  51095. SHEEN: boolean;
  51096. SHEEN_TEXTURE: boolean;
  51097. SHEEN_TEXTUREDIRECTUV: number;
  51098. SHEEN_LINKWITHALBEDO: boolean;
  51099. SHEEN_ROUGHNESS: boolean;
  51100. SHEEN_ALBEDOSCALING: boolean;
  51101. /** @hidden */
  51102. _areTexturesDirty: boolean;
  51103. }
  51104. /**
  51105. * Define the code related to the Sheen parameters of the pbr material.
  51106. */
  51107. export class PBRSheenConfiguration {
  51108. private _isEnabled;
  51109. /**
  51110. * Defines if the material uses sheen.
  51111. */
  51112. isEnabled: boolean;
  51113. private _linkSheenWithAlbedo;
  51114. /**
  51115. * Defines if the sheen is linked to the sheen color.
  51116. */
  51117. linkSheenWithAlbedo: boolean;
  51118. /**
  51119. * Defines the sheen intensity.
  51120. */
  51121. intensity: number;
  51122. /**
  51123. * Defines the sheen color.
  51124. */
  51125. color: Color3;
  51126. private _texture;
  51127. /**
  51128. * Stores the sheen tint values in a texture.
  51129. * rgb is tint
  51130. * a is a intensity
  51131. */
  51132. texture: Nullable<BaseTexture>;
  51133. private _roughness;
  51134. /**
  51135. * Defines the sheen roughness.
  51136. * It is not taken into account if linkSheenWithAlbedo is true.
  51137. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  51138. */
  51139. roughness: Nullable<number>;
  51140. private _albedoScaling;
  51141. /**
  51142. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  51143. * It allows the strength of the sheen effect to not depend on the base color of the material,
  51144. * making it easier to setup and tweak the effect
  51145. */
  51146. albedoScaling: boolean;
  51147. /** @hidden */
  51148. private _internalMarkAllSubMeshesAsTexturesDirty;
  51149. /** @hidden */
  51150. _markAllSubMeshesAsTexturesDirty(): void;
  51151. /**
  51152. * Instantiate a new istance of clear coat configuration.
  51153. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51154. */
  51155. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51156. /**
  51157. * Specifies that the submesh is ready to be used.
  51158. * @param defines the list of "defines" to update.
  51159. * @param scene defines the scene the material belongs to.
  51160. * @returns - boolean indicating that the submesh is ready or not.
  51161. */
  51162. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51163. /**
  51164. * Checks to see if a texture is used in the material.
  51165. * @param defines the list of "defines" to update.
  51166. * @param scene defines the scene the material belongs to.
  51167. */
  51168. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51169. /**
  51170. * Binds the material data.
  51171. * @param uniformBuffer defines the Uniform buffer to fill in.
  51172. * @param scene defines the scene the material belongs to.
  51173. * @param isFrozen defines wether the material is frozen or not.
  51174. */
  51175. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51176. /**
  51177. * Checks to see if a texture is used in the material.
  51178. * @param texture - Base texture to use.
  51179. * @returns - Boolean specifying if a texture is used in the material.
  51180. */
  51181. hasTexture(texture: BaseTexture): boolean;
  51182. /**
  51183. * Returns an array of the actively used textures.
  51184. * @param activeTextures Array of BaseTextures
  51185. */
  51186. getActiveTextures(activeTextures: BaseTexture[]): void;
  51187. /**
  51188. * Returns the animatable textures.
  51189. * @param animatables Array of animatable textures.
  51190. */
  51191. getAnimatables(animatables: IAnimatable[]): void;
  51192. /**
  51193. * Disposes the resources of the material.
  51194. * @param forceDisposeTextures - Forces the disposal of all textures.
  51195. */
  51196. dispose(forceDisposeTextures?: boolean): void;
  51197. /**
  51198. * Get the current class name of the texture useful for serialization or dynamic coding.
  51199. * @returns "PBRSheenConfiguration"
  51200. */
  51201. getClassName(): string;
  51202. /**
  51203. * Add fallbacks to the effect fallbacks list.
  51204. * @param defines defines the Base texture to use.
  51205. * @param fallbacks defines the current fallback list.
  51206. * @param currentRank defines the current fallback rank.
  51207. * @returns the new fallback rank.
  51208. */
  51209. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51210. /**
  51211. * Add the required uniforms to the current list.
  51212. * @param uniforms defines the current uniform list.
  51213. */
  51214. static AddUniforms(uniforms: string[]): void;
  51215. /**
  51216. * Add the required uniforms to the current buffer.
  51217. * @param uniformBuffer defines the current uniform buffer.
  51218. */
  51219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51220. /**
  51221. * Add the required samplers to the current list.
  51222. * @param samplers defines the current sampler list.
  51223. */
  51224. static AddSamplers(samplers: string[]): void;
  51225. /**
  51226. * Makes a duplicate of the current configuration into another one.
  51227. * @param sheenConfiguration define the config where to copy the info
  51228. */
  51229. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51230. /**
  51231. * Serializes this BRDF configuration.
  51232. * @returns - An object with the serialized config.
  51233. */
  51234. serialize(): any;
  51235. /**
  51236. * Parses a anisotropy Configuration from a serialized object.
  51237. * @param source - Serialized object.
  51238. * @param scene Defines the scene we are parsing for
  51239. * @param rootUrl Defines the rootUrl to load from
  51240. */
  51241. parse(source: any, scene: Scene, rootUrl: string): void;
  51242. }
  51243. }
  51244. declare module BABYLON {
  51245. /**
  51246. * @hidden
  51247. */
  51248. export interface IMaterialSubSurfaceDefines {
  51249. SUBSURFACE: boolean;
  51250. SS_REFRACTION: boolean;
  51251. SS_TRANSLUCENCY: boolean;
  51252. SS_SCATERRING: boolean;
  51253. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51254. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51255. SS_REFRACTIONMAP_3D: boolean;
  51256. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51257. SS_LODINREFRACTIONALPHA: boolean;
  51258. SS_GAMMAREFRACTION: boolean;
  51259. SS_RGBDREFRACTION: boolean;
  51260. SS_LINEARSPECULARREFRACTION: boolean;
  51261. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51262. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51263. /** @hidden */
  51264. _areTexturesDirty: boolean;
  51265. }
  51266. /**
  51267. * Define the code related to the sub surface parameters of the pbr material.
  51268. */
  51269. export class PBRSubSurfaceConfiguration {
  51270. private _isRefractionEnabled;
  51271. /**
  51272. * Defines if the refraction is enabled in the material.
  51273. */
  51274. isRefractionEnabled: boolean;
  51275. private _isTranslucencyEnabled;
  51276. /**
  51277. * Defines if the translucency is enabled in the material.
  51278. */
  51279. isTranslucencyEnabled: boolean;
  51280. private _isScatteringEnabled;
  51281. /**
  51282. * Defines the refraction intensity of the material.
  51283. * The refraction when enabled replaces the Diffuse part of the material.
  51284. * The intensity helps transitionning between diffuse and refraction.
  51285. */
  51286. refractionIntensity: number;
  51287. /**
  51288. * Defines the translucency intensity of the material.
  51289. * When translucency has been enabled, this defines how much of the "translucency"
  51290. * is addded to the diffuse part of the material.
  51291. */
  51292. translucencyIntensity: number;
  51293. /**
  51294. * Defines the scattering intensity of the material.
  51295. * When scattering has been enabled, this defines how much of the "scattered light"
  51296. * is addded to the diffuse part of the material.
  51297. */
  51298. scatteringIntensity: number;
  51299. private _thicknessTexture;
  51300. /**
  51301. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51302. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51303. * 0 would mean minimumThickness
  51304. * 1 would mean maximumThickness
  51305. * The other channels might be use as a mask to vary the different effects intensity.
  51306. */
  51307. thicknessTexture: Nullable<BaseTexture>;
  51308. private _refractionTexture;
  51309. /**
  51310. * Defines the texture to use for refraction.
  51311. */
  51312. refractionTexture: Nullable<BaseTexture>;
  51313. private _indexOfRefraction;
  51314. /**
  51315. * Defines the index of refraction used in the material.
  51316. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51317. */
  51318. indexOfRefraction: number;
  51319. private _invertRefractionY;
  51320. /**
  51321. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51322. */
  51323. invertRefractionY: boolean;
  51324. private _linkRefractionWithTransparency;
  51325. /**
  51326. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51327. * Materials half opaque for instance using refraction could benefit from this control.
  51328. */
  51329. linkRefractionWithTransparency: boolean;
  51330. /**
  51331. * Defines the minimum thickness stored in the thickness map.
  51332. * If no thickness map is defined, this value will be used to simulate thickness.
  51333. */
  51334. minimumThickness: number;
  51335. /**
  51336. * Defines the maximum thickness stored in the thickness map.
  51337. */
  51338. maximumThickness: number;
  51339. /**
  51340. * Defines the volume tint of the material.
  51341. * This is used for both translucency and scattering.
  51342. */
  51343. tintColor: Color3;
  51344. /**
  51345. * Defines the distance at which the tint color should be found in the media.
  51346. * This is used for refraction only.
  51347. */
  51348. tintColorAtDistance: number;
  51349. /**
  51350. * Defines how far each channel transmit through the media.
  51351. * It is defined as a color to simplify it selection.
  51352. */
  51353. diffusionDistance: Color3;
  51354. private _useMaskFromThicknessTexture;
  51355. /**
  51356. * Stores the intensity of the different subsurface effects in the thickness texture.
  51357. * * the green channel is the translucency intensity.
  51358. * * the blue channel is the scattering intensity.
  51359. * * the alpha channel is the refraction intensity.
  51360. */
  51361. useMaskFromThicknessTexture: boolean;
  51362. /** @hidden */
  51363. private _internalMarkAllSubMeshesAsTexturesDirty;
  51364. /** @hidden */
  51365. _markAllSubMeshesAsTexturesDirty(): void;
  51366. /**
  51367. * Instantiate a new istance of sub surface configuration.
  51368. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51369. */
  51370. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51371. /**
  51372. * Gets wehter the submesh is ready to be used or not.
  51373. * @param defines the list of "defines" to update.
  51374. * @param scene defines the scene the material belongs to.
  51375. * @returns - boolean indicating that the submesh is ready or not.
  51376. */
  51377. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51378. /**
  51379. * Checks to see if a texture is used in the material.
  51380. * @param defines the list of "defines" to update.
  51381. * @param scene defines the scene to the material belongs to.
  51382. */
  51383. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51384. /**
  51385. * Binds the material data.
  51386. * @param uniformBuffer defines the Uniform buffer to fill in.
  51387. * @param scene defines the scene the material belongs to.
  51388. * @param engine defines the engine the material belongs to.
  51389. * @param isFrozen defines wether the material is frozen or not.
  51390. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51391. */
  51392. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51393. /**
  51394. * Unbinds the material from the mesh.
  51395. * @param activeEffect defines the effect that should be unbound from.
  51396. * @returns true if unbound, otherwise false
  51397. */
  51398. unbind(activeEffect: Effect): boolean;
  51399. /**
  51400. * Returns the texture used for refraction or null if none is used.
  51401. * @param scene defines the scene the material belongs to.
  51402. * @returns - Refraction texture if present. If no refraction texture and refraction
  51403. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51404. */
  51405. private _getRefractionTexture;
  51406. /**
  51407. * Returns true if alpha blending should be disabled.
  51408. */
  51409. get disableAlphaBlending(): boolean;
  51410. /**
  51411. * Fills the list of render target textures.
  51412. * @param renderTargets the list of render targets to update
  51413. */
  51414. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51415. /**
  51416. * Checks to see if a texture is used in the material.
  51417. * @param texture - Base texture to use.
  51418. * @returns - Boolean specifying if a texture is used in the material.
  51419. */
  51420. hasTexture(texture: BaseTexture): boolean;
  51421. /**
  51422. * Gets a boolean indicating that current material needs to register RTT
  51423. * @returns true if this uses a render target otherwise false.
  51424. */
  51425. hasRenderTargetTextures(): boolean;
  51426. /**
  51427. * Returns an array of the actively used textures.
  51428. * @param activeTextures Array of BaseTextures
  51429. */
  51430. getActiveTextures(activeTextures: BaseTexture[]): void;
  51431. /**
  51432. * Returns the animatable textures.
  51433. * @param animatables Array of animatable textures.
  51434. */
  51435. getAnimatables(animatables: IAnimatable[]): void;
  51436. /**
  51437. * Disposes the resources of the material.
  51438. * @param forceDisposeTextures - Forces the disposal of all textures.
  51439. */
  51440. dispose(forceDisposeTextures?: boolean): void;
  51441. /**
  51442. * Get the current class name of the texture useful for serialization or dynamic coding.
  51443. * @returns "PBRSubSurfaceConfiguration"
  51444. */
  51445. getClassName(): string;
  51446. /**
  51447. * Add fallbacks to the effect fallbacks list.
  51448. * @param defines defines the Base texture to use.
  51449. * @param fallbacks defines the current fallback list.
  51450. * @param currentRank defines the current fallback rank.
  51451. * @returns the new fallback rank.
  51452. */
  51453. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51454. /**
  51455. * Add the required uniforms to the current list.
  51456. * @param uniforms defines the current uniform list.
  51457. */
  51458. static AddUniforms(uniforms: string[]): void;
  51459. /**
  51460. * Add the required samplers to the current list.
  51461. * @param samplers defines the current sampler list.
  51462. */
  51463. static AddSamplers(samplers: string[]): void;
  51464. /**
  51465. * Add the required uniforms to the current buffer.
  51466. * @param uniformBuffer defines the current uniform buffer.
  51467. */
  51468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51469. /**
  51470. * Makes a duplicate of the current configuration into another one.
  51471. * @param configuration define the config where to copy the info
  51472. */
  51473. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51474. /**
  51475. * Serializes this Sub Surface configuration.
  51476. * @returns - An object with the serialized config.
  51477. */
  51478. serialize(): any;
  51479. /**
  51480. * Parses a anisotropy Configuration from a serialized object.
  51481. * @param source - Serialized object.
  51482. * @param scene Defines the scene we are parsing for
  51483. * @param rootUrl Defines the rootUrl to load from
  51484. */
  51485. parse(source: any, scene: Scene, rootUrl: string): void;
  51486. }
  51487. }
  51488. declare module BABYLON {
  51489. /** @hidden */
  51490. export var pbrFragmentDeclaration: {
  51491. name: string;
  51492. shader: string;
  51493. };
  51494. }
  51495. declare module BABYLON {
  51496. /** @hidden */
  51497. export var pbrUboDeclaration: {
  51498. name: string;
  51499. shader: string;
  51500. };
  51501. }
  51502. declare module BABYLON {
  51503. /** @hidden */
  51504. export var pbrFragmentExtraDeclaration: {
  51505. name: string;
  51506. shader: string;
  51507. };
  51508. }
  51509. declare module BABYLON {
  51510. /** @hidden */
  51511. export var pbrFragmentSamplersDeclaration: {
  51512. name: string;
  51513. shader: string;
  51514. };
  51515. }
  51516. declare module BABYLON {
  51517. /** @hidden */
  51518. export var pbrHelperFunctions: {
  51519. name: string;
  51520. shader: string;
  51521. };
  51522. }
  51523. declare module BABYLON {
  51524. /** @hidden */
  51525. export var harmonicsFunctions: {
  51526. name: string;
  51527. shader: string;
  51528. };
  51529. }
  51530. declare module BABYLON {
  51531. /** @hidden */
  51532. export var pbrDirectLightingSetupFunctions: {
  51533. name: string;
  51534. shader: string;
  51535. };
  51536. }
  51537. declare module BABYLON {
  51538. /** @hidden */
  51539. export var pbrDirectLightingFalloffFunctions: {
  51540. name: string;
  51541. shader: string;
  51542. };
  51543. }
  51544. declare module BABYLON {
  51545. /** @hidden */
  51546. export var pbrBRDFFunctions: {
  51547. name: string;
  51548. shader: string;
  51549. };
  51550. }
  51551. declare module BABYLON {
  51552. /** @hidden */
  51553. export var pbrDirectLightingFunctions: {
  51554. name: string;
  51555. shader: string;
  51556. };
  51557. }
  51558. declare module BABYLON {
  51559. /** @hidden */
  51560. export var pbrIBLFunctions: {
  51561. name: string;
  51562. shader: string;
  51563. };
  51564. }
  51565. declare module BABYLON {
  51566. /** @hidden */
  51567. export var pbrBlockAlbedoOpacity: {
  51568. name: string;
  51569. shader: string;
  51570. };
  51571. }
  51572. declare module BABYLON {
  51573. /** @hidden */
  51574. export var pbrBlockReflectivity: {
  51575. name: string;
  51576. shader: string;
  51577. };
  51578. }
  51579. declare module BABYLON {
  51580. /** @hidden */
  51581. export var pbrBlockAmbientOcclusion: {
  51582. name: string;
  51583. shader: string;
  51584. };
  51585. }
  51586. declare module BABYLON {
  51587. /** @hidden */
  51588. export var pbrBlockAlphaFresnel: {
  51589. name: string;
  51590. shader: string;
  51591. };
  51592. }
  51593. declare module BABYLON {
  51594. /** @hidden */
  51595. export var pbrBlockAnisotropic: {
  51596. name: string;
  51597. shader: string;
  51598. };
  51599. }
  51600. declare module BABYLON {
  51601. /** @hidden */
  51602. export var pbrBlockReflection: {
  51603. name: string;
  51604. shader: string;
  51605. };
  51606. }
  51607. declare module BABYLON {
  51608. /** @hidden */
  51609. export var pbrBlockSheen: {
  51610. name: string;
  51611. shader: string;
  51612. };
  51613. }
  51614. declare module BABYLON {
  51615. /** @hidden */
  51616. export var pbrBlockClearcoat: {
  51617. name: string;
  51618. shader: string;
  51619. };
  51620. }
  51621. declare module BABYLON {
  51622. /** @hidden */
  51623. export var pbrBlockSubSurface: {
  51624. name: string;
  51625. shader: string;
  51626. };
  51627. }
  51628. declare module BABYLON {
  51629. /** @hidden */
  51630. export var pbrBlockNormalGeometric: {
  51631. name: string;
  51632. shader: string;
  51633. };
  51634. }
  51635. declare module BABYLON {
  51636. /** @hidden */
  51637. export var pbrBlockNormalFinal: {
  51638. name: string;
  51639. shader: string;
  51640. };
  51641. }
  51642. declare module BABYLON {
  51643. /** @hidden */
  51644. export var pbrBlockGeometryInfo: {
  51645. name: string;
  51646. shader: string;
  51647. };
  51648. }
  51649. declare module BABYLON {
  51650. /** @hidden */
  51651. export var pbrBlockReflectance0: {
  51652. name: string;
  51653. shader: string;
  51654. };
  51655. }
  51656. declare module BABYLON {
  51657. /** @hidden */
  51658. export var pbrBlockReflectance: {
  51659. name: string;
  51660. shader: string;
  51661. };
  51662. }
  51663. declare module BABYLON {
  51664. /** @hidden */
  51665. export var pbrBlockDirectLighting: {
  51666. name: string;
  51667. shader: string;
  51668. };
  51669. }
  51670. declare module BABYLON {
  51671. /** @hidden */
  51672. export var pbrBlockFinalLitComponents: {
  51673. name: string;
  51674. shader: string;
  51675. };
  51676. }
  51677. declare module BABYLON {
  51678. /** @hidden */
  51679. export var pbrBlockFinalUnlitComponents: {
  51680. name: string;
  51681. shader: string;
  51682. };
  51683. }
  51684. declare module BABYLON {
  51685. /** @hidden */
  51686. export var pbrBlockFinalColorComposition: {
  51687. name: string;
  51688. shader: string;
  51689. };
  51690. }
  51691. declare module BABYLON {
  51692. /** @hidden */
  51693. export var pbrBlockImageProcessing: {
  51694. name: string;
  51695. shader: string;
  51696. };
  51697. }
  51698. declare module BABYLON {
  51699. /** @hidden */
  51700. export var pbrDebug: {
  51701. name: string;
  51702. shader: string;
  51703. };
  51704. }
  51705. declare module BABYLON {
  51706. /** @hidden */
  51707. export var pbrPixelShader: {
  51708. name: string;
  51709. shader: string;
  51710. };
  51711. }
  51712. declare module BABYLON {
  51713. /** @hidden */
  51714. export var pbrVertexDeclaration: {
  51715. name: string;
  51716. shader: string;
  51717. };
  51718. }
  51719. declare module BABYLON {
  51720. /** @hidden */
  51721. export var pbrVertexShader: {
  51722. name: string;
  51723. shader: string;
  51724. };
  51725. }
  51726. declare module BABYLON {
  51727. /**
  51728. * Manages the defines for the PBR Material.
  51729. * @hidden
  51730. */
  51731. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51732. PBR: boolean;
  51733. MAINUV1: boolean;
  51734. MAINUV2: boolean;
  51735. UV1: boolean;
  51736. UV2: boolean;
  51737. ALBEDO: boolean;
  51738. GAMMAALBEDO: boolean;
  51739. ALBEDODIRECTUV: number;
  51740. VERTEXCOLOR: boolean;
  51741. AMBIENT: boolean;
  51742. AMBIENTDIRECTUV: number;
  51743. AMBIENTINGRAYSCALE: boolean;
  51744. OPACITY: boolean;
  51745. VERTEXALPHA: boolean;
  51746. OPACITYDIRECTUV: number;
  51747. OPACITYRGB: boolean;
  51748. ALPHATEST: boolean;
  51749. DEPTHPREPASS: boolean;
  51750. ALPHABLEND: boolean;
  51751. ALPHAFROMALBEDO: boolean;
  51752. ALPHATESTVALUE: string;
  51753. SPECULAROVERALPHA: boolean;
  51754. RADIANCEOVERALPHA: boolean;
  51755. ALPHAFRESNEL: boolean;
  51756. LINEARALPHAFRESNEL: boolean;
  51757. PREMULTIPLYALPHA: boolean;
  51758. EMISSIVE: boolean;
  51759. EMISSIVEDIRECTUV: number;
  51760. REFLECTIVITY: boolean;
  51761. REFLECTIVITYDIRECTUV: number;
  51762. SPECULARTERM: boolean;
  51763. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51764. MICROSURFACEAUTOMATIC: boolean;
  51765. LODBASEDMICROSFURACE: boolean;
  51766. MICROSURFACEMAP: boolean;
  51767. MICROSURFACEMAPDIRECTUV: number;
  51768. METALLICWORKFLOW: boolean;
  51769. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51770. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51771. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51772. AOSTOREINMETALMAPRED: boolean;
  51773. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51774. ENVIRONMENTBRDF: boolean;
  51775. ENVIRONMENTBRDF_RGBD: boolean;
  51776. NORMAL: boolean;
  51777. TANGENT: boolean;
  51778. BUMP: boolean;
  51779. BUMPDIRECTUV: number;
  51780. OBJECTSPACE_NORMALMAP: boolean;
  51781. PARALLAX: boolean;
  51782. PARALLAXOCCLUSION: boolean;
  51783. NORMALXYSCALE: boolean;
  51784. LIGHTMAP: boolean;
  51785. LIGHTMAPDIRECTUV: number;
  51786. USELIGHTMAPASSHADOWMAP: boolean;
  51787. GAMMALIGHTMAP: boolean;
  51788. RGBDLIGHTMAP: boolean;
  51789. REFLECTION: boolean;
  51790. REFLECTIONMAP_3D: boolean;
  51791. REFLECTIONMAP_SPHERICAL: boolean;
  51792. REFLECTIONMAP_PLANAR: boolean;
  51793. REFLECTIONMAP_CUBIC: boolean;
  51794. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51795. REFLECTIONMAP_PROJECTION: boolean;
  51796. REFLECTIONMAP_SKYBOX: boolean;
  51797. REFLECTIONMAP_EXPLICIT: boolean;
  51798. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51799. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51800. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51801. INVERTCUBICMAP: boolean;
  51802. USESPHERICALFROMREFLECTIONMAP: boolean;
  51803. USEIRRADIANCEMAP: boolean;
  51804. SPHERICAL_HARMONICS: boolean;
  51805. USESPHERICALINVERTEX: boolean;
  51806. REFLECTIONMAP_OPPOSITEZ: boolean;
  51807. LODINREFLECTIONALPHA: boolean;
  51808. GAMMAREFLECTION: boolean;
  51809. RGBDREFLECTION: boolean;
  51810. LINEARSPECULARREFLECTION: boolean;
  51811. RADIANCEOCCLUSION: boolean;
  51812. HORIZONOCCLUSION: boolean;
  51813. INSTANCES: boolean;
  51814. NUM_BONE_INFLUENCERS: number;
  51815. BonesPerMesh: number;
  51816. BONETEXTURE: boolean;
  51817. NONUNIFORMSCALING: boolean;
  51818. MORPHTARGETS: boolean;
  51819. MORPHTARGETS_NORMAL: boolean;
  51820. MORPHTARGETS_TANGENT: boolean;
  51821. MORPHTARGETS_UV: boolean;
  51822. NUM_MORPH_INFLUENCERS: number;
  51823. IMAGEPROCESSING: boolean;
  51824. VIGNETTE: boolean;
  51825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51826. VIGNETTEBLENDMODEOPAQUE: boolean;
  51827. TONEMAPPING: boolean;
  51828. TONEMAPPING_ACES: boolean;
  51829. CONTRAST: boolean;
  51830. COLORCURVES: boolean;
  51831. COLORGRADING: boolean;
  51832. COLORGRADING3D: boolean;
  51833. SAMPLER3DGREENDEPTH: boolean;
  51834. SAMPLER3DBGRMAP: boolean;
  51835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51836. EXPOSURE: boolean;
  51837. MULTIVIEW: boolean;
  51838. USEPHYSICALLIGHTFALLOFF: boolean;
  51839. USEGLTFLIGHTFALLOFF: boolean;
  51840. TWOSIDEDLIGHTING: boolean;
  51841. SHADOWFLOAT: boolean;
  51842. CLIPPLANE: boolean;
  51843. CLIPPLANE2: boolean;
  51844. CLIPPLANE3: boolean;
  51845. CLIPPLANE4: boolean;
  51846. CLIPPLANE5: boolean;
  51847. CLIPPLANE6: boolean;
  51848. POINTSIZE: boolean;
  51849. FOG: boolean;
  51850. LOGARITHMICDEPTH: boolean;
  51851. FORCENORMALFORWARD: boolean;
  51852. SPECULARAA: boolean;
  51853. CLEARCOAT: boolean;
  51854. CLEARCOAT_DEFAULTIOR: boolean;
  51855. CLEARCOAT_TEXTURE: boolean;
  51856. CLEARCOAT_TEXTUREDIRECTUV: number;
  51857. CLEARCOAT_BUMP: boolean;
  51858. CLEARCOAT_BUMPDIRECTUV: number;
  51859. CLEARCOAT_TINT: boolean;
  51860. CLEARCOAT_TINT_TEXTURE: boolean;
  51861. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51862. ANISOTROPIC: boolean;
  51863. ANISOTROPIC_TEXTURE: boolean;
  51864. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51865. BRDF_V_HEIGHT_CORRELATED: boolean;
  51866. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51867. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51868. SHEEN: boolean;
  51869. SHEEN_TEXTURE: boolean;
  51870. SHEEN_TEXTUREDIRECTUV: number;
  51871. SHEEN_LINKWITHALBEDO: boolean;
  51872. SHEEN_ROUGHNESS: boolean;
  51873. SHEEN_ALBEDOSCALING: boolean;
  51874. SUBSURFACE: boolean;
  51875. SS_REFRACTION: boolean;
  51876. SS_TRANSLUCENCY: boolean;
  51877. SS_SCATERRING: boolean;
  51878. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51879. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51880. SS_REFRACTIONMAP_3D: boolean;
  51881. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51882. SS_LODINREFRACTIONALPHA: boolean;
  51883. SS_GAMMAREFRACTION: boolean;
  51884. SS_RGBDREFRACTION: boolean;
  51885. SS_LINEARSPECULARREFRACTION: boolean;
  51886. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51887. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51888. UNLIT: boolean;
  51889. DEBUGMODE: number;
  51890. /**
  51891. * Initializes the PBR Material defines.
  51892. */
  51893. constructor();
  51894. /**
  51895. * Resets the PBR Material defines.
  51896. */
  51897. reset(): void;
  51898. }
  51899. /**
  51900. * The Physically based material base class of BJS.
  51901. *
  51902. * This offers the main features of a standard PBR material.
  51903. * For more information, please refer to the documentation :
  51904. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51905. */
  51906. export abstract class PBRBaseMaterial extends PushMaterial {
  51907. /**
  51908. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51909. */
  51910. static readonly PBRMATERIAL_OPAQUE: number;
  51911. /**
  51912. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51913. */
  51914. static readonly PBRMATERIAL_ALPHATEST: number;
  51915. /**
  51916. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51917. */
  51918. static readonly PBRMATERIAL_ALPHABLEND: number;
  51919. /**
  51920. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51921. * They are also discarded below the alpha cutoff threshold to improve performances.
  51922. */
  51923. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51924. /**
  51925. * Defines the default value of how much AO map is occluding the analytical lights
  51926. * (point spot...).
  51927. */
  51928. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51929. /**
  51930. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51931. */
  51932. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51933. /**
  51934. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51935. * to enhance interoperability with other engines.
  51936. */
  51937. static readonly LIGHTFALLOFF_GLTF: number;
  51938. /**
  51939. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51940. * to enhance interoperability with other materials.
  51941. */
  51942. static readonly LIGHTFALLOFF_STANDARD: number;
  51943. /**
  51944. * Intensity of the direct lights e.g. the four lights available in your scene.
  51945. * This impacts both the direct diffuse and specular highlights.
  51946. */
  51947. protected _directIntensity: number;
  51948. /**
  51949. * Intensity of the emissive part of the material.
  51950. * This helps controlling the emissive effect without modifying the emissive color.
  51951. */
  51952. protected _emissiveIntensity: number;
  51953. /**
  51954. * Intensity of the environment e.g. how much the environment will light the object
  51955. * either through harmonics for rough material or through the refelction for shiny ones.
  51956. */
  51957. protected _environmentIntensity: number;
  51958. /**
  51959. * This is a special control allowing the reduction of the specular highlights coming from the
  51960. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51961. */
  51962. protected _specularIntensity: number;
  51963. /**
  51964. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51965. */
  51966. private _lightingInfos;
  51967. /**
  51968. * Debug Control allowing disabling the bump map on this material.
  51969. */
  51970. protected _disableBumpMap: boolean;
  51971. /**
  51972. * AKA Diffuse Texture in standard nomenclature.
  51973. */
  51974. protected _albedoTexture: Nullable<BaseTexture>;
  51975. /**
  51976. * AKA Occlusion Texture in other nomenclature.
  51977. */
  51978. protected _ambientTexture: Nullable<BaseTexture>;
  51979. /**
  51980. * AKA Occlusion Texture Intensity in other nomenclature.
  51981. */
  51982. protected _ambientTextureStrength: number;
  51983. /**
  51984. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51985. * 1 means it completely occludes it
  51986. * 0 mean it has no impact
  51987. */
  51988. protected _ambientTextureImpactOnAnalyticalLights: number;
  51989. /**
  51990. * Stores the alpha values in a texture.
  51991. */
  51992. protected _opacityTexture: Nullable<BaseTexture>;
  51993. /**
  51994. * Stores the reflection values in a texture.
  51995. */
  51996. protected _reflectionTexture: Nullable<BaseTexture>;
  51997. /**
  51998. * Stores the emissive values in a texture.
  51999. */
  52000. protected _emissiveTexture: Nullable<BaseTexture>;
  52001. /**
  52002. * AKA Specular texture in other nomenclature.
  52003. */
  52004. protected _reflectivityTexture: Nullable<BaseTexture>;
  52005. /**
  52006. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52007. */
  52008. protected _metallicTexture: Nullable<BaseTexture>;
  52009. /**
  52010. * Specifies the metallic scalar of the metallic/roughness workflow.
  52011. * Can also be used to scale the metalness values of the metallic texture.
  52012. */
  52013. protected _metallic: Nullable<number>;
  52014. /**
  52015. * Specifies the roughness scalar of the metallic/roughness workflow.
  52016. * Can also be used to scale the roughness values of the metallic texture.
  52017. */
  52018. protected _roughness: Nullable<number>;
  52019. /**
  52020. * Specifies the an F0 factor to help configuring the material F0.
  52021. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52022. * to 0.5 the previously hard coded value stays the same.
  52023. * Can also be used to scale the F0 values of the metallic texture.
  52024. */
  52025. protected _metallicF0Factor: number;
  52026. /**
  52027. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52028. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52029. * your expectation as it multiplies with the texture data.
  52030. */
  52031. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52032. /**
  52033. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52034. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52035. */
  52036. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52037. /**
  52038. * Stores surface normal data used to displace a mesh in a texture.
  52039. */
  52040. protected _bumpTexture: Nullable<BaseTexture>;
  52041. /**
  52042. * Stores the pre-calculated light information of a mesh in a texture.
  52043. */
  52044. protected _lightmapTexture: Nullable<BaseTexture>;
  52045. /**
  52046. * The color of a material in ambient lighting.
  52047. */
  52048. protected _ambientColor: Color3;
  52049. /**
  52050. * AKA Diffuse Color in other nomenclature.
  52051. */
  52052. protected _albedoColor: Color3;
  52053. /**
  52054. * AKA Specular Color in other nomenclature.
  52055. */
  52056. protected _reflectivityColor: Color3;
  52057. /**
  52058. * The color applied when light is reflected from a material.
  52059. */
  52060. protected _reflectionColor: Color3;
  52061. /**
  52062. * The color applied when light is emitted from a material.
  52063. */
  52064. protected _emissiveColor: Color3;
  52065. /**
  52066. * AKA Glossiness in other nomenclature.
  52067. */
  52068. protected _microSurface: number;
  52069. /**
  52070. * Specifies that the material will use the light map as a show map.
  52071. */
  52072. protected _useLightmapAsShadowmap: boolean;
  52073. /**
  52074. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52075. * makes the reflect vector face the model (under horizon).
  52076. */
  52077. protected _useHorizonOcclusion: boolean;
  52078. /**
  52079. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52080. * too much the area relying on ambient texture to define their ambient occlusion.
  52081. */
  52082. protected _useRadianceOcclusion: boolean;
  52083. /**
  52084. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52085. */
  52086. protected _useAlphaFromAlbedoTexture: boolean;
  52087. /**
  52088. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52089. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52090. */
  52091. protected _useSpecularOverAlpha: boolean;
  52092. /**
  52093. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52094. */
  52095. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52096. /**
  52097. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52098. */
  52099. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52100. /**
  52101. * Specifies if the metallic texture contains the roughness information in its green channel.
  52102. */
  52103. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52104. /**
  52105. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52106. */
  52107. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52108. /**
  52109. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52110. */
  52111. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52112. /**
  52113. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52114. */
  52115. protected _useAmbientInGrayScale: boolean;
  52116. /**
  52117. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52118. * The material will try to infer what glossiness each pixel should be.
  52119. */
  52120. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52121. /**
  52122. * Defines the falloff type used in this material.
  52123. * It by default is Physical.
  52124. */
  52125. protected _lightFalloff: number;
  52126. /**
  52127. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52128. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52129. */
  52130. protected _useRadianceOverAlpha: boolean;
  52131. /**
  52132. * Allows using an object space normal map (instead of tangent space).
  52133. */
  52134. protected _useObjectSpaceNormalMap: boolean;
  52135. /**
  52136. * Allows using the bump map in parallax mode.
  52137. */
  52138. protected _useParallax: boolean;
  52139. /**
  52140. * Allows using the bump map in parallax occlusion mode.
  52141. */
  52142. protected _useParallaxOcclusion: boolean;
  52143. /**
  52144. * Controls the scale bias of the parallax mode.
  52145. */
  52146. protected _parallaxScaleBias: number;
  52147. /**
  52148. * If sets to true, disables all the lights affecting the material.
  52149. */
  52150. protected _disableLighting: boolean;
  52151. /**
  52152. * Number of Simultaneous lights allowed on the material.
  52153. */
  52154. protected _maxSimultaneousLights: number;
  52155. /**
  52156. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52157. */
  52158. protected _invertNormalMapX: boolean;
  52159. /**
  52160. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52161. */
  52162. protected _invertNormalMapY: boolean;
  52163. /**
  52164. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52165. */
  52166. protected _twoSidedLighting: boolean;
  52167. /**
  52168. * Defines the alpha limits in alpha test mode.
  52169. */
  52170. protected _alphaCutOff: number;
  52171. /**
  52172. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52173. */
  52174. protected _forceAlphaTest: boolean;
  52175. /**
  52176. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52177. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52178. */
  52179. protected _useAlphaFresnel: boolean;
  52180. /**
  52181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52182. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52183. */
  52184. protected _useLinearAlphaFresnel: boolean;
  52185. /**
  52186. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52187. * from cos thetav and roughness:
  52188. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52189. */
  52190. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52191. /**
  52192. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52193. */
  52194. protected _forceIrradianceInFragment: boolean;
  52195. /**
  52196. * Force normal to face away from face.
  52197. */
  52198. protected _forceNormalForward: boolean;
  52199. /**
  52200. * Enables specular anti aliasing in the PBR shader.
  52201. * It will both interacts on the Geometry for analytical and IBL lighting.
  52202. * It also prefilter the roughness map based on the bump values.
  52203. */
  52204. protected _enableSpecularAntiAliasing: boolean;
  52205. /**
  52206. * Default configuration related to image processing available in the PBR Material.
  52207. */
  52208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52209. /**
  52210. * Keep track of the image processing observer to allow dispose and replace.
  52211. */
  52212. private _imageProcessingObserver;
  52213. /**
  52214. * Attaches a new image processing configuration to the PBR Material.
  52215. * @param configuration
  52216. */
  52217. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52218. /**
  52219. * Stores the available render targets.
  52220. */
  52221. private _renderTargets;
  52222. /**
  52223. * Sets the global ambient color for the material used in lighting calculations.
  52224. */
  52225. private _globalAmbientColor;
  52226. /**
  52227. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52228. */
  52229. private _useLogarithmicDepth;
  52230. /**
  52231. * If set to true, no lighting calculations will be applied.
  52232. */
  52233. private _unlit;
  52234. private _debugMode;
  52235. /**
  52236. * @hidden
  52237. * This is reserved for the inspector.
  52238. * Defines the material debug mode.
  52239. * It helps seeing only some components of the material while troubleshooting.
  52240. */
  52241. debugMode: number;
  52242. /**
  52243. * @hidden
  52244. * This is reserved for the inspector.
  52245. * Specify from where on screen the debug mode should start.
  52246. * The value goes from -1 (full screen) to 1 (not visible)
  52247. * It helps with side by side comparison against the final render
  52248. * This defaults to -1
  52249. */
  52250. private debugLimit;
  52251. /**
  52252. * @hidden
  52253. * This is reserved for the inspector.
  52254. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52255. * You can use the factor to better multiply the final value.
  52256. */
  52257. private debugFactor;
  52258. /**
  52259. * Defines the clear coat layer parameters for the material.
  52260. */
  52261. readonly clearCoat: PBRClearCoatConfiguration;
  52262. /**
  52263. * Defines the anisotropic parameters for the material.
  52264. */
  52265. readonly anisotropy: PBRAnisotropicConfiguration;
  52266. /**
  52267. * Defines the BRDF parameters for the material.
  52268. */
  52269. readonly brdf: PBRBRDFConfiguration;
  52270. /**
  52271. * Defines the Sheen parameters for the material.
  52272. */
  52273. readonly sheen: PBRSheenConfiguration;
  52274. /**
  52275. * Defines the SubSurface parameters for the material.
  52276. */
  52277. readonly subSurface: PBRSubSurfaceConfiguration;
  52278. protected _rebuildInParallel: boolean;
  52279. /**
  52280. * Instantiates a new PBRMaterial instance.
  52281. *
  52282. * @param name The material name
  52283. * @param scene The scene the material will be use in.
  52284. */
  52285. constructor(name: string, scene: Scene);
  52286. /**
  52287. * Gets a boolean indicating that current material needs to register RTT
  52288. */
  52289. get hasRenderTargetTextures(): boolean;
  52290. /**
  52291. * Gets the name of the material class.
  52292. */
  52293. getClassName(): string;
  52294. /**
  52295. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52296. */
  52297. get useLogarithmicDepth(): boolean;
  52298. /**
  52299. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52300. */
  52301. set useLogarithmicDepth(value: boolean);
  52302. /**
  52303. * Returns true if alpha blending should be disabled.
  52304. */
  52305. protected get _disableAlphaBlending(): boolean;
  52306. /**
  52307. * Specifies whether or not this material should be rendered in alpha blend mode.
  52308. */
  52309. needAlphaBlending(): boolean;
  52310. /**
  52311. * Specifies whether or not this material should be rendered in alpha test mode.
  52312. */
  52313. needAlphaTesting(): boolean;
  52314. /**
  52315. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52316. */
  52317. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52318. /**
  52319. * Gets the texture used for the alpha test.
  52320. */
  52321. getAlphaTestTexture(): Nullable<BaseTexture>;
  52322. /**
  52323. * Specifies that the submesh is ready to be used.
  52324. * @param mesh - BJS mesh.
  52325. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52326. * @param useInstances - Specifies that instances should be used.
  52327. * @returns - boolean indicating that the submesh is ready or not.
  52328. */
  52329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52330. /**
  52331. * Specifies if the material uses metallic roughness workflow.
  52332. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52333. */
  52334. isMetallicWorkflow(): boolean;
  52335. private _prepareEffect;
  52336. private _prepareDefines;
  52337. /**
  52338. * Force shader compilation
  52339. */
  52340. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52341. /**
  52342. * Initializes the uniform buffer layout for the shader.
  52343. */
  52344. buildUniformLayout(): void;
  52345. /**
  52346. * Unbinds the material from the mesh
  52347. */
  52348. unbind(): void;
  52349. /**
  52350. * Binds the submesh data.
  52351. * @param world - The world matrix.
  52352. * @param mesh - The BJS mesh.
  52353. * @param subMesh - A submesh of the BJS mesh.
  52354. */
  52355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52356. /**
  52357. * Returns the animatable textures.
  52358. * @returns - Array of animatable textures.
  52359. */
  52360. getAnimatables(): IAnimatable[];
  52361. /**
  52362. * Returns the texture used for reflections.
  52363. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52364. */
  52365. private _getReflectionTexture;
  52366. /**
  52367. * Returns an array of the actively used textures.
  52368. * @returns - Array of BaseTextures
  52369. */
  52370. getActiveTextures(): BaseTexture[];
  52371. /**
  52372. * Checks to see if a texture is used in the material.
  52373. * @param texture - Base texture to use.
  52374. * @returns - Boolean specifying if a texture is used in the material.
  52375. */
  52376. hasTexture(texture: BaseTexture): boolean;
  52377. /**
  52378. * Disposes the resources of the material.
  52379. * @param forceDisposeEffect - Forces the disposal of effects.
  52380. * @param forceDisposeTextures - Forces the disposal of all textures.
  52381. */
  52382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52383. }
  52384. }
  52385. declare module BABYLON {
  52386. /**
  52387. * The Physically based material of BJS.
  52388. *
  52389. * This offers the main features of a standard PBR material.
  52390. * For more information, please refer to the documentation :
  52391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52392. */
  52393. export class PBRMaterial extends PBRBaseMaterial {
  52394. /**
  52395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52396. */
  52397. static readonly PBRMATERIAL_OPAQUE: number;
  52398. /**
  52399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52400. */
  52401. static readonly PBRMATERIAL_ALPHATEST: number;
  52402. /**
  52403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52404. */
  52405. static readonly PBRMATERIAL_ALPHABLEND: number;
  52406. /**
  52407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52408. * They are also discarded below the alpha cutoff threshold to improve performances.
  52409. */
  52410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52411. /**
  52412. * Defines the default value of how much AO map is occluding the analytical lights
  52413. * (point spot...).
  52414. */
  52415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52416. /**
  52417. * Intensity of the direct lights e.g. the four lights available in your scene.
  52418. * This impacts both the direct diffuse and specular highlights.
  52419. */
  52420. directIntensity: number;
  52421. /**
  52422. * Intensity of the emissive part of the material.
  52423. * This helps controlling the emissive effect without modifying the emissive color.
  52424. */
  52425. emissiveIntensity: number;
  52426. /**
  52427. * Intensity of the environment e.g. how much the environment will light the object
  52428. * either through harmonics for rough material or through the refelction for shiny ones.
  52429. */
  52430. environmentIntensity: number;
  52431. /**
  52432. * This is a special control allowing the reduction of the specular highlights coming from the
  52433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52434. */
  52435. specularIntensity: number;
  52436. /**
  52437. * Debug Control allowing disabling the bump map on this material.
  52438. */
  52439. disableBumpMap: boolean;
  52440. /**
  52441. * AKA Diffuse Texture in standard nomenclature.
  52442. */
  52443. albedoTexture: BaseTexture;
  52444. /**
  52445. * AKA Occlusion Texture in other nomenclature.
  52446. */
  52447. ambientTexture: BaseTexture;
  52448. /**
  52449. * AKA Occlusion Texture Intensity in other nomenclature.
  52450. */
  52451. ambientTextureStrength: number;
  52452. /**
  52453. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52454. * 1 means it completely occludes it
  52455. * 0 mean it has no impact
  52456. */
  52457. ambientTextureImpactOnAnalyticalLights: number;
  52458. /**
  52459. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52460. */
  52461. opacityTexture: BaseTexture;
  52462. /**
  52463. * Stores the reflection values in a texture.
  52464. */
  52465. reflectionTexture: Nullable<BaseTexture>;
  52466. /**
  52467. * Stores the emissive values in a texture.
  52468. */
  52469. emissiveTexture: BaseTexture;
  52470. /**
  52471. * AKA Specular texture in other nomenclature.
  52472. */
  52473. reflectivityTexture: BaseTexture;
  52474. /**
  52475. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52476. */
  52477. metallicTexture: BaseTexture;
  52478. /**
  52479. * Specifies the metallic scalar of the metallic/roughness workflow.
  52480. * Can also be used to scale the metalness values of the metallic texture.
  52481. */
  52482. metallic: Nullable<number>;
  52483. /**
  52484. * Specifies the roughness scalar of the metallic/roughness workflow.
  52485. * Can also be used to scale the roughness values of the metallic texture.
  52486. */
  52487. roughness: Nullable<number>;
  52488. /**
  52489. * Specifies the an F0 factor to help configuring the material F0.
  52490. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52491. * to 0.5 the previously hard coded value stays the same.
  52492. * Can also be used to scale the F0 values of the metallic texture.
  52493. */
  52494. metallicF0Factor: number;
  52495. /**
  52496. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52497. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52498. * your expectation as it multiplies with the texture data.
  52499. */
  52500. useMetallicF0FactorFromMetallicTexture: boolean;
  52501. /**
  52502. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52503. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52504. */
  52505. microSurfaceTexture: BaseTexture;
  52506. /**
  52507. * Stores surface normal data used to displace a mesh in a texture.
  52508. */
  52509. bumpTexture: BaseTexture;
  52510. /**
  52511. * Stores the pre-calculated light information of a mesh in a texture.
  52512. */
  52513. lightmapTexture: BaseTexture;
  52514. /**
  52515. * Stores the refracted light information in a texture.
  52516. */
  52517. get refractionTexture(): Nullable<BaseTexture>;
  52518. set refractionTexture(value: Nullable<BaseTexture>);
  52519. /**
  52520. * The color of a material in ambient lighting.
  52521. */
  52522. ambientColor: Color3;
  52523. /**
  52524. * AKA Diffuse Color in other nomenclature.
  52525. */
  52526. albedoColor: Color3;
  52527. /**
  52528. * AKA Specular Color in other nomenclature.
  52529. */
  52530. reflectivityColor: Color3;
  52531. /**
  52532. * The color reflected from the material.
  52533. */
  52534. reflectionColor: Color3;
  52535. /**
  52536. * The color emitted from the material.
  52537. */
  52538. emissiveColor: Color3;
  52539. /**
  52540. * AKA Glossiness in other nomenclature.
  52541. */
  52542. microSurface: number;
  52543. /**
  52544. * source material index of refraction (IOR)' / 'destination material IOR.
  52545. */
  52546. get indexOfRefraction(): number;
  52547. set indexOfRefraction(value: number);
  52548. /**
  52549. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52550. */
  52551. get invertRefractionY(): boolean;
  52552. set invertRefractionY(value: boolean);
  52553. /**
  52554. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52555. * Materials half opaque for instance using refraction could benefit from this control.
  52556. */
  52557. get linkRefractionWithTransparency(): boolean;
  52558. set linkRefractionWithTransparency(value: boolean);
  52559. /**
  52560. * If true, the light map contains occlusion information instead of lighting info.
  52561. */
  52562. useLightmapAsShadowmap: boolean;
  52563. /**
  52564. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52565. */
  52566. useAlphaFromAlbedoTexture: boolean;
  52567. /**
  52568. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52569. */
  52570. forceAlphaTest: boolean;
  52571. /**
  52572. * Defines the alpha limits in alpha test mode.
  52573. */
  52574. alphaCutOff: number;
  52575. /**
  52576. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52577. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52578. */
  52579. useSpecularOverAlpha: boolean;
  52580. /**
  52581. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52582. */
  52583. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52584. /**
  52585. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52586. */
  52587. useRoughnessFromMetallicTextureAlpha: boolean;
  52588. /**
  52589. * Specifies if the metallic texture contains the roughness information in its green channel.
  52590. */
  52591. useRoughnessFromMetallicTextureGreen: boolean;
  52592. /**
  52593. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52594. */
  52595. useMetallnessFromMetallicTextureBlue: boolean;
  52596. /**
  52597. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52598. */
  52599. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52600. /**
  52601. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52602. */
  52603. useAmbientInGrayScale: boolean;
  52604. /**
  52605. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52606. * The material will try to infer what glossiness each pixel should be.
  52607. */
  52608. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52609. /**
  52610. * BJS is using an harcoded light falloff based on a manually sets up range.
  52611. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52612. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52613. */
  52614. get usePhysicalLightFalloff(): boolean;
  52615. /**
  52616. * BJS is using an harcoded light falloff based on a manually sets up range.
  52617. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52618. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52619. */
  52620. set usePhysicalLightFalloff(value: boolean);
  52621. /**
  52622. * In order to support the falloff compatibility with gltf, a special mode has been added
  52623. * to reproduce the gltf light falloff.
  52624. */
  52625. get useGLTFLightFalloff(): boolean;
  52626. /**
  52627. * In order to support the falloff compatibility with gltf, a special mode has been added
  52628. * to reproduce the gltf light falloff.
  52629. */
  52630. set useGLTFLightFalloff(value: boolean);
  52631. /**
  52632. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52633. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52634. */
  52635. useRadianceOverAlpha: boolean;
  52636. /**
  52637. * Allows using an object space normal map (instead of tangent space).
  52638. */
  52639. useObjectSpaceNormalMap: boolean;
  52640. /**
  52641. * Allows using the bump map in parallax mode.
  52642. */
  52643. useParallax: boolean;
  52644. /**
  52645. * Allows using the bump map in parallax occlusion mode.
  52646. */
  52647. useParallaxOcclusion: boolean;
  52648. /**
  52649. * Controls the scale bias of the parallax mode.
  52650. */
  52651. parallaxScaleBias: number;
  52652. /**
  52653. * If sets to true, disables all the lights affecting the material.
  52654. */
  52655. disableLighting: boolean;
  52656. /**
  52657. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52658. */
  52659. forceIrradianceInFragment: boolean;
  52660. /**
  52661. * Number of Simultaneous lights allowed on the material.
  52662. */
  52663. maxSimultaneousLights: number;
  52664. /**
  52665. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52666. */
  52667. invertNormalMapX: boolean;
  52668. /**
  52669. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52670. */
  52671. invertNormalMapY: boolean;
  52672. /**
  52673. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52674. */
  52675. twoSidedLighting: boolean;
  52676. /**
  52677. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52678. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52679. */
  52680. useAlphaFresnel: boolean;
  52681. /**
  52682. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52683. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52684. */
  52685. useLinearAlphaFresnel: boolean;
  52686. /**
  52687. * Let user defines the brdf lookup texture used for IBL.
  52688. * A default 8bit version is embedded but you could point at :
  52689. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52690. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52691. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52692. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52693. */
  52694. environmentBRDFTexture: Nullable<BaseTexture>;
  52695. /**
  52696. * Force normal to face away from face.
  52697. */
  52698. forceNormalForward: boolean;
  52699. /**
  52700. * Enables specular anti aliasing in the PBR shader.
  52701. * It will both interacts on the Geometry for analytical and IBL lighting.
  52702. * It also prefilter the roughness map based on the bump values.
  52703. */
  52704. enableSpecularAntiAliasing: boolean;
  52705. /**
  52706. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52707. * makes the reflect vector face the model (under horizon).
  52708. */
  52709. useHorizonOcclusion: boolean;
  52710. /**
  52711. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52712. * too much the area relying on ambient texture to define their ambient occlusion.
  52713. */
  52714. useRadianceOcclusion: boolean;
  52715. /**
  52716. * If set to true, no lighting calculations will be applied.
  52717. */
  52718. unlit: boolean;
  52719. /**
  52720. * Gets the image processing configuration used either in this material.
  52721. */
  52722. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52723. /**
  52724. * Sets the Default image processing configuration used either in the this material.
  52725. *
  52726. * If sets to null, the scene one is in use.
  52727. */
  52728. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52729. /**
  52730. * Gets wether the color curves effect is enabled.
  52731. */
  52732. get cameraColorCurvesEnabled(): boolean;
  52733. /**
  52734. * Sets wether the color curves effect is enabled.
  52735. */
  52736. set cameraColorCurvesEnabled(value: boolean);
  52737. /**
  52738. * Gets wether the color grading effect is enabled.
  52739. */
  52740. get cameraColorGradingEnabled(): boolean;
  52741. /**
  52742. * Gets wether the color grading effect is enabled.
  52743. */
  52744. set cameraColorGradingEnabled(value: boolean);
  52745. /**
  52746. * Gets wether tonemapping is enabled or not.
  52747. */
  52748. get cameraToneMappingEnabled(): boolean;
  52749. /**
  52750. * Sets wether tonemapping is enabled or not
  52751. */
  52752. set cameraToneMappingEnabled(value: boolean);
  52753. /**
  52754. * The camera exposure used on this material.
  52755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52756. * This corresponds to a photographic exposure.
  52757. */
  52758. get cameraExposure(): number;
  52759. /**
  52760. * The camera exposure used on this material.
  52761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52762. * This corresponds to a photographic exposure.
  52763. */
  52764. set cameraExposure(value: number);
  52765. /**
  52766. * Gets The camera contrast used on this material.
  52767. */
  52768. get cameraContrast(): number;
  52769. /**
  52770. * Sets The camera contrast used on this material.
  52771. */
  52772. set cameraContrast(value: number);
  52773. /**
  52774. * Gets the Color Grading 2D Lookup Texture.
  52775. */
  52776. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52777. /**
  52778. * Sets the Color Grading 2D Lookup Texture.
  52779. */
  52780. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52781. /**
  52782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52784. * 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;
  52785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52786. */
  52787. get cameraColorCurves(): Nullable<ColorCurves>;
  52788. /**
  52789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52791. * 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;
  52792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52793. */
  52794. set cameraColorCurves(value: Nullable<ColorCurves>);
  52795. /**
  52796. * Instantiates a new PBRMaterial instance.
  52797. *
  52798. * @param name The material name
  52799. * @param scene The scene the material will be use in.
  52800. */
  52801. constructor(name: string, scene: Scene);
  52802. /**
  52803. * Returns the name of this material class.
  52804. */
  52805. getClassName(): string;
  52806. /**
  52807. * Makes a duplicate of the current material.
  52808. * @param name - name to use for the new material.
  52809. */
  52810. clone(name: string): PBRMaterial;
  52811. /**
  52812. * Serializes this PBR Material.
  52813. * @returns - An object with the serialized material.
  52814. */
  52815. serialize(): any;
  52816. /**
  52817. * Parses a PBR Material from a serialized object.
  52818. * @param source - Serialized object.
  52819. * @param scene - BJS scene instance.
  52820. * @param rootUrl - url for the scene object
  52821. * @returns - PBRMaterial
  52822. */
  52823. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52824. }
  52825. }
  52826. declare module BABYLON {
  52827. /**
  52828. * Direct draw surface info
  52829. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52830. */
  52831. export interface DDSInfo {
  52832. /**
  52833. * Width of the texture
  52834. */
  52835. width: number;
  52836. /**
  52837. * Width of the texture
  52838. */
  52839. height: number;
  52840. /**
  52841. * Number of Mipmaps for the texture
  52842. * @see https://en.wikipedia.org/wiki/Mipmap
  52843. */
  52844. mipmapCount: number;
  52845. /**
  52846. * If the textures format is a known fourCC format
  52847. * @see https://www.fourcc.org/
  52848. */
  52849. isFourCC: boolean;
  52850. /**
  52851. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52852. */
  52853. isRGB: boolean;
  52854. /**
  52855. * If the texture is a lumincance format
  52856. */
  52857. isLuminance: boolean;
  52858. /**
  52859. * If this is a cube texture
  52860. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52861. */
  52862. isCube: boolean;
  52863. /**
  52864. * If the texture is a compressed format eg. FOURCC_DXT1
  52865. */
  52866. isCompressed: boolean;
  52867. /**
  52868. * The dxgiFormat of the texture
  52869. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52870. */
  52871. dxgiFormat: number;
  52872. /**
  52873. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52874. */
  52875. textureType: number;
  52876. /**
  52877. * Sphericle polynomial created for the dds texture
  52878. */
  52879. sphericalPolynomial?: SphericalPolynomial;
  52880. }
  52881. /**
  52882. * Class used to provide DDS decompression tools
  52883. */
  52884. export class DDSTools {
  52885. /**
  52886. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52887. */
  52888. static StoreLODInAlphaChannel: boolean;
  52889. /**
  52890. * Gets DDS information from an array buffer
  52891. * @param data defines the array buffer view to read data from
  52892. * @returns the DDS information
  52893. */
  52894. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52895. private static _FloatView;
  52896. private static _Int32View;
  52897. private static _ToHalfFloat;
  52898. private static _FromHalfFloat;
  52899. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52900. private static _GetHalfFloatRGBAArrayBuffer;
  52901. private static _GetFloatRGBAArrayBuffer;
  52902. private static _GetFloatAsUIntRGBAArrayBuffer;
  52903. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52904. private static _GetRGBAArrayBuffer;
  52905. private static _ExtractLongWordOrder;
  52906. private static _GetRGBArrayBuffer;
  52907. private static _GetLuminanceArrayBuffer;
  52908. /**
  52909. * Uploads DDS Levels to a Babylon Texture
  52910. * @hidden
  52911. */
  52912. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52913. }
  52914. interface ThinEngine {
  52915. /**
  52916. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52917. * @param rootUrl defines the url where the file to load is located
  52918. * @param scene defines the current scene
  52919. * @param lodScale defines scale to apply to the mip map selection
  52920. * @param lodOffset defines offset to apply to the mip map selection
  52921. * @param onLoad defines an optional callback raised when the texture is loaded
  52922. * @param onError defines an optional callback raised if there is an issue to load the texture
  52923. * @param format defines the format of the data
  52924. * @param forcedExtension defines the extension to use to pick the right loader
  52925. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52926. * @returns the cube texture as an InternalTexture
  52927. */
  52928. 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;
  52929. }
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * Implementation of the DDS Texture Loader.
  52934. * @hidden
  52935. */
  52936. export class _DDSTextureLoader implements IInternalTextureLoader {
  52937. /**
  52938. * Defines wether the loader supports cascade loading the different faces.
  52939. */
  52940. readonly supportCascades: boolean;
  52941. /**
  52942. * This returns if the loader support the current file information.
  52943. * @param extension defines the file extension of the file being loaded
  52944. * @returns true if the loader can load the specified file
  52945. */
  52946. canLoad(extension: string): boolean;
  52947. /**
  52948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52949. * @param data contains the texture data
  52950. * @param texture defines the BabylonJS internal texture
  52951. * @param createPolynomials will be true if polynomials have been requested
  52952. * @param onLoad defines the callback to trigger once the texture is ready
  52953. * @param onError defines the callback to trigger in case of error
  52954. */
  52955. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52956. /**
  52957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52958. * @param data contains the texture data
  52959. * @param texture defines the BabylonJS internal texture
  52960. * @param callback defines the method to call once ready to upload
  52961. */
  52962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52963. }
  52964. }
  52965. declare module BABYLON {
  52966. /**
  52967. * Implementation of the ENV Texture Loader.
  52968. * @hidden
  52969. */
  52970. export class _ENVTextureLoader implements IInternalTextureLoader {
  52971. /**
  52972. * Defines wether the loader supports cascade loading the different faces.
  52973. */
  52974. readonly supportCascades: boolean;
  52975. /**
  52976. * This returns if the loader support the current file information.
  52977. * @param extension defines the file extension of the file being loaded
  52978. * @returns true if the loader can load the specified file
  52979. */
  52980. canLoad(extension: string): boolean;
  52981. /**
  52982. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52983. * @param data contains the texture data
  52984. * @param texture defines the BabylonJS internal texture
  52985. * @param createPolynomials will be true if polynomials have been requested
  52986. * @param onLoad defines the callback to trigger once the texture is ready
  52987. * @param onError defines the callback to trigger in case of error
  52988. */
  52989. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52990. /**
  52991. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52992. * @param data contains the texture data
  52993. * @param texture defines the BabylonJS internal texture
  52994. * @param callback defines the method to call once ready to upload
  52995. */
  52996. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52997. }
  52998. }
  52999. declare module BABYLON {
  53000. /**
  53001. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53002. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53003. */
  53004. export class KhronosTextureContainer {
  53005. /** contents of the KTX container file */
  53006. data: ArrayBufferView;
  53007. private static HEADER_LEN;
  53008. private static COMPRESSED_2D;
  53009. private static COMPRESSED_3D;
  53010. private static TEX_2D;
  53011. private static TEX_3D;
  53012. /**
  53013. * Gets the openGL type
  53014. */
  53015. glType: number;
  53016. /**
  53017. * Gets the openGL type size
  53018. */
  53019. glTypeSize: number;
  53020. /**
  53021. * Gets the openGL format
  53022. */
  53023. glFormat: number;
  53024. /**
  53025. * Gets the openGL internal format
  53026. */
  53027. glInternalFormat: number;
  53028. /**
  53029. * Gets the base internal format
  53030. */
  53031. glBaseInternalFormat: number;
  53032. /**
  53033. * Gets image width in pixel
  53034. */
  53035. pixelWidth: number;
  53036. /**
  53037. * Gets image height in pixel
  53038. */
  53039. pixelHeight: number;
  53040. /**
  53041. * Gets image depth in pixels
  53042. */
  53043. pixelDepth: number;
  53044. /**
  53045. * Gets the number of array elements
  53046. */
  53047. numberOfArrayElements: number;
  53048. /**
  53049. * Gets the number of faces
  53050. */
  53051. numberOfFaces: number;
  53052. /**
  53053. * Gets the number of mipmap levels
  53054. */
  53055. numberOfMipmapLevels: number;
  53056. /**
  53057. * Gets the bytes of key value data
  53058. */
  53059. bytesOfKeyValueData: number;
  53060. /**
  53061. * Gets the load type
  53062. */
  53063. loadType: number;
  53064. /**
  53065. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53066. */
  53067. isInvalid: boolean;
  53068. /**
  53069. * Creates a new KhronosTextureContainer
  53070. * @param data contents of the KTX container file
  53071. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53072. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53073. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53074. */
  53075. constructor(
  53076. /** contents of the KTX container file */
  53077. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53078. /**
  53079. * Uploads KTX content to a Babylon Texture.
  53080. * It is assumed that the texture has already been created & is currently bound
  53081. * @hidden
  53082. */
  53083. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53084. private _upload2DCompressedLevels;
  53085. /**
  53086. * Checks if the given data starts with a KTX file identifier.
  53087. * @param data the data to check
  53088. * @returns true if the data is a KTX file or false otherwise
  53089. */
  53090. static IsValid(data: ArrayBufferView): boolean;
  53091. }
  53092. }
  53093. declare module BABYLON {
  53094. /**
  53095. * Class for loading KTX2 files
  53096. * !!! Experimental Extension Subject to Changes !!!
  53097. * @hidden
  53098. */
  53099. export class KhronosTextureContainer2 {
  53100. private static _ModulePromise;
  53101. private static _TranscodeFormat;
  53102. constructor(engine: ThinEngine);
  53103. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  53104. private _determineTranscodeFormat;
  53105. /**
  53106. * Checks if the given data starts with a KTX2 file identifier.
  53107. * @param data the data to check
  53108. * @returns true if the data is a KTX2 file or false otherwise
  53109. */
  53110. static IsValid(data: ArrayBufferView): boolean;
  53111. }
  53112. }
  53113. declare module BABYLON {
  53114. /**
  53115. * Implementation of the KTX Texture Loader.
  53116. * @hidden
  53117. */
  53118. export class _KTXTextureLoader implements IInternalTextureLoader {
  53119. /**
  53120. * Defines wether the loader supports cascade loading the different faces.
  53121. */
  53122. readonly supportCascades: boolean;
  53123. /**
  53124. * This returns if the loader support the current file information.
  53125. * @param extension defines the file extension of the file being loaded
  53126. * @returns true if the loader can load the specified file
  53127. */
  53128. canLoad(extension: string): boolean;
  53129. /**
  53130. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53131. * @param data contains the texture data
  53132. * @param texture defines the BabylonJS internal texture
  53133. * @param createPolynomials will be true if polynomials have been requested
  53134. * @param onLoad defines the callback to trigger once the texture is ready
  53135. * @param onError defines the callback to trigger in case of error
  53136. */
  53137. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53138. /**
  53139. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53140. * @param data contains the texture data
  53141. * @param texture defines the BabylonJS internal texture
  53142. * @param callback defines the method to call once ready to upload
  53143. */
  53144. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53145. }
  53146. }
  53147. declare module BABYLON {
  53148. /** @hidden */
  53149. export var _forceSceneHelpersToBundle: boolean;
  53150. interface Scene {
  53151. /**
  53152. * Creates a default light for the scene.
  53153. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53154. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53155. */
  53156. createDefaultLight(replace?: boolean): void;
  53157. /**
  53158. * Creates a default camera for the scene.
  53159. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53160. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53161. * @param replace has default false, when true replaces the active camera in the scene
  53162. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53163. */
  53164. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53165. /**
  53166. * Creates a default camera and a default light.
  53167. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53168. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53169. * @param replace has the default false, when true replaces the active camera/light in the scene
  53170. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53171. */
  53172. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53173. /**
  53174. * Creates a new sky box
  53175. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53176. * @param environmentTexture defines the texture to use as environment texture
  53177. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53178. * @param scale defines the overall scale of the skybox
  53179. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53180. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53181. * @returns a new mesh holding the sky box
  53182. */
  53183. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53184. /**
  53185. * Creates a new environment
  53186. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53187. * @param options defines the options you can use to configure the environment
  53188. * @returns the new EnvironmentHelper
  53189. */
  53190. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53191. /**
  53192. * Creates a new VREXperienceHelper
  53193. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53194. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53195. * @returns a new VREXperienceHelper
  53196. */
  53197. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53198. /**
  53199. * Creates a new WebXRDefaultExperience
  53200. * @see http://doc.babylonjs.com/how_to/webxr
  53201. * @param options experience options
  53202. * @returns a promise for a new WebXRDefaultExperience
  53203. */
  53204. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53205. }
  53206. }
  53207. declare module BABYLON {
  53208. /**
  53209. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53210. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53211. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53212. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53213. */
  53214. export class VideoDome extends TransformNode {
  53215. /**
  53216. * Define the video source as a Monoscopic panoramic 360 video.
  53217. */
  53218. static readonly MODE_MONOSCOPIC: number;
  53219. /**
  53220. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53221. */
  53222. static readonly MODE_TOPBOTTOM: number;
  53223. /**
  53224. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53225. */
  53226. static readonly MODE_SIDEBYSIDE: number;
  53227. private _halfDome;
  53228. private _useDirectMapping;
  53229. /**
  53230. * The video texture being displayed on the sphere
  53231. */
  53232. protected _videoTexture: VideoTexture;
  53233. /**
  53234. * Gets the video texture being displayed on the sphere
  53235. */
  53236. get videoTexture(): VideoTexture;
  53237. /**
  53238. * The skybox material
  53239. */
  53240. protected _material: BackgroundMaterial;
  53241. /**
  53242. * The surface used for the skybox
  53243. */
  53244. protected _mesh: Mesh;
  53245. /**
  53246. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53247. */
  53248. private _halfDomeMask;
  53249. /**
  53250. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53251. * Also see the options.resolution property.
  53252. */
  53253. get fovMultiplier(): number;
  53254. set fovMultiplier(value: number);
  53255. private _videoMode;
  53256. /**
  53257. * Gets or set the current video mode for the video. It can be:
  53258. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53259. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53260. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53261. */
  53262. get videoMode(): number;
  53263. set videoMode(value: number);
  53264. /**
  53265. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53266. *
  53267. */
  53268. get halfDome(): boolean;
  53269. /**
  53270. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53271. */
  53272. set halfDome(enabled: boolean);
  53273. /**
  53274. * Oberserver used in Stereoscopic VR Mode.
  53275. */
  53276. private _onBeforeCameraRenderObserver;
  53277. /**
  53278. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53279. * @param name Element's name, child elements will append suffixes for their own names.
  53280. * @param urlsOrVideo defines the url(s) or the video element to use
  53281. * @param options An object containing optional or exposed sub element properties
  53282. */
  53283. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53284. resolution?: number;
  53285. clickToPlay?: boolean;
  53286. autoPlay?: boolean;
  53287. loop?: boolean;
  53288. size?: number;
  53289. poster?: string;
  53290. faceForward?: boolean;
  53291. useDirectMapping?: boolean;
  53292. halfDomeMode?: boolean;
  53293. }, scene: Scene);
  53294. private _changeVideoMode;
  53295. /**
  53296. * Releases resources associated with this node.
  53297. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53298. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53299. */
  53300. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53301. }
  53302. }
  53303. declare module BABYLON {
  53304. /**
  53305. * This class can be used to get instrumentation data from a Babylon engine
  53306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53307. */
  53308. export class EngineInstrumentation implements IDisposable {
  53309. /**
  53310. * Define the instrumented engine.
  53311. */
  53312. engine: Engine;
  53313. private _captureGPUFrameTime;
  53314. private _gpuFrameTimeToken;
  53315. private _gpuFrameTime;
  53316. private _captureShaderCompilationTime;
  53317. private _shaderCompilationTime;
  53318. private _onBeginFrameObserver;
  53319. private _onEndFrameObserver;
  53320. private _onBeforeShaderCompilationObserver;
  53321. private _onAfterShaderCompilationObserver;
  53322. /**
  53323. * Gets the perf counter used for GPU frame time
  53324. */
  53325. get gpuFrameTimeCounter(): PerfCounter;
  53326. /**
  53327. * Gets the GPU frame time capture status
  53328. */
  53329. get captureGPUFrameTime(): boolean;
  53330. /**
  53331. * Enable or disable the GPU frame time capture
  53332. */
  53333. set captureGPUFrameTime(value: boolean);
  53334. /**
  53335. * Gets the perf counter used for shader compilation time
  53336. */
  53337. get shaderCompilationTimeCounter(): PerfCounter;
  53338. /**
  53339. * Gets the shader compilation time capture status
  53340. */
  53341. get captureShaderCompilationTime(): boolean;
  53342. /**
  53343. * Enable or disable the shader compilation time capture
  53344. */
  53345. set captureShaderCompilationTime(value: boolean);
  53346. /**
  53347. * Instantiates a new engine instrumentation.
  53348. * This class can be used to get instrumentation data from a Babylon engine
  53349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53350. * @param engine Defines the engine to instrument
  53351. */
  53352. constructor(
  53353. /**
  53354. * Define the instrumented engine.
  53355. */
  53356. engine: Engine);
  53357. /**
  53358. * Dispose and release associated resources.
  53359. */
  53360. dispose(): void;
  53361. }
  53362. }
  53363. declare module BABYLON {
  53364. /**
  53365. * This class can be used to get instrumentation data from a Babylon engine
  53366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53367. */
  53368. export class SceneInstrumentation implements IDisposable {
  53369. /**
  53370. * Defines the scene to instrument
  53371. */
  53372. scene: Scene;
  53373. private _captureActiveMeshesEvaluationTime;
  53374. private _activeMeshesEvaluationTime;
  53375. private _captureRenderTargetsRenderTime;
  53376. private _renderTargetsRenderTime;
  53377. private _captureFrameTime;
  53378. private _frameTime;
  53379. private _captureRenderTime;
  53380. private _renderTime;
  53381. private _captureInterFrameTime;
  53382. private _interFrameTime;
  53383. private _captureParticlesRenderTime;
  53384. private _particlesRenderTime;
  53385. private _captureSpritesRenderTime;
  53386. private _spritesRenderTime;
  53387. private _capturePhysicsTime;
  53388. private _physicsTime;
  53389. private _captureAnimationsTime;
  53390. private _animationsTime;
  53391. private _captureCameraRenderTime;
  53392. private _cameraRenderTime;
  53393. private _onBeforeActiveMeshesEvaluationObserver;
  53394. private _onAfterActiveMeshesEvaluationObserver;
  53395. private _onBeforeRenderTargetsRenderObserver;
  53396. private _onAfterRenderTargetsRenderObserver;
  53397. private _onAfterRenderObserver;
  53398. private _onBeforeDrawPhaseObserver;
  53399. private _onAfterDrawPhaseObserver;
  53400. private _onBeforeAnimationsObserver;
  53401. private _onBeforeParticlesRenderingObserver;
  53402. private _onAfterParticlesRenderingObserver;
  53403. private _onBeforeSpritesRenderingObserver;
  53404. private _onAfterSpritesRenderingObserver;
  53405. private _onBeforePhysicsObserver;
  53406. private _onAfterPhysicsObserver;
  53407. private _onAfterAnimationsObserver;
  53408. private _onBeforeCameraRenderObserver;
  53409. private _onAfterCameraRenderObserver;
  53410. /**
  53411. * Gets the perf counter used for active meshes evaluation time
  53412. */
  53413. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53414. /**
  53415. * Gets the active meshes evaluation time capture status
  53416. */
  53417. get captureActiveMeshesEvaluationTime(): boolean;
  53418. /**
  53419. * Enable or disable the active meshes evaluation time capture
  53420. */
  53421. set captureActiveMeshesEvaluationTime(value: boolean);
  53422. /**
  53423. * Gets the perf counter used for render targets render time
  53424. */
  53425. get renderTargetsRenderTimeCounter(): PerfCounter;
  53426. /**
  53427. * Gets the render targets render time capture status
  53428. */
  53429. get captureRenderTargetsRenderTime(): boolean;
  53430. /**
  53431. * Enable or disable the render targets render time capture
  53432. */
  53433. set captureRenderTargetsRenderTime(value: boolean);
  53434. /**
  53435. * Gets the perf counter used for particles render time
  53436. */
  53437. get particlesRenderTimeCounter(): PerfCounter;
  53438. /**
  53439. * Gets the particles render time capture status
  53440. */
  53441. get captureParticlesRenderTime(): boolean;
  53442. /**
  53443. * Enable or disable the particles render time capture
  53444. */
  53445. set captureParticlesRenderTime(value: boolean);
  53446. /**
  53447. * Gets the perf counter used for sprites render time
  53448. */
  53449. get spritesRenderTimeCounter(): PerfCounter;
  53450. /**
  53451. * Gets the sprites render time capture status
  53452. */
  53453. get captureSpritesRenderTime(): boolean;
  53454. /**
  53455. * Enable or disable the sprites render time capture
  53456. */
  53457. set captureSpritesRenderTime(value: boolean);
  53458. /**
  53459. * Gets the perf counter used for physics time
  53460. */
  53461. get physicsTimeCounter(): PerfCounter;
  53462. /**
  53463. * Gets the physics time capture status
  53464. */
  53465. get capturePhysicsTime(): boolean;
  53466. /**
  53467. * Enable or disable the physics time capture
  53468. */
  53469. set capturePhysicsTime(value: boolean);
  53470. /**
  53471. * Gets the perf counter used for animations time
  53472. */
  53473. get animationsTimeCounter(): PerfCounter;
  53474. /**
  53475. * Gets the animations time capture status
  53476. */
  53477. get captureAnimationsTime(): boolean;
  53478. /**
  53479. * Enable or disable the animations time capture
  53480. */
  53481. set captureAnimationsTime(value: boolean);
  53482. /**
  53483. * Gets the perf counter used for frame time capture
  53484. */
  53485. get frameTimeCounter(): PerfCounter;
  53486. /**
  53487. * Gets the frame time capture status
  53488. */
  53489. get captureFrameTime(): boolean;
  53490. /**
  53491. * Enable or disable the frame time capture
  53492. */
  53493. set captureFrameTime(value: boolean);
  53494. /**
  53495. * Gets the perf counter used for inter-frames time capture
  53496. */
  53497. get interFrameTimeCounter(): PerfCounter;
  53498. /**
  53499. * Gets the inter-frames time capture status
  53500. */
  53501. get captureInterFrameTime(): boolean;
  53502. /**
  53503. * Enable or disable the inter-frames time capture
  53504. */
  53505. set captureInterFrameTime(value: boolean);
  53506. /**
  53507. * Gets the perf counter used for render time capture
  53508. */
  53509. get renderTimeCounter(): PerfCounter;
  53510. /**
  53511. * Gets the render time capture status
  53512. */
  53513. get captureRenderTime(): boolean;
  53514. /**
  53515. * Enable or disable the render time capture
  53516. */
  53517. set captureRenderTime(value: boolean);
  53518. /**
  53519. * Gets the perf counter used for camera render time capture
  53520. */
  53521. get cameraRenderTimeCounter(): PerfCounter;
  53522. /**
  53523. * Gets the camera render time capture status
  53524. */
  53525. get captureCameraRenderTime(): boolean;
  53526. /**
  53527. * Enable or disable the camera render time capture
  53528. */
  53529. set captureCameraRenderTime(value: boolean);
  53530. /**
  53531. * Gets the perf counter used for draw calls
  53532. */
  53533. get drawCallsCounter(): PerfCounter;
  53534. /**
  53535. * Instantiates a new scene instrumentation.
  53536. * This class can be used to get instrumentation data from a Babylon engine
  53537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53538. * @param scene Defines the scene to instrument
  53539. */
  53540. constructor(
  53541. /**
  53542. * Defines the scene to instrument
  53543. */
  53544. scene: Scene);
  53545. /**
  53546. * Dispose and release associated resources.
  53547. */
  53548. dispose(): void;
  53549. }
  53550. }
  53551. declare module BABYLON {
  53552. /** @hidden */
  53553. export var glowMapGenerationPixelShader: {
  53554. name: string;
  53555. shader: string;
  53556. };
  53557. }
  53558. declare module BABYLON {
  53559. /** @hidden */
  53560. export var glowMapGenerationVertexShader: {
  53561. name: string;
  53562. shader: string;
  53563. };
  53564. }
  53565. declare module BABYLON {
  53566. /**
  53567. * Effect layer options. This helps customizing the behaviour
  53568. * of the effect layer.
  53569. */
  53570. export interface IEffectLayerOptions {
  53571. /**
  53572. * Multiplication factor apply to the canvas size to compute the render target size
  53573. * used to generated the objects (the smaller the faster).
  53574. */
  53575. mainTextureRatio: number;
  53576. /**
  53577. * Enforces a fixed size texture to ensure effect stability across devices.
  53578. */
  53579. mainTextureFixedSize?: number;
  53580. /**
  53581. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53582. */
  53583. alphaBlendingMode: number;
  53584. /**
  53585. * The camera attached to the layer.
  53586. */
  53587. camera: Nullable<Camera>;
  53588. /**
  53589. * The rendering group to draw the layer in.
  53590. */
  53591. renderingGroupId: number;
  53592. }
  53593. /**
  53594. * The effect layer Helps adding post process effect blended with the main pass.
  53595. *
  53596. * This can be for instance use to generate glow or higlight effects on the scene.
  53597. *
  53598. * The effect layer class can not be used directly and is intented to inherited from to be
  53599. * customized per effects.
  53600. */
  53601. export abstract class EffectLayer {
  53602. private _vertexBuffers;
  53603. private _indexBuffer;
  53604. private _cachedDefines;
  53605. private _effectLayerMapGenerationEffect;
  53606. private _effectLayerOptions;
  53607. private _mergeEffect;
  53608. protected _scene: Scene;
  53609. protected _engine: Engine;
  53610. protected _maxSize: number;
  53611. protected _mainTextureDesiredSize: ISize;
  53612. protected _mainTexture: RenderTargetTexture;
  53613. protected _shouldRender: boolean;
  53614. protected _postProcesses: PostProcess[];
  53615. protected _textures: BaseTexture[];
  53616. protected _emissiveTextureAndColor: {
  53617. texture: Nullable<BaseTexture>;
  53618. color: Color4;
  53619. };
  53620. /**
  53621. * The name of the layer
  53622. */
  53623. name: string;
  53624. /**
  53625. * The clear color of the texture used to generate the glow map.
  53626. */
  53627. neutralColor: Color4;
  53628. /**
  53629. * Specifies whether the highlight layer is enabled or not.
  53630. */
  53631. isEnabled: boolean;
  53632. /**
  53633. * Gets the camera attached to the layer.
  53634. */
  53635. get camera(): Nullable<Camera>;
  53636. /**
  53637. * Gets the rendering group id the layer should render in.
  53638. */
  53639. get renderingGroupId(): number;
  53640. set renderingGroupId(renderingGroupId: number);
  53641. /**
  53642. * An event triggered when the effect layer has been disposed.
  53643. */
  53644. onDisposeObservable: Observable<EffectLayer>;
  53645. /**
  53646. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53647. */
  53648. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53649. /**
  53650. * An event triggered when the generated texture is being merged in the scene.
  53651. */
  53652. onBeforeComposeObservable: Observable<EffectLayer>;
  53653. /**
  53654. * An event triggered when the mesh is rendered into the effect render target.
  53655. */
  53656. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53657. /**
  53658. * An event triggered after the mesh has been rendered into the effect render target.
  53659. */
  53660. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53661. /**
  53662. * An event triggered when the generated texture has been merged in the scene.
  53663. */
  53664. onAfterComposeObservable: Observable<EffectLayer>;
  53665. /**
  53666. * An event triggered when the efffect layer changes its size.
  53667. */
  53668. onSizeChangedObservable: Observable<EffectLayer>;
  53669. /** @hidden */
  53670. static _SceneComponentInitialization: (scene: Scene) => void;
  53671. /**
  53672. * Instantiates a new effect Layer and references it in the scene.
  53673. * @param name The name of the layer
  53674. * @param scene The scene to use the layer in
  53675. */
  53676. constructor(
  53677. /** The Friendly of the effect in the scene */
  53678. name: string, scene: Scene);
  53679. /**
  53680. * Get the effect name of the layer.
  53681. * @return The effect name
  53682. */
  53683. abstract getEffectName(): string;
  53684. /**
  53685. * Checks for the readiness of the element composing the layer.
  53686. * @param subMesh the mesh to check for
  53687. * @param useInstances specify whether or not to use instances to render the mesh
  53688. * @return true if ready otherwise, false
  53689. */
  53690. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53691. /**
  53692. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53693. * @returns true if the effect requires stencil during the main canvas render pass.
  53694. */
  53695. abstract needStencil(): boolean;
  53696. /**
  53697. * Create the merge effect. This is the shader use to blit the information back
  53698. * to the main canvas at the end of the scene rendering.
  53699. * @returns The effect containing the shader used to merge the effect on the main canvas
  53700. */
  53701. protected abstract _createMergeEffect(): Effect;
  53702. /**
  53703. * Creates the render target textures and post processes used in the effect layer.
  53704. */
  53705. protected abstract _createTextureAndPostProcesses(): void;
  53706. /**
  53707. * Implementation specific of rendering the generating effect on the main canvas.
  53708. * @param effect The effect used to render through
  53709. */
  53710. protected abstract _internalRender(effect: Effect): void;
  53711. /**
  53712. * Sets the required values for both the emissive texture and and the main color.
  53713. */
  53714. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53715. /**
  53716. * Free any resources and references associated to a mesh.
  53717. * Internal use
  53718. * @param mesh The mesh to free.
  53719. */
  53720. abstract _disposeMesh(mesh: Mesh): void;
  53721. /**
  53722. * Serializes this layer (Glow or Highlight for example)
  53723. * @returns a serialized layer object
  53724. */
  53725. abstract serialize?(): any;
  53726. /**
  53727. * Initializes the effect layer with the required options.
  53728. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53729. */
  53730. protected _init(options: Partial<IEffectLayerOptions>): void;
  53731. /**
  53732. * Generates the index buffer of the full screen quad blending to the main canvas.
  53733. */
  53734. private _generateIndexBuffer;
  53735. /**
  53736. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53737. */
  53738. private _generateVertexBuffer;
  53739. /**
  53740. * Sets the main texture desired size which is the closest power of two
  53741. * of the engine canvas size.
  53742. */
  53743. private _setMainTextureSize;
  53744. /**
  53745. * Creates the main texture for the effect layer.
  53746. */
  53747. protected _createMainTexture(): void;
  53748. /**
  53749. * Adds specific effects defines.
  53750. * @param defines The defines to add specifics to.
  53751. */
  53752. protected _addCustomEffectDefines(defines: string[]): void;
  53753. /**
  53754. * Checks for the readiness of the element composing the layer.
  53755. * @param subMesh the mesh to check for
  53756. * @param useInstances specify whether or not to use instances to render the mesh
  53757. * @param emissiveTexture the associated emissive texture used to generate the glow
  53758. * @return true if ready otherwise, false
  53759. */
  53760. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53761. /**
  53762. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53763. */
  53764. render(): void;
  53765. /**
  53766. * Determine if a given mesh will be used in the current effect.
  53767. * @param mesh mesh to test
  53768. * @returns true if the mesh will be used
  53769. */
  53770. hasMesh(mesh: AbstractMesh): boolean;
  53771. /**
  53772. * Returns true if the layer contains information to display, otherwise false.
  53773. * @returns true if the glow layer should be rendered
  53774. */
  53775. shouldRender(): boolean;
  53776. /**
  53777. * Returns true if the mesh should render, otherwise false.
  53778. * @param mesh The mesh to render
  53779. * @returns true if it should render otherwise false
  53780. */
  53781. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53782. /**
  53783. * Returns true if the mesh can be rendered, otherwise false.
  53784. * @param mesh The mesh to render
  53785. * @param material The material used on the mesh
  53786. * @returns true if it can be rendered otherwise false
  53787. */
  53788. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53789. /**
  53790. * Returns true if the mesh should render, otherwise false.
  53791. * @param mesh The mesh to render
  53792. * @returns true if it should render otherwise false
  53793. */
  53794. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53795. /**
  53796. * Renders the submesh passed in parameter to the generation map.
  53797. */
  53798. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53799. /**
  53800. * Defines whether the current material of the mesh should be use to render the effect.
  53801. * @param mesh defines the current mesh to render
  53802. */
  53803. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53804. /**
  53805. * Rebuild the required buffers.
  53806. * @hidden Internal use only.
  53807. */
  53808. _rebuild(): void;
  53809. /**
  53810. * Dispose only the render target textures and post process.
  53811. */
  53812. private _disposeTextureAndPostProcesses;
  53813. /**
  53814. * Dispose the highlight layer and free resources.
  53815. */
  53816. dispose(): void;
  53817. /**
  53818. * Gets the class name of the effect layer
  53819. * @returns the string with the class name of the effect layer
  53820. */
  53821. getClassName(): string;
  53822. /**
  53823. * Creates an effect layer from parsed effect layer data
  53824. * @param parsedEffectLayer defines effect layer data
  53825. * @param scene defines the current scene
  53826. * @param rootUrl defines the root URL containing the effect layer information
  53827. * @returns a parsed effect Layer
  53828. */
  53829. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. interface AbstractScene {
  53834. /**
  53835. * The list of effect layers (highlights/glow) added to the scene
  53836. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53837. * @see http://doc.babylonjs.com/how_to/glow_layer
  53838. */
  53839. effectLayers: Array<EffectLayer>;
  53840. /**
  53841. * Removes the given effect layer from this scene.
  53842. * @param toRemove defines the effect layer to remove
  53843. * @returns the index of the removed effect layer
  53844. */
  53845. removeEffectLayer(toRemove: EffectLayer): number;
  53846. /**
  53847. * Adds the given effect layer to this scene
  53848. * @param newEffectLayer defines the effect layer to add
  53849. */
  53850. addEffectLayer(newEffectLayer: EffectLayer): void;
  53851. }
  53852. /**
  53853. * Defines the layer scene component responsible to manage any effect layers
  53854. * in a given scene.
  53855. */
  53856. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53857. /**
  53858. * The component name helpfull to identify the component in the list of scene components.
  53859. */
  53860. readonly name: string;
  53861. /**
  53862. * The scene the component belongs to.
  53863. */
  53864. scene: Scene;
  53865. private _engine;
  53866. private _renderEffects;
  53867. private _needStencil;
  53868. private _previousStencilState;
  53869. /**
  53870. * Creates a new instance of the component for the given scene
  53871. * @param scene Defines the scene to register the component in
  53872. */
  53873. constructor(scene: Scene);
  53874. /**
  53875. * Registers the component in a given scene
  53876. */
  53877. register(): void;
  53878. /**
  53879. * Rebuilds the elements related to this component in case of
  53880. * context lost for instance.
  53881. */
  53882. rebuild(): void;
  53883. /**
  53884. * Serializes the component data to the specified json object
  53885. * @param serializationObject The object to serialize to
  53886. */
  53887. serialize(serializationObject: any): void;
  53888. /**
  53889. * Adds all the elements from the container to the scene
  53890. * @param container the container holding the elements
  53891. */
  53892. addFromContainer(container: AbstractScene): void;
  53893. /**
  53894. * Removes all the elements in the container from the scene
  53895. * @param container contains the elements to remove
  53896. * @param dispose if the removed element should be disposed (default: false)
  53897. */
  53898. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53899. /**
  53900. * Disposes the component and the associated ressources.
  53901. */
  53902. dispose(): void;
  53903. private _isReadyForMesh;
  53904. private _renderMainTexture;
  53905. private _setStencil;
  53906. private _setStencilBack;
  53907. private _draw;
  53908. private _drawCamera;
  53909. private _drawRenderingGroup;
  53910. }
  53911. }
  53912. declare module BABYLON {
  53913. /** @hidden */
  53914. export var glowMapMergePixelShader: {
  53915. name: string;
  53916. shader: string;
  53917. };
  53918. }
  53919. declare module BABYLON {
  53920. /** @hidden */
  53921. export var glowMapMergeVertexShader: {
  53922. name: string;
  53923. shader: string;
  53924. };
  53925. }
  53926. declare module BABYLON {
  53927. interface AbstractScene {
  53928. /**
  53929. * Return a the first highlight layer of the scene with a given name.
  53930. * @param name The name of the highlight layer to look for.
  53931. * @return The highlight layer if found otherwise null.
  53932. */
  53933. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53934. }
  53935. /**
  53936. * Glow layer options. This helps customizing the behaviour
  53937. * of the glow layer.
  53938. */
  53939. export interface IGlowLayerOptions {
  53940. /**
  53941. * Multiplication factor apply to the canvas size to compute the render target size
  53942. * used to generated the glowing objects (the smaller the faster).
  53943. */
  53944. mainTextureRatio: number;
  53945. /**
  53946. * Enforces a fixed size texture to ensure resize independant blur.
  53947. */
  53948. mainTextureFixedSize?: number;
  53949. /**
  53950. * How big is the kernel of the blur texture.
  53951. */
  53952. blurKernelSize: number;
  53953. /**
  53954. * The camera attached to the layer.
  53955. */
  53956. camera: Nullable<Camera>;
  53957. /**
  53958. * Enable MSAA by chosing the number of samples.
  53959. */
  53960. mainTextureSamples?: number;
  53961. /**
  53962. * The rendering group to draw the layer in.
  53963. */
  53964. renderingGroupId: number;
  53965. }
  53966. /**
  53967. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53968. *
  53969. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53970. *
  53971. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53972. */
  53973. export class GlowLayer extends EffectLayer {
  53974. /**
  53975. * Effect Name of the layer.
  53976. */
  53977. static readonly EffectName: string;
  53978. /**
  53979. * The default blur kernel size used for the glow.
  53980. */
  53981. static DefaultBlurKernelSize: number;
  53982. /**
  53983. * The default texture size ratio used for the glow.
  53984. */
  53985. static DefaultTextureRatio: number;
  53986. /**
  53987. * Sets the kernel size of the blur.
  53988. */
  53989. set blurKernelSize(value: number);
  53990. /**
  53991. * Gets the kernel size of the blur.
  53992. */
  53993. get blurKernelSize(): number;
  53994. /**
  53995. * Sets the glow intensity.
  53996. */
  53997. set intensity(value: number);
  53998. /**
  53999. * Gets the glow intensity.
  54000. */
  54001. get intensity(): number;
  54002. private _options;
  54003. private _intensity;
  54004. private _horizontalBlurPostprocess1;
  54005. private _verticalBlurPostprocess1;
  54006. private _horizontalBlurPostprocess2;
  54007. private _verticalBlurPostprocess2;
  54008. private _blurTexture1;
  54009. private _blurTexture2;
  54010. private _postProcesses1;
  54011. private _postProcesses2;
  54012. private _includedOnlyMeshes;
  54013. private _excludedMeshes;
  54014. private _meshesUsingTheirOwnMaterials;
  54015. /**
  54016. * Callback used to let the user override the color selection on a per mesh basis
  54017. */
  54018. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54019. /**
  54020. * Callback used to let the user override the texture selection on a per mesh basis
  54021. */
  54022. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54023. /**
  54024. * Instantiates a new glow Layer and references it to the scene.
  54025. * @param name The name of the layer
  54026. * @param scene The scene to use the layer in
  54027. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54028. */
  54029. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54030. /**
  54031. * Get the effect name of the layer.
  54032. * @return The effect name
  54033. */
  54034. getEffectName(): string;
  54035. /**
  54036. * Create the merge effect. This is the shader use to blit the information back
  54037. * to the main canvas at the end of the scene rendering.
  54038. */
  54039. protected _createMergeEffect(): Effect;
  54040. /**
  54041. * Creates the render target textures and post processes used in the glow layer.
  54042. */
  54043. protected _createTextureAndPostProcesses(): void;
  54044. /**
  54045. * Checks for the readiness of the element composing the layer.
  54046. * @param subMesh the mesh to check for
  54047. * @param useInstances specify wether or not to use instances to render the mesh
  54048. * @param emissiveTexture the associated emissive texture used to generate the glow
  54049. * @return true if ready otherwise, false
  54050. */
  54051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54052. /**
  54053. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54054. */
  54055. needStencil(): boolean;
  54056. /**
  54057. * Returns true if the mesh can be rendered, otherwise false.
  54058. * @param mesh The mesh to render
  54059. * @param material The material used on the mesh
  54060. * @returns true if it can be rendered otherwise false
  54061. */
  54062. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54063. /**
  54064. * Implementation specific of rendering the generating effect on the main canvas.
  54065. * @param effect The effect used to render through
  54066. */
  54067. protected _internalRender(effect: Effect): void;
  54068. /**
  54069. * Sets the required values for both the emissive texture and and the main color.
  54070. */
  54071. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54072. /**
  54073. * Returns true if the mesh should render, otherwise false.
  54074. * @param mesh The mesh to render
  54075. * @returns true if it should render otherwise false
  54076. */
  54077. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54078. /**
  54079. * Adds specific effects defines.
  54080. * @param defines The defines to add specifics to.
  54081. */
  54082. protected _addCustomEffectDefines(defines: string[]): void;
  54083. /**
  54084. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54085. * @param mesh The mesh to exclude from the glow layer
  54086. */
  54087. addExcludedMesh(mesh: Mesh): void;
  54088. /**
  54089. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54090. * @param mesh The mesh to remove
  54091. */
  54092. removeExcludedMesh(mesh: Mesh): void;
  54093. /**
  54094. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54095. * @param mesh The mesh to include in the glow layer
  54096. */
  54097. addIncludedOnlyMesh(mesh: Mesh): void;
  54098. /**
  54099. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54100. * @param mesh The mesh to remove
  54101. */
  54102. removeIncludedOnlyMesh(mesh: Mesh): void;
  54103. /**
  54104. * Determine if a given mesh will be used in the glow layer
  54105. * @param mesh The mesh to test
  54106. * @returns true if the mesh will be highlighted by the current glow layer
  54107. */
  54108. hasMesh(mesh: AbstractMesh): boolean;
  54109. /**
  54110. * Defines whether the current material of the mesh should be use to render the effect.
  54111. * @param mesh defines the current mesh to render
  54112. */
  54113. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54114. /**
  54115. * Add a mesh to be rendered through its own material and not with emissive only.
  54116. * @param mesh The mesh for which we need to use its material
  54117. */
  54118. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54119. /**
  54120. * Remove a mesh from being rendered through its own material and not with emissive only.
  54121. * @param mesh The mesh for which we need to not use its material
  54122. */
  54123. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54124. /**
  54125. * Free any resources and references associated to a mesh.
  54126. * Internal use
  54127. * @param mesh The mesh to free.
  54128. * @hidden
  54129. */
  54130. _disposeMesh(mesh: Mesh): void;
  54131. /**
  54132. * Gets the class name of the effect layer
  54133. * @returns the string with the class name of the effect layer
  54134. */
  54135. getClassName(): string;
  54136. /**
  54137. * Serializes this glow layer
  54138. * @returns a serialized glow layer object
  54139. */
  54140. serialize(): any;
  54141. /**
  54142. * Creates a Glow Layer from parsed glow layer data
  54143. * @param parsedGlowLayer defines glow layer data
  54144. * @param scene defines the current scene
  54145. * @param rootUrl defines the root URL containing the glow layer information
  54146. * @returns a parsed Glow Layer
  54147. */
  54148. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54149. }
  54150. }
  54151. declare module BABYLON {
  54152. /** @hidden */
  54153. export var glowBlurPostProcessPixelShader: {
  54154. name: string;
  54155. shader: string;
  54156. };
  54157. }
  54158. declare module BABYLON {
  54159. interface AbstractScene {
  54160. /**
  54161. * Return a the first highlight layer of the scene with a given name.
  54162. * @param name The name of the highlight layer to look for.
  54163. * @return The highlight layer if found otherwise null.
  54164. */
  54165. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54166. }
  54167. /**
  54168. * Highlight layer options. This helps customizing the behaviour
  54169. * of the highlight layer.
  54170. */
  54171. export interface IHighlightLayerOptions {
  54172. /**
  54173. * Multiplication factor apply to the canvas size to compute the render target size
  54174. * used to generated the glowing objects (the smaller the faster).
  54175. */
  54176. mainTextureRatio: number;
  54177. /**
  54178. * Enforces a fixed size texture to ensure resize independant blur.
  54179. */
  54180. mainTextureFixedSize?: number;
  54181. /**
  54182. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54183. * of the picture to blur (the smaller the faster).
  54184. */
  54185. blurTextureSizeRatio: number;
  54186. /**
  54187. * How big in texel of the blur texture is the vertical blur.
  54188. */
  54189. blurVerticalSize: number;
  54190. /**
  54191. * How big in texel of the blur texture is the horizontal blur.
  54192. */
  54193. blurHorizontalSize: number;
  54194. /**
  54195. * Alpha blending mode used to apply the blur. Default is combine.
  54196. */
  54197. alphaBlendingMode: number;
  54198. /**
  54199. * The camera attached to the layer.
  54200. */
  54201. camera: Nullable<Camera>;
  54202. /**
  54203. * Should we display highlight as a solid stroke?
  54204. */
  54205. isStroke?: boolean;
  54206. /**
  54207. * The rendering group to draw the layer in.
  54208. */
  54209. renderingGroupId: number;
  54210. }
  54211. /**
  54212. * The highlight layer Helps adding a glow effect around a mesh.
  54213. *
  54214. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54215. * glowy meshes to your scene.
  54216. *
  54217. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54218. */
  54219. export class HighlightLayer extends EffectLayer {
  54220. name: string;
  54221. /**
  54222. * Effect Name of the highlight layer.
  54223. */
  54224. static readonly EffectName: string;
  54225. /**
  54226. * The neutral color used during the preparation of the glow effect.
  54227. * This is black by default as the blend operation is a blend operation.
  54228. */
  54229. static NeutralColor: Color4;
  54230. /**
  54231. * Stencil value used for glowing meshes.
  54232. */
  54233. static GlowingMeshStencilReference: number;
  54234. /**
  54235. * Stencil value used for the other meshes in the scene.
  54236. */
  54237. static NormalMeshStencilReference: number;
  54238. /**
  54239. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54240. */
  54241. innerGlow: boolean;
  54242. /**
  54243. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54244. */
  54245. outerGlow: boolean;
  54246. /**
  54247. * Specifies the horizontal size of the blur.
  54248. */
  54249. set blurHorizontalSize(value: number);
  54250. /**
  54251. * Specifies the vertical size of the blur.
  54252. */
  54253. set blurVerticalSize(value: number);
  54254. /**
  54255. * Gets the horizontal size of the blur.
  54256. */
  54257. get blurHorizontalSize(): number;
  54258. /**
  54259. * Gets the vertical size of the blur.
  54260. */
  54261. get blurVerticalSize(): number;
  54262. /**
  54263. * An event triggered when the highlight layer is being blurred.
  54264. */
  54265. onBeforeBlurObservable: Observable<HighlightLayer>;
  54266. /**
  54267. * An event triggered when the highlight layer has been blurred.
  54268. */
  54269. onAfterBlurObservable: Observable<HighlightLayer>;
  54270. private _instanceGlowingMeshStencilReference;
  54271. private _options;
  54272. private _downSamplePostprocess;
  54273. private _horizontalBlurPostprocess;
  54274. private _verticalBlurPostprocess;
  54275. private _blurTexture;
  54276. private _meshes;
  54277. private _excludedMeshes;
  54278. /**
  54279. * Instantiates a new highlight Layer and references it to the scene..
  54280. * @param name The name of the layer
  54281. * @param scene The scene to use the layer in
  54282. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54283. */
  54284. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54285. /**
  54286. * Get the effect name of the layer.
  54287. * @return The effect name
  54288. */
  54289. getEffectName(): string;
  54290. /**
  54291. * Create the merge effect. This is the shader use to blit the information back
  54292. * to the main canvas at the end of the scene rendering.
  54293. */
  54294. protected _createMergeEffect(): Effect;
  54295. /**
  54296. * Creates the render target textures and post processes used in the highlight layer.
  54297. */
  54298. protected _createTextureAndPostProcesses(): void;
  54299. /**
  54300. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54301. */
  54302. needStencil(): boolean;
  54303. /**
  54304. * Checks for the readiness of the element composing the layer.
  54305. * @param subMesh the mesh to check for
  54306. * @param useInstances specify wether or not to use instances to render the mesh
  54307. * @param emissiveTexture the associated emissive texture used to generate the glow
  54308. * @return true if ready otherwise, false
  54309. */
  54310. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54311. /**
  54312. * Implementation specific of rendering the generating effect on the main canvas.
  54313. * @param effect The effect used to render through
  54314. */
  54315. protected _internalRender(effect: Effect): void;
  54316. /**
  54317. * Returns true if the layer contains information to display, otherwise false.
  54318. */
  54319. shouldRender(): boolean;
  54320. /**
  54321. * Returns true if the mesh should render, otherwise false.
  54322. * @param mesh The mesh to render
  54323. * @returns true if it should render otherwise false
  54324. */
  54325. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54326. /**
  54327. * Adds specific effects defines.
  54328. * @param defines The defines to add specifics to.
  54329. */
  54330. protected _addCustomEffectDefines(defines: string[]): void;
  54331. /**
  54332. * Sets the required values for both the emissive texture and and the main color.
  54333. */
  54334. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54335. /**
  54336. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54337. * @param mesh The mesh to exclude from the highlight layer
  54338. */
  54339. addExcludedMesh(mesh: Mesh): void;
  54340. /**
  54341. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54342. * @param mesh The mesh to highlight
  54343. */
  54344. removeExcludedMesh(mesh: Mesh): void;
  54345. /**
  54346. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54347. * @param mesh mesh to test
  54348. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54349. */
  54350. hasMesh(mesh: AbstractMesh): boolean;
  54351. /**
  54352. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54353. * @param mesh The mesh to highlight
  54354. * @param color The color of the highlight
  54355. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54356. */
  54357. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54358. /**
  54359. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54360. * @param mesh The mesh to highlight
  54361. */
  54362. removeMesh(mesh: Mesh): void;
  54363. /**
  54364. * Remove all the meshes currently referenced in the highlight layer
  54365. */
  54366. removeAllMeshes(): void;
  54367. /**
  54368. * Force the stencil to the normal expected value for none glowing parts
  54369. */
  54370. private _defaultStencilReference;
  54371. /**
  54372. * Free any resources and references associated to a mesh.
  54373. * Internal use
  54374. * @param mesh The mesh to free.
  54375. * @hidden
  54376. */
  54377. _disposeMesh(mesh: Mesh): void;
  54378. /**
  54379. * Dispose the highlight layer and free resources.
  54380. */
  54381. dispose(): void;
  54382. /**
  54383. * Gets the class name of the effect layer
  54384. * @returns the string with the class name of the effect layer
  54385. */
  54386. getClassName(): string;
  54387. /**
  54388. * Serializes this Highlight layer
  54389. * @returns a serialized Highlight layer object
  54390. */
  54391. serialize(): any;
  54392. /**
  54393. * Creates a Highlight layer from parsed Highlight layer data
  54394. * @param parsedHightlightLayer defines the Highlight layer data
  54395. * @param scene defines the current scene
  54396. * @param rootUrl defines the root URL containing the Highlight layer information
  54397. * @returns a parsed Highlight layer
  54398. */
  54399. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54400. }
  54401. }
  54402. declare module BABYLON {
  54403. interface AbstractScene {
  54404. /**
  54405. * The list of layers (background and foreground) of the scene
  54406. */
  54407. layers: Array<Layer>;
  54408. }
  54409. /**
  54410. * Defines the layer scene component responsible to manage any layers
  54411. * in a given scene.
  54412. */
  54413. export class LayerSceneComponent implements ISceneComponent {
  54414. /**
  54415. * The component name helpfull to identify the component in the list of scene components.
  54416. */
  54417. readonly name: string;
  54418. /**
  54419. * The scene the component belongs to.
  54420. */
  54421. scene: Scene;
  54422. private _engine;
  54423. /**
  54424. * Creates a new instance of the component for the given scene
  54425. * @param scene Defines the scene to register the component in
  54426. */
  54427. constructor(scene: Scene);
  54428. /**
  54429. * Registers the component in a given scene
  54430. */
  54431. register(): void;
  54432. /**
  54433. * Rebuilds the elements related to this component in case of
  54434. * context lost for instance.
  54435. */
  54436. rebuild(): void;
  54437. /**
  54438. * Disposes the component and the associated ressources.
  54439. */
  54440. dispose(): void;
  54441. private _draw;
  54442. private _drawCameraPredicate;
  54443. private _drawCameraBackground;
  54444. private _drawCameraForeground;
  54445. private _drawRenderTargetPredicate;
  54446. private _drawRenderTargetBackground;
  54447. private _drawRenderTargetForeground;
  54448. /**
  54449. * Adds all the elements from the container to the scene
  54450. * @param container the container holding the elements
  54451. */
  54452. addFromContainer(container: AbstractScene): void;
  54453. /**
  54454. * Removes all the elements in the container from the scene
  54455. * @param container contains the elements to remove
  54456. * @param dispose if the removed element should be disposed (default: false)
  54457. */
  54458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54459. }
  54460. }
  54461. declare module BABYLON {
  54462. /** @hidden */
  54463. export var layerPixelShader: {
  54464. name: string;
  54465. shader: string;
  54466. };
  54467. }
  54468. declare module BABYLON {
  54469. /** @hidden */
  54470. export var layerVertexShader: {
  54471. name: string;
  54472. shader: string;
  54473. };
  54474. }
  54475. declare module BABYLON {
  54476. /**
  54477. * This represents a full screen 2d layer.
  54478. * This can be useful to display a picture in the background of your scene for instance.
  54479. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54480. */
  54481. export class Layer {
  54482. /**
  54483. * Define the name of the layer.
  54484. */
  54485. name: string;
  54486. /**
  54487. * Define the texture the layer should display.
  54488. */
  54489. texture: Nullable<Texture>;
  54490. /**
  54491. * Is the layer in background or foreground.
  54492. */
  54493. isBackground: boolean;
  54494. /**
  54495. * Define the color of the layer (instead of texture).
  54496. */
  54497. color: Color4;
  54498. /**
  54499. * Define the scale of the layer in order to zoom in out of the texture.
  54500. */
  54501. scale: Vector2;
  54502. /**
  54503. * Define an offset for the layer in order to shift the texture.
  54504. */
  54505. offset: Vector2;
  54506. /**
  54507. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54508. */
  54509. alphaBlendingMode: number;
  54510. /**
  54511. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54512. * Alpha test will not mix with the background color in case of transparency.
  54513. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54514. */
  54515. alphaTest: boolean;
  54516. /**
  54517. * Define a mask to restrict the layer to only some of the scene cameras.
  54518. */
  54519. layerMask: number;
  54520. /**
  54521. * Define the list of render target the layer is visible into.
  54522. */
  54523. renderTargetTextures: RenderTargetTexture[];
  54524. /**
  54525. * Define if the layer is only used in renderTarget or if it also
  54526. * renders in the main frame buffer of the canvas.
  54527. */
  54528. renderOnlyInRenderTargetTextures: boolean;
  54529. private _scene;
  54530. private _vertexBuffers;
  54531. private _indexBuffer;
  54532. private _effect;
  54533. private _previousDefines;
  54534. /**
  54535. * An event triggered when the layer is disposed.
  54536. */
  54537. onDisposeObservable: Observable<Layer>;
  54538. private _onDisposeObserver;
  54539. /**
  54540. * Back compatibility with callback before the onDisposeObservable existed.
  54541. * The set callback will be triggered when the layer has been disposed.
  54542. */
  54543. set onDispose(callback: () => void);
  54544. /**
  54545. * An event triggered before rendering the scene
  54546. */
  54547. onBeforeRenderObservable: Observable<Layer>;
  54548. private _onBeforeRenderObserver;
  54549. /**
  54550. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54551. * The set callback will be triggered just before rendering the layer.
  54552. */
  54553. set onBeforeRender(callback: () => void);
  54554. /**
  54555. * An event triggered after rendering the scene
  54556. */
  54557. onAfterRenderObservable: Observable<Layer>;
  54558. private _onAfterRenderObserver;
  54559. /**
  54560. * Back compatibility with callback before the onAfterRenderObservable existed.
  54561. * The set callback will be triggered just after rendering the layer.
  54562. */
  54563. set onAfterRender(callback: () => void);
  54564. /**
  54565. * Instantiates a new layer.
  54566. * This represents a full screen 2d layer.
  54567. * This can be useful to display a picture in the background of your scene for instance.
  54568. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54569. * @param name Define the name of the layer in the scene
  54570. * @param imgUrl Define the url of the texture to display in the layer
  54571. * @param scene Define the scene the layer belongs to
  54572. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54573. * @param color Defines a color for the layer
  54574. */
  54575. constructor(
  54576. /**
  54577. * Define the name of the layer.
  54578. */
  54579. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54580. private _createIndexBuffer;
  54581. /** @hidden */
  54582. _rebuild(): void;
  54583. /**
  54584. * Renders the layer in the scene.
  54585. */
  54586. render(): void;
  54587. /**
  54588. * Disposes and releases the associated ressources.
  54589. */
  54590. dispose(): void;
  54591. }
  54592. }
  54593. declare module BABYLON {
  54594. /** @hidden */
  54595. export var lensFlarePixelShader: {
  54596. name: string;
  54597. shader: string;
  54598. };
  54599. }
  54600. declare module BABYLON {
  54601. /** @hidden */
  54602. export var lensFlareVertexShader: {
  54603. name: string;
  54604. shader: string;
  54605. };
  54606. }
  54607. declare module BABYLON {
  54608. /**
  54609. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54610. * It is usually composed of several `lensFlare`.
  54611. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54612. */
  54613. export class LensFlareSystem {
  54614. /**
  54615. * Define the name of the lens flare system
  54616. */
  54617. name: string;
  54618. /**
  54619. * List of lens flares used in this system.
  54620. */
  54621. lensFlares: LensFlare[];
  54622. /**
  54623. * Define a limit from the border the lens flare can be visible.
  54624. */
  54625. borderLimit: number;
  54626. /**
  54627. * Define a viewport border we do not want to see the lens flare in.
  54628. */
  54629. viewportBorder: number;
  54630. /**
  54631. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54632. */
  54633. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54634. /**
  54635. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54636. */
  54637. layerMask: number;
  54638. /**
  54639. * Define the id of the lens flare system in the scene.
  54640. * (equal to name by default)
  54641. */
  54642. id: string;
  54643. private _scene;
  54644. private _emitter;
  54645. private _vertexBuffers;
  54646. private _indexBuffer;
  54647. private _effect;
  54648. private _positionX;
  54649. private _positionY;
  54650. private _isEnabled;
  54651. /** @hidden */
  54652. static _SceneComponentInitialization: (scene: Scene) => void;
  54653. /**
  54654. * Instantiates a lens flare system.
  54655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54656. * It is usually composed of several `lensFlare`.
  54657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54658. * @param name Define the name of the lens flare system in the scene
  54659. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54660. * @param scene Define the scene the lens flare system belongs to
  54661. */
  54662. constructor(
  54663. /**
  54664. * Define the name of the lens flare system
  54665. */
  54666. name: string, emitter: any, scene: Scene);
  54667. /**
  54668. * Define if the lens flare system is enabled.
  54669. */
  54670. get isEnabled(): boolean;
  54671. set isEnabled(value: boolean);
  54672. /**
  54673. * Get the scene the effects belongs to.
  54674. * @returns the scene holding the lens flare system
  54675. */
  54676. getScene(): Scene;
  54677. /**
  54678. * Get the emitter of the lens flare system.
  54679. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54680. * @returns the emitter of the lens flare system
  54681. */
  54682. getEmitter(): any;
  54683. /**
  54684. * Set the emitter of the lens flare system.
  54685. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54686. * @param newEmitter Define the new emitter of the system
  54687. */
  54688. setEmitter(newEmitter: any): void;
  54689. /**
  54690. * Get the lens flare system emitter position.
  54691. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54692. * @returns the position
  54693. */
  54694. getEmitterPosition(): Vector3;
  54695. /**
  54696. * @hidden
  54697. */
  54698. computeEffectivePosition(globalViewport: Viewport): boolean;
  54699. /** @hidden */
  54700. _isVisible(): boolean;
  54701. /**
  54702. * @hidden
  54703. */
  54704. render(): boolean;
  54705. /**
  54706. * Dispose and release the lens flare with its associated resources.
  54707. */
  54708. dispose(): void;
  54709. /**
  54710. * Parse a lens flare system from a JSON repressentation
  54711. * @param parsedLensFlareSystem Define the JSON to parse
  54712. * @param scene Define the scene the parsed system should be instantiated in
  54713. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54714. * @returns the parsed system
  54715. */
  54716. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54717. /**
  54718. * Serialize the current Lens Flare System into a JSON representation.
  54719. * @returns the serialized JSON
  54720. */
  54721. serialize(): any;
  54722. }
  54723. }
  54724. declare module BABYLON {
  54725. /**
  54726. * This represents one of the lens effect in a `lensFlareSystem`.
  54727. * It controls one of the indiviual texture used in the effect.
  54728. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54729. */
  54730. export class LensFlare {
  54731. /**
  54732. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54733. */
  54734. size: number;
  54735. /**
  54736. * 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.
  54737. */
  54738. position: number;
  54739. /**
  54740. * Define the lens color.
  54741. */
  54742. color: Color3;
  54743. /**
  54744. * Define the lens texture.
  54745. */
  54746. texture: Nullable<Texture>;
  54747. /**
  54748. * Define the alpha mode to render this particular lens.
  54749. */
  54750. alphaMode: number;
  54751. private _system;
  54752. /**
  54753. * Creates a new Lens Flare.
  54754. * This represents one of the lens effect in a `lensFlareSystem`.
  54755. * It controls one of the indiviual texture used in the effect.
  54756. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54757. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54758. * @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.
  54759. * @param color Define the lens color
  54760. * @param imgUrl Define the lens texture url
  54761. * @param system Define the `lensFlareSystem` this flare is part of
  54762. * @returns The newly created Lens Flare
  54763. */
  54764. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54765. /**
  54766. * Instantiates a new Lens Flare.
  54767. * This represents one of the lens effect in a `lensFlareSystem`.
  54768. * It controls one of the indiviual texture used in the effect.
  54769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54770. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54771. * @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.
  54772. * @param color Define the lens color
  54773. * @param imgUrl Define the lens texture url
  54774. * @param system Define the `lensFlareSystem` this flare is part of
  54775. */
  54776. constructor(
  54777. /**
  54778. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54779. */
  54780. size: number,
  54781. /**
  54782. * 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.
  54783. */
  54784. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54785. /**
  54786. * Dispose and release the lens flare with its associated resources.
  54787. */
  54788. dispose(): void;
  54789. }
  54790. }
  54791. declare module BABYLON {
  54792. interface AbstractScene {
  54793. /**
  54794. * The list of lens flare system added to the scene
  54795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54796. */
  54797. lensFlareSystems: Array<LensFlareSystem>;
  54798. /**
  54799. * Removes the given lens flare system from this scene.
  54800. * @param toRemove The lens flare system to remove
  54801. * @returns The index of the removed lens flare system
  54802. */
  54803. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54804. /**
  54805. * Adds the given lens flare system to this scene
  54806. * @param newLensFlareSystem The lens flare system to add
  54807. */
  54808. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54809. /**
  54810. * Gets a lens flare system using its name
  54811. * @param name defines the name to look for
  54812. * @returns the lens flare system or null if not found
  54813. */
  54814. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54815. /**
  54816. * Gets a lens flare system using its id
  54817. * @param id defines the id to look for
  54818. * @returns the lens flare system or null if not found
  54819. */
  54820. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54821. }
  54822. /**
  54823. * Defines the lens flare scene component responsible to manage any lens flares
  54824. * in a given scene.
  54825. */
  54826. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54827. /**
  54828. * The component name helpfull to identify the component in the list of scene components.
  54829. */
  54830. readonly name: string;
  54831. /**
  54832. * The scene the component belongs to.
  54833. */
  54834. scene: Scene;
  54835. /**
  54836. * Creates a new instance of the component for the given scene
  54837. * @param scene Defines the scene to register the component in
  54838. */
  54839. constructor(scene: Scene);
  54840. /**
  54841. * Registers the component in a given scene
  54842. */
  54843. register(): void;
  54844. /**
  54845. * Rebuilds the elements related to this component in case of
  54846. * context lost for instance.
  54847. */
  54848. rebuild(): void;
  54849. /**
  54850. * Adds all the elements from the container to the scene
  54851. * @param container the container holding the elements
  54852. */
  54853. addFromContainer(container: AbstractScene): void;
  54854. /**
  54855. * Removes all the elements in the container from the scene
  54856. * @param container contains the elements to remove
  54857. * @param dispose if the removed element should be disposed (default: false)
  54858. */
  54859. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54860. /**
  54861. * Serializes the component data to the specified json object
  54862. * @param serializationObject The object to serialize to
  54863. */
  54864. serialize(serializationObject: any): void;
  54865. /**
  54866. * Disposes the component and the associated ressources.
  54867. */
  54868. dispose(): void;
  54869. private _draw;
  54870. }
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var depthPixelShader: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export var depthVertexShader: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module BABYLON {
  54887. /**
  54888. * This represents a depth renderer in Babylon.
  54889. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54890. */
  54891. export class DepthRenderer {
  54892. private _scene;
  54893. private _depthMap;
  54894. private _effect;
  54895. private readonly _storeNonLinearDepth;
  54896. private readonly _clearColor;
  54897. /** Get if the depth renderer is using packed depth or not */
  54898. readonly isPacked: boolean;
  54899. private _cachedDefines;
  54900. private _camera;
  54901. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54902. enabled: boolean;
  54903. /**
  54904. * Specifiess that the depth renderer will only be used within
  54905. * the camera it is created for.
  54906. * This can help forcing its rendering during the camera processing.
  54907. */
  54908. useOnlyInActiveCamera: boolean;
  54909. /** @hidden */
  54910. static _SceneComponentInitialization: (scene: Scene) => void;
  54911. /**
  54912. * Instantiates a depth renderer
  54913. * @param scene The scene the renderer belongs to
  54914. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54915. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54916. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54917. */
  54918. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54919. /**
  54920. * Creates the depth rendering effect and checks if the effect is ready.
  54921. * @param subMesh The submesh to be used to render the depth map of
  54922. * @param useInstances If multiple world instances should be used
  54923. * @returns if the depth renderer is ready to render the depth map
  54924. */
  54925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54926. /**
  54927. * Gets the texture which the depth map will be written to.
  54928. * @returns The depth map texture
  54929. */
  54930. getDepthMap(): RenderTargetTexture;
  54931. /**
  54932. * Disposes of the depth renderer.
  54933. */
  54934. dispose(): void;
  54935. }
  54936. }
  54937. declare module BABYLON {
  54938. /** @hidden */
  54939. export var minmaxReduxPixelShader: {
  54940. name: string;
  54941. shader: string;
  54942. };
  54943. }
  54944. declare module BABYLON {
  54945. /**
  54946. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54947. * and maximum values from all values of the texture.
  54948. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54949. * The source values are read from the red channel of the texture.
  54950. */
  54951. export class MinMaxReducer {
  54952. /**
  54953. * Observable triggered when the computation has been performed
  54954. */
  54955. onAfterReductionPerformed: Observable<{
  54956. min: number;
  54957. max: number;
  54958. }>;
  54959. protected _camera: Camera;
  54960. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54961. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54962. protected _postProcessManager: PostProcessManager;
  54963. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54964. protected _forceFullscreenViewport: boolean;
  54965. /**
  54966. * Creates a min/max reducer
  54967. * @param camera The camera to use for the post processes
  54968. */
  54969. constructor(camera: Camera);
  54970. /**
  54971. * Gets the texture used to read the values from.
  54972. */
  54973. get sourceTexture(): Nullable<RenderTargetTexture>;
  54974. /**
  54975. * Sets the source texture to read the values from.
  54976. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54977. * because in such textures '1' value must not be taken into account to compute the maximum
  54978. * as this value is used to clear the texture.
  54979. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54980. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54981. * @param depthRedux Indicates if the texture is a depth texture or not
  54982. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54983. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54984. */
  54985. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54986. /**
  54987. * Defines the refresh rate of the computation.
  54988. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54989. */
  54990. get refreshRate(): number;
  54991. set refreshRate(value: number);
  54992. protected _activated: boolean;
  54993. /**
  54994. * Gets the activation status of the reducer
  54995. */
  54996. get activated(): boolean;
  54997. /**
  54998. * Activates the reduction computation.
  54999. * When activated, the observers registered in onAfterReductionPerformed are
  55000. * called after the compuation is performed
  55001. */
  55002. activate(): void;
  55003. /**
  55004. * Deactivates the reduction computation.
  55005. */
  55006. deactivate(): void;
  55007. /**
  55008. * Disposes the min/max reducer
  55009. * @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.
  55010. */
  55011. dispose(disposeAll?: boolean): void;
  55012. }
  55013. }
  55014. declare module BABYLON {
  55015. /**
  55016. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  55017. */
  55018. export class DepthReducer extends MinMaxReducer {
  55019. private _depthRenderer;
  55020. private _depthRendererId;
  55021. /**
  55022. * Gets the depth renderer used for the computation.
  55023. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  55024. */
  55025. get depthRenderer(): Nullable<DepthRenderer>;
  55026. /**
  55027. * Creates a depth reducer
  55028. * @param camera The camera used to render the depth texture
  55029. */
  55030. constructor(camera: Camera);
  55031. /**
  55032. * Sets the depth renderer to use to generate the depth map
  55033. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  55034. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  55035. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  55036. */
  55037. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  55038. /** @hidden */
  55039. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  55040. /**
  55041. * Activates the reduction computation.
  55042. * When activated, the observers registered in onAfterReductionPerformed are
  55043. * called after the compuation is performed
  55044. */
  55045. activate(): void;
  55046. /**
  55047. * Deactivates the reduction computation.
  55048. */
  55049. deactivate(): void;
  55050. /**
  55051. * Disposes the depth reducer
  55052. * @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.
  55053. */
  55054. dispose(disposeAll?: boolean): void;
  55055. }
  55056. }
  55057. declare module BABYLON {
  55058. /**
  55059. * A CSM implementation allowing casting shadows on large scenes.
  55060. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55061. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  55062. */
  55063. export class CascadedShadowGenerator extends ShadowGenerator {
  55064. private static readonly frustumCornersNDCSpace;
  55065. /**
  55066. * Name of the CSM class
  55067. */
  55068. static CLASSNAME: string;
  55069. /**
  55070. * Defines the default number of cascades used by the CSM.
  55071. */
  55072. static readonly DEFAULT_CASCADES_COUNT: number;
  55073. /**
  55074. * Defines the minimum number of cascades used by the CSM.
  55075. */
  55076. static readonly MIN_CASCADES_COUNT: number;
  55077. /**
  55078. * Defines the maximum number of cascades used by the CSM.
  55079. */
  55080. static readonly MAX_CASCADES_COUNT: number;
  55081. protected _validateFilter(filter: number): number;
  55082. /**
  55083. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  55084. */
  55085. penumbraDarkness: number;
  55086. private _numCascades;
  55087. /**
  55088. * Gets or set the number of cascades used by the CSM.
  55089. */
  55090. get numCascades(): number;
  55091. set numCascades(value: number);
  55092. /**
  55093. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  55094. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  55095. */
  55096. stabilizeCascades: boolean;
  55097. private _freezeShadowCastersBoundingInfo;
  55098. private _freezeShadowCastersBoundingInfoObservable;
  55099. /**
  55100. * Enables or disables the shadow casters bounding info computation.
  55101. * If your shadow casters don't move, you can disable this feature.
  55102. * If it is enabled, the bounding box computation is done every frame.
  55103. */
  55104. get freezeShadowCastersBoundingInfo(): boolean;
  55105. set freezeShadowCastersBoundingInfo(freeze: boolean);
  55106. private _scbiMin;
  55107. private _scbiMax;
  55108. protected _computeShadowCastersBoundingInfo(): void;
  55109. protected _shadowCastersBoundingInfo: BoundingInfo;
  55110. /**
  55111. * Gets or sets the shadow casters bounding info.
  55112. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  55113. * so that the system won't overwrite the bounds you provide
  55114. */
  55115. get shadowCastersBoundingInfo(): BoundingInfo;
  55116. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  55117. protected _breaksAreDirty: boolean;
  55118. protected _minDistance: number;
  55119. protected _maxDistance: number;
  55120. /**
  55121. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  55122. *
  55123. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  55124. * If you don't know these values, simply leave them to their defaults and don't call this function.
  55125. * @param min minimal distance for the breaks (default to 0.)
  55126. * @param max maximal distance for the breaks (default to 1.)
  55127. */
  55128. setMinMaxDistance(min: number, max: number): void;
  55129. /** Gets the minimal distance used in the cascade break computation */
  55130. get minDistance(): number;
  55131. /** Gets the maximal distance used in the cascade break computation */
  55132. get maxDistance(): number;
  55133. /**
  55134. * Gets the class name of that object
  55135. * @returns "CascadedShadowGenerator"
  55136. */
  55137. getClassName(): string;
  55138. private _cascadeMinExtents;
  55139. private _cascadeMaxExtents;
  55140. /**
  55141. * Gets a cascade minimum extents
  55142. * @param cascadeIndex index of the cascade
  55143. * @returns the minimum cascade extents
  55144. */
  55145. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  55146. /**
  55147. * Gets a cascade maximum extents
  55148. * @param cascadeIndex index of the cascade
  55149. * @returns the maximum cascade extents
  55150. */
  55151. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55152. private _cascades;
  55153. private _currentLayer;
  55154. private _viewSpaceFrustumsZ;
  55155. private _viewMatrices;
  55156. private _projectionMatrices;
  55157. private _transformMatrices;
  55158. private _transformMatricesAsArray;
  55159. private _frustumLengths;
  55160. private _lightSizeUVCorrection;
  55161. private _depthCorrection;
  55162. private _frustumCornersWorldSpace;
  55163. private _frustumCenter;
  55164. private _shadowCameraPos;
  55165. private _shadowMaxZ;
  55166. /**
  55167. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55168. * It defaults to camera.maxZ
  55169. */
  55170. get shadowMaxZ(): number;
  55171. /**
  55172. * Sets the shadow max z distance.
  55173. */
  55174. set shadowMaxZ(value: number);
  55175. protected _debug: boolean;
  55176. /**
  55177. * Gets or sets the debug flag.
  55178. * When enabled, the cascades are materialized by different colors on the screen.
  55179. */
  55180. get debug(): boolean;
  55181. set debug(dbg: boolean);
  55182. private _depthClamp;
  55183. /**
  55184. * Gets or sets the depth clamping value.
  55185. *
  55186. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55187. * to account for the shadow casters far away.
  55188. *
  55189. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55190. */
  55191. get depthClamp(): boolean;
  55192. set depthClamp(value: boolean);
  55193. private _cascadeBlendPercentage;
  55194. /**
  55195. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55196. * It defaults to 0.1 (10% blending).
  55197. */
  55198. get cascadeBlendPercentage(): number;
  55199. set cascadeBlendPercentage(value: number);
  55200. private _lambda;
  55201. /**
  55202. * Gets or set the lambda parameter.
  55203. * This parameter is used to split the camera frustum and create the cascades.
  55204. * 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.
  55205. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55206. */
  55207. get lambda(): number;
  55208. set lambda(value: number);
  55209. /**
  55210. * Gets the view matrix corresponding to a given cascade
  55211. * @param cascadeNum cascade to retrieve the view matrix from
  55212. * @returns the cascade view matrix
  55213. */
  55214. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55215. /**
  55216. * Gets the projection matrix corresponding to a given cascade
  55217. * @param cascadeNum cascade to retrieve the projection matrix from
  55218. * @returns the cascade projection matrix
  55219. */
  55220. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55221. /**
  55222. * Gets the transformation matrix corresponding to a given cascade
  55223. * @param cascadeNum cascade to retrieve the transformation matrix from
  55224. * @returns the cascade transformation matrix
  55225. */
  55226. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55227. private _depthRenderer;
  55228. /**
  55229. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55230. *
  55231. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55232. *
  55233. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55234. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55235. * @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
  55236. */
  55237. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55238. private _depthReducer;
  55239. private _autoCalcDepthBounds;
  55240. /**
  55241. * Gets or sets the autoCalcDepthBounds property.
  55242. *
  55243. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55244. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55245. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55246. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55247. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55248. */
  55249. get autoCalcDepthBounds(): boolean;
  55250. set autoCalcDepthBounds(value: boolean);
  55251. /**
  55252. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55253. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55254. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55255. * for setting the refresh rate on the renderer yourself!
  55256. */
  55257. get autoCalcDepthBoundsRefreshRate(): number;
  55258. set autoCalcDepthBoundsRefreshRate(value: number);
  55259. /**
  55260. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55261. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55262. * you change the camera near/far planes!
  55263. */
  55264. splitFrustum(): void;
  55265. private _splitFrustum;
  55266. private _computeMatrices;
  55267. private _computeFrustumInWorldSpace;
  55268. private _computeCascadeFrustum;
  55269. /**
  55270. * Support test.
  55271. */
  55272. static get IsSupported(): boolean;
  55273. /** @hidden */
  55274. static _SceneComponentInitialization: (scene: Scene) => void;
  55275. /**
  55276. * Creates a Cascaded Shadow Generator object.
  55277. * A ShadowGenerator is the required tool to use the shadows.
  55278. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55279. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55280. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55281. * @param light The directional light object generating the shadows.
  55282. * @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.
  55283. */
  55284. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55285. protected _initializeGenerator(): void;
  55286. protected _createTargetRenderTexture(): void;
  55287. protected _initializeShadowMap(): void;
  55288. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55289. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55290. /**
  55291. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55292. * @param defines Defines of the material we want to update
  55293. * @param lightIndex Index of the light in the enabled light list of the material
  55294. */
  55295. prepareDefines(defines: any, lightIndex: number): void;
  55296. /**
  55297. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55298. * defined in the generator but impacting the effect).
  55299. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55300. * @param effect The effect we are binfing the information for
  55301. */
  55302. bindShadowLight(lightIndex: string, effect: Effect): void;
  55303. /**
  55304. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55305. * (eq to view projection * shadow projection matrices)
  55306. * @returns The transform matrix used to create the shadow map
  55307. */
  55308. getTransformMatrix(): Matrix;
  55309. /**
  55310. * Disposes the ShadowGenerator.
  55311. * Returns nothing.
  55312. */
  55313. dispose(): void;
  55314. /**
  55315. * Serializes the shadow generator setup to a json object.
  55316. * @returns The serialized JSON object
  55317. */
  55318. serialize(): any;
  55319. /**
  55320. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55321. * @param parsedShadowGenerator The JSON object to parse
  55322. * @param scene The scene to create the shadow map for
  55323. * @returns The parsed shadow generator
  55324. */
  55325. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55326. }
  55327. }
  55328. declare module BABYLON {
  55329. /**
  55330. * Defines the shadow generator component responsible to manage any shadow generators
  55331. * in a given scene.
  55332. */
  55333. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55334. /**
  55335. * The component name helpfull to identify the component in the list of scene components.
  55336. */
  55337. readonly name: string;
  55338. /**
  55339. * The scene the component belongs to.
  55340. */
  55341. scene: Scene;
  55342. /**
  55343. * Creates a new instance of the component for the given scene
  55344. * @param scene Defines the scene to register the component in
  55345. */
  55346. constructor(scene: Scene);
  55347. /**
  55348. * Registers the component in a given scene
  55349. */
  55350. register(): void;
  55351. /**
  55352. * Rebuilds the elements related to this component in case of
  55353. * context lost for instance.
  55354. */
  55355. rebuild(): void;
  55356. /**
  55357. * Serializes the component data to the specified json object
  55358. * @param serializationObject The object to serialize to
  55359. */
  55360. serialize(serializationObject: any): void;
  55361. /**
  55362. * Adds all the elements from the container to the scene
  55363. * @param container the container holding the elements
  55364. */
  55365. addFromContainer(container: AbstractScene): void;
  55366. /**
  55367. * Removes all the elements in the container from the scene
  55368. * @param container contains the elements to remove
  55369. * @param dispose if the removed element should be disposed (default: false)
  55370. */
  55371. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55372. /**
  55373. * Rebuilds the elements related to this component in case of
  55374. * context lost for instance.
  55375. */
  55376. dispose(): void;
  55377. private _gatherRenderTargets;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * A point light is a light defined by an unique point in world space.
  55383. * The light is emitted in every direction from this point.
  55384. * A good example of a point light is a standard light bulb.
  55385. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55386. */
  55387. export class PointLight extends ShadowLight {
  55388. private _shadowAngle;
  55389. /**
  55390. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55391. * This specifies what angle the shadow will use to be created.
  55392. *
  55393. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55394. */
  55395. get shadowAngle(): number;
  55396. /**
  55397. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55398. * This specifies what angle the shadow will use to be created.
  55399. *
  55400. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55401. */
  55402. set shadowAngle(value: number);
  55403. /**
  55404. * Gets the direction if it has been set.
  55405. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55406. */
  55407. get direction(): Vector3;
  55408. /**
  55409. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55410. */
  55411. set direction(value: Vector3);
  55412. /**
  55413. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55414. * A PointLight emits the light in every direction.
  55415. * It can cast shadows.
  55416. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55417. * ```javascript
  55418. * var pointLight = new PointLight("pl", camera.position, scene);
  55419. * ```
  55420. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55421. * @param name The light friendly name
  55422. * @param position The position of the point light in the scene
  55423. * @param scene The scene the lights belongs to
  55424. */
  55425. constructor(name: string, position: Vector3, scene: Scene);
  55426. /**
  55427. * Returns the string "PointLight"
  55428. * @returns the class name
  55429. */
  55430. getClassName(): string;
  55431. /**
  55432. * Returns the integer 0.
  55433. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55434. */
  55435. getTypeID(): number;
  55436. /**
  55437. * Specifies wether or not the shadowmap should be a cube texture.
  55438. * @returns true if the shadowmap needs to be a cube texture.
  55439. */
  55440. needCube(): boolean;
  55441. /**
  55442. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55443. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55444. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55445. */
  55446. getShadowDirection(faceIndex?: number): Vector3;
  55447. /**
  55448. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55449. * - fov = PI / 2
  55450. * - aspect ratio : 1.0
  55451. * - z-near and far equal to the active camera minZ and maxZ.
  55452. * Returns the PointLight.
  55453. */
  55454. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55455. protected _buildUniformLayout(): void;
  55456. /**
  55457. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55458. * @param effect The effect to update
  55459. * @param lightIndex The index of the light in the effect to update
  55460. * @returns The point light
  55461. */
  55462. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55463. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55464. /**
  55465. * Prepares the list of defines specific to the light type.
  55466. * @param defines the list of defines
  55467. * @param lightIndex defines the index of the light for the effect
  55468. */
  55469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55470. }
  55471. }
  55472. declare module BABYLON {
  55473. /**
  55474. * Header information of HDR texture files.
  55475. */
  55476. export interface HDRInfo {
  55477. /**
  55478. * The height of the texture in pixels.
  55479. */
  55480. height: number;
  55481. /**
  55482. * The width of the texture in pixels.
  55483. */
  55484. width: number;
  55485. /**
  55486. * The index of the beginning of the data in the binary file.
  55487. */
  55488. dataPosition: number;
  55489. }
  55490. /**
  55491. * This groups tools to convert HDR texture to native colors array.
  55492. */
  55493. export class HDRTools {
  55494. private static Ldexp;
  55495. private static Rgbe2float;
  55496. private static readStringLine;
  55497. /**
  55498. * Reads header information from an RGBE texture stored in a native array.
  55499. * More information on this format are available here:
  55500. * https://en.wikipedia.org/wiki/RGBE_image_format
  55501. *
  55502. * @param uint8array The binary file stored in native array.
  55503. * @return The header information.
  55504. */
  55505. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55506. /**
  55507. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55508. * This RGBE texture needs to store the information as a panorama.
  55509. *
  55510. * More information on this format are available here:
  55511. * https://en.wikipedia.org/wiki/RGBE_image_format
  55512. *
  55513. * @param buffer The binary file stored in an array buffer.
  55514. * @param size The expected size of the extracted cubemap.
  55515. * @return The Cube Map information.
  55516. */
  55517. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55518. /**
  55519. * Returns the pixels data extracted from an RGBE texture.
  55520. * This pixels will be stored left to right up to down in the R G B order in one array.
  55521. *
  55522. * More information on this format are available here:
  55523. * https://en.wikipedia.org/wiki/RGBE_image_format
  55524. *
  55525. * @param uint8array The binary file stored in an array buffer.
  55526. * @param hdrInfo The header information of the file.
  55527. * @return The pixels data in RGB right to left up to down order.
  55528. */
  55529. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55530. private static RGBE_ReadPixels_RLE;
  55531. }
  55532. }
  55533. declare module BABYLON {
  55534. /**
  55535. * This represents a texture coming from an HDR input.
  55536. *
  55537. * The only supported format is currently panorama picture stored in RGBE format.
  55538. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55539. */
  55540. export class HDRCubeTexture extends BaseTexture {
  55541. private static _facesMapping;
  55542. private _generateHarmonics;
  55543. private _noMipmap;
  55544. private _textureMatrix;
  55545. private _size;
  55546. private _onLoad;
  55547. private _onError;
  55548. /**
  55549. * The texture URL.
  55550. */
  55551. url: string;
  55552. /**
  55553. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55554. */
  55555. coordinatesMode: number;
  55556. protected _isBlocking: boolean;
  55557. /**
  55558. * Sets wether or not the texture is blocking during loading.
  55559. */
  55560. set isBlocking(value: boolean);
  55561. /**
  55562. * Gets wether or not the texture is blocking during loading.
  55563. */
  55564. get isBlocking(): boolean;
  55565. protected _rotationY: number;
  55566. /**
  55567. * Sets texture matrix rotation angle around Y axis in radians.
  55568. */
  55569. set rotationY(value: number);
  55570. /**
  55571. * Gets texture matrix rotation angle around Y axis radians.
  55572. */
  55573. get rotationY(): number;
  55574. /**
  55575. * Gets or sets the center of the bounding box associated with the cube texture
  55576. * It must define where the camera used to render the texture was set
  55577. */
  55578. boundingBoxPosition: Vector3;
  55579. private _boundingBoxSize;
  55580. /**
  55581. * Gets or sets the size of the bounding box associated with the cube texture
  55582. * When defined, the cubemap will switch to local mode
  55583. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55584. * @example https://www.babylonjs-playground.com/#RNASML
  55585. */
  55586. set boundingBoxSize(value: Vector3);
  55587. get boundingBoxSize(): Vector3;
  55588. /**
  55589. * Instantiates an HDRTexture from the following parameters.
  55590. *
  55591. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55592. * @param sceneOrEngine The scene or engine the texture will be used in
  55593. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55594. * @param noMipmap Forces to not generate the mipmap if true
  55595. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55596. * @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)
  55597. * @param reserved Reserved flag for internal use.
  55598. */
  55599. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55600. /**
  55601. * Get the current class name of the texture useful for serialization or dynamic coding.
  55602. * @returns "HDRCubeTexture"
  55603. */
  55604. getClassName(): string;
  55605. /**
  55606. * Occurs when the file is raw .hdr file.
  55607. */
  55608. private loadTexture;
  55609. clone(): HDRCubeTexture;
  55610. delayLoad(): void;
  55611. /**
  55612. * Get the texture reflection matrix used to rotate/transform the reflection.
  55613. * @returns the reflection matrix
  55614. */
  55615. getReflectionTextureMatrix(): Matrix;
  55616. /**
  55617. * Set the texture reflection matrix used to rotate/transform the reflection.
  55618. * @param value Define the reflection matrix to set
  55619. */
  55620. setReflectionTextureMatrix(value: Matrix): void;
  55621. /**
  55622. * Parses a JSON representation of an HDR Texture in order to create the texture
  55623. * @param parsedTexture Define the JSON representation
  55624. * @param scene Define the scene the texture should be created in
  55625. * @param rootUrl Define the root url in case we need to load relative dependencies
  55626. * @returns the newly created texture after parsing
  55627. */
  55628. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55629. serialize(): any;
  55630. }
  55631. }
  55632. declare module BABYLON {
  55633. /**
  55634. * Class used to control physics engine
  55635. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55636. */
  55637. export class PhysicsEngine implements IPhysicsEngine {
  55638. private _physicsPlugin;
  55639. /**
  55640. * Global value used to control the smallest number supported by the simulation
  55641. */
  55642. static Epsilon: number;
  55643. private _impostors;
  55644. private _joints;
  55645. private _subTimeStep;
  55646. /**
  55647. * Gets the gravity vector used by the simulation
  55648. */
  55649. gravity: Vector3;
  55650. /**
  55651. * Factory used to create the default physics plugin.
  55652. * @returns The default physics plugin
  55653. */
  55654. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55655. /**
  55656. * Creates a new Physics Engine
  55657. * @param gravity defines the gravity vector used by the simulation
  55658. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55659. */
  55660. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55661. /**
  55662. * Sets the gravity vector used by the simulation
  55663. * @param gravity defines the gravity vector to use
  55664. */
  55665. setGravity(gravity: Vector3): void;
  55666. /**
  55667. * Set the time step of the physics engine.
  55668. * Default is 1/60.
  55669. * To slow it down, enter 1/600 for example.
  55670. * To speed it up, 1/30
  55671. * @param newTimeStep defines the new timestep to apply to this world.
  55672. */
  55673. setTimeStep(newTimeStep?: number): void;
  55674. /**
  55675. * Get the time step of the physics engine.
  55676. * @returns the current time step
  55677. */
  55678. getTimeStep(): number;
  55679. /**
  55680. * Set the sub time step of the physics engine.
  55681. * Default is 0 meaning there is no sub steps
  55682. * To increase physics resolution precision, set a small value (like 1 ms)
  55683. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55684. */
  55685. setSubTimeStep(subTimeStep?: number): void;
  55686. /**
  55687. * Get the sub time step of the physics engine.
  55688. * @returns the current sub time step
  55689. */
  55690. getSubTimeStep(): number;
  55691. /**
  55692. * Release all resources
  55693. */
  55694. dispose(): void;
  55695. /**
  55696. * Gets the name of the current physics plugin
  55697. * @returns the name of the plugin
  55698. */
  55699. getPhysicsPluginName(): string;
  55700. /**
  55701. * Adding a new impostor for the impostor tracking.
  55702. * This will be done by the impostor itself.
  55703. * @param impostor the impostor to add
  55704. */
  55705. addImpostor(impostor: PhysicsImpostor): void;
  55706. /**
  55707. * Remove an impostor from the engine.
  55708. * This impostor and its mesh will not longer be updated by the physics engine.
  55709. * @param impostor the impostor to remove
  55710. */
  55711. removeImpostor(impostor: PhysicsImpostor): void;
  55712. /**
  55713. * Add a joint to the physics engine
  55714. * @param mainImpostor defines the main impostor to which the joint is added.
  55715. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55716. * @param joint defines the joint that will connect both impostors.
  55717. */
  55718. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55719. /**
  55720. * Removes a joint from the simulation
  55721. * @param mainImpostor defines the impostor used with the joint
  55722. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55723. * @param joint defines the joint to remove
  55724. */
  55725. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55726. /**
  55727. * Called by the scene. No need to call it.
  55728. * @param delta defines the timespam between frames
  55729. */
  55730. _step(delta: number): void;
  55731. /**
  55732. * Gets the current plugin used to run the simulation
  55733. * @returns current plugin
  55734. */
  55735. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55736. /**
  55737. * Gets the list of physic impostors
  55738. * @returns an array of PhysicsImpostor
  55739. */
  55740. getImpostors(): Array<PhysicsImpostor>;
  55741. /**
  55742. * Gets the impostor for a physics enabled object
  55743. * @param object defines the object impersonated by the impostor
  55744. * @returns the PhysicsImpostor or null if not found
  55745. */
  55746. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55747. /**
  55748. * Gets the impostor for a physics body object
  55749. * @param body defines physics body used by the impostor
  55750. * @returns the PhysicsImpostor or null if not found
  55751. */
  55752. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55753. /**
  55754. * Does a raycast in the physics world
  55755. * @param from when should the ray start?
  55756. * @param to when should the ray end?
  55757. * @returns PhysicsRaycastResult
  55758. */
  55759. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55760. }
  55761. }
  55762. declare module BABYLON {
  55763. /** @hidden */
  55764. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55765. private _useDeltaForWorldStep;
  55766. world: any;
  55767. name: string;
  55768. private _physicsMaterials;
  55769. private _fixedTimeStep;
  55770. private _cannonRaycastResult;
  55771. private _raycastResult;
  55772. private _physicsBodysToRemoveAfterStep;
  55773. BJSCANNON: any;
  55774. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55775. setGravity(gravity: Vector3): void;
  55776. setTimeStep(timeStep: number): void;
  55777. getTimeStep(): number;
  55778. executeStep(delta: number): void;
  55779. private _removeMarkedPhysicsBodiesFromWorld;
  55780. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55781. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55782. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55783. private _processChildMeshes;
  55784. removePhysicsBody(impostor: PhysicsImpostor): void;
  55785. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55786. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55787. private _addMaterial;
  55788. private _checkWithEpsilon;
  55789. private _createShape;
  55790. private _createHeightmap;
  55791. private _minus90X;
  55792. private _plus90X;
  55793. private _tmpPosition;
  55794. private _tmpDeltaPosition;
  55795. private _tmpUnityRotation;
  55796. private _updatePhysicsBodyTransformation;
  55797. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55798. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55799. isSupported(): boolean;
  55800. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55801. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55802. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55805. getBodyMass(impostor: PhysicsImpostor): number;
  55806. getBodyFriction(impostor: PhysicsImpostor): number;
  55807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55808. getBodyRestitution(impostor: PhysicsImpostor): number;
  55809. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55810. sleepBody(impostor: PhysicsImpostor): void;
  55811. wakeUpBody(impostor: PhysicsImpostor): void;
  55812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55813. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55816. getRadius(impostor: PhysicsImpostor): number;
  55817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55818. dispose(): void;
  55819. private _extendNamespace;
  55820. /**
  55821. * Does a raycast in the physics world
  55822. * @param from when should the ray start?
  55823. * @param to when should the ray end?
  55824. * @returns PhysicsRaycastResult
  55825. */
  55826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55827. }
  55828. }
  55829. declare module BABYLON {
  55830. /** @hidden */
  55831. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55832. private _useDeltaForWorldStep;
  55833. world: any;
  55834. name: string;
  55835. BJSOIMO: any;
  55836. private _raycastResult;
  55837. private _fixedTimeStep;
  55838. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55839. setGravity(gravity: Vector3): void;
  55840. setTimeStep(timeStep: number): void;
  55841. getTimeStep(): number;
  55842. private _tmpImpostorsArray;
  55843. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55844. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55846. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55847. private _tmpPositionVector;
  55848. removePhysicsBody(impostor: PhysicsImpostor): void;
  55849. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55850. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55851. isSupported(): boolean;
  55852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55854. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55855. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55857. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55858. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55859. getBodyMass(impostor: PhysicsImpostor): number;
  55860. getBodyFriction(impostor: PhysicsImpostor): number;
  55861. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55862. getBodyRestitution(impostor: PhysicsImpostor): number;
  55863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55864. sleepBody(impostor: PhysicsImpostor): void;
  55865. wakeUpBody(impostor: PhysicsImpostor): void;
  55866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55867. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55870. getRadius(impostor: PhysicsImpostor): number;
  55871. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55872. dispose(): void;
  55873. /**
  55874. * Does a raycast in the physics world
  55875. * @param from when should the ray start?
  55876. * @param to when should the ray end?
  55877. * @returns PhysicsRaycastResult
  55878. */
  55879. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55880. }
  55881. }
  55882. declare module BABYLON {
  55883. /**
  55884. * Class containing static functions to help procedurally build meshes
  55885. */
  55886. export class RibbonBuilder {
  55887. /**
  55888. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55889. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55890. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55891. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55892. * * 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
  55893. * * 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
  55894. * * 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
  55895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55896. * * 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
  55897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55898. * * 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
  55899. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55900. * * 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
  55901. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55903. * @param name defines the name of the mesh
  55904. * @param options defines the options used to create the mesh
  55905. * @param scene defines the hosting scene
  55906. * @returns the ribbon mesh
  55907. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55909. */
  55910. static CreateRibbon(name: string, options: {
  55911. pathArray: Vector3[][];
  55912. closeArray?: boolean;
  55913. closePath?: boolean;
  55914. offset?: number;
  55915. updatable?: boolean;
  55916. sideOrientation?: number;
  55917. frontUVs?: Vector4;
  55918. backUVs?: Vector4;
  55919. instance?: Mesh;
  55920. invertUV?: boolean;
  55921. uvs?: Vector2[];
  55922. colors?: Color4[];
  55923. }, scene?: Nullable<Scene>): Mesh;
  55924. }
  55925. }
  55926. declare module BABYLON {
  55927. /**
  55928. * Class containing static functions to help procedurally build meshes
  55929. */
  55930. export class ShapeBuilder {
  55931. /**
  55932. * 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.
  55933. * * 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.
  55934. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55935. * * 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.
  55936. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55937. * * 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
  55938. * * 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
  55939. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55941. * * 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
  55942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55944. * @param name defines the name of the mesh
  55945. * @param options defines the options used to create the mesh
  55946. * @param scene defines the hosting scene
  55947. * @returns the extruded shape mesh
  55948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55950. */
  55951. static ExtrudeShape(name: string, options: {
  55952. shape: Vector3[];
  55953. path: Vector3[];
  55954. scale?: number;
  55955. rotation?: number;
  55956. cap?: number;
  55957. updatable?: boolean;
  55958. sideOrientation?: number;
  55959. frontUVs?: Vector4;
  55960. backUVs?: Vector4;
  55961. instance?: Mesh;
  55962. invertUV?: boolean;
  55963. }, scene?: Nullable<Scene>): Mesh;
  55964. /**
  55965. * Creates an custom extruded shape mesh.
  55966. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55967. * * 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.
  55968. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55969. * * 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
  55970. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55971. * * 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
  55972. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55973. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55974. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55975. * * 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
  55976. * * 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
  55977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55979. * * 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
  55980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55982. * @param name defines the name of the mesh
  55983. * @param options defines the options used to create the mesh
  55984. * @param scene defines the hosting scene
  55985. * @returns the custom extruded shape mesh
  55986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55989. */
  55990. static ExtrudeShapeCustom(name: string, options: {
  55991. shape: Vector3[];
  55992. path: Vector3[];
  55993. scaleFunction?: any;
  55994. rotationFunction?: any;
  55995. ribbonCloseArray?: boolean;
  55996. ribbonClosePath?: boolean;
  55997. cap?: number;
  55998. updatable?: boolean;
  55999. sideOrientation?: number;
  56000. frontUVs?: Vector4;
  56001. backUVs?: Vector4;
  56002. instance?: Mesh;
  56003. invertUV?: boolean;
  56004. }, scene?: Nullable<Scene>): Mesh;
  56005. private static _ExtrudeShapeGeneric;
  56006. }
  56007. }
  56008. declare module BABYLON {
  56009. /**
  56010. * AmmoJS Physics plugin
  56011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56012. * @see https://github.com/kripken/ammo.js/
  56013. */
  56014. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56015. private _useDeltaForWorldStep;
  56016. /**
  56017. * Reference to the Ammo library
  56018. */
  56019. bjsAMMO: any;
  56020. /**
  56021. * Created ammoJS world which physics bodies are added to
  56022. */
  56023. world: any;
  56024. /**
  56025. * Name of the plugin
  56026. */
  56027. name: string;
  56028. private _timeStep;
  56029. private _fixedTimeStep;
  56030. private _maxSteps;
  56031. private _tmpQuaternion;
  56032. private _tmpAmmoTransform;
  56033. private _tmpAmmoQuaternion;
  56034. private _tmpAmmoConcreteContactResultCallback;
  56035. private _collisionConfiguration;
  56036. private _dispatcher;
  56037. private _overlappingPairCache;
  56038. private _solver;
  56039. private _softBodySolver;
  56040. private _tmpAmmoVectorA;
  56041. private _tmpAmmoVectorB;
  56042. private _tmpAmmoVectorC;
  56043. private _tmpAmmoVectorD;
  56044. private _tmpContactCallbackResult;
  56045. private _tmpAmmoVectorRCA;
  56046. private _tmpAmmoVectorRCB;
  56047. private _raycastResult;
  56048. private static readonly DISABLE_COLLISION_FLAG;
  56049. private static readonly KINEMATIC_FLAG;
  56050. private static readonly DISABLE_DEACTIVATION_FLAG;
  56051. /**
  56052. * Initializes the ammoJS plugin
  56053. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56054. * @param ammoInjection can be used to inject your own ammo reference
  56055. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56056. */
  56057. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56058. /**
  56059. * Sets the gravity of the physics world (m/(s^2))
  56060. * @param gravity Gravity to set
  56061. */
  56062. setGravity(gravity: Vector3): void;
  56063. /**
  56064. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56065. * @param timeStep timestep to use in seconds
  56066. */
  56067. setTimeStep(timeStep: number): void;
  56068. /**
  56069. * 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)
  56070. * @param fixedTimeStep fixedTimeStep to use in seconds
  56071. */
  56072. setFixedTimeStep(fixedTimeStep: number): void;
  56073. /**
  56074. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56075. * @param maxSteps the maximum number of steps by the physics engine per frame
  56076. */
  56077. setMaxSteps(maxSteps: number): void;
  56078. /**
  56079. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56080. * @returns the current timestep in seconds
  56081. */
  56082. getTimeStep(): number;
  56083. /**
  56084. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56085. */
  56086. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56087. private _isImpostorInContact;
  56088. private _isImpostorPairInContact;
  56089. private _stepSimulation;
  56090. /**
  56091. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56092. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56093. * After the step the babylon meshes are set to the position of the physics imposters
  56094. * @param delta amount of time to step forward
  56095. * @param impostors array of imposters to update before/after the step
  56096. */
  56097. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56098. /**
  56099. * Update babylon mesh to match physics world object
  56100. * @param impostor imposter to match
  56101. */
  56102. private _afterSoftStep;
  56103. /**
  56104. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56105. * @param impostor imposter to match
  56106. */
  56107. private _ropeStep;
  56108. /**
  56109. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56110. * @param impostor imposter to match
  56111. */
  56112. private _softbodyOrClothStep;
  56113. private _tmpMatrix;
  56114. /**
  56115. * Applies an impulse on the imposter
  56116. * @param impostor imposter to apply impulse to
  56117. * @param force amount of force to be applied to the imposter
  56118. * @param contactPoint the location to apply the impulse on the imposter
  56119. */
  56120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56121. /**
  56122. * Applies a force on the imposter
  56123. * @param impostor imposter to apply force
  56124. * @param force amount of force to be applied to the imposter
  56125. * @param contactPoint the location to apply the force on the imposter
  56126. */
  56127. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56128. /**
  56129. * Creates a physics body using the plugin
  56130. * @param impostor the imposter to create the physics body on
  56131. */
  56132. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56133. /**
  56134. * Removes the physics body from the imposter and disposes of the body's memory
  56135. * @param impostor imposter to remove the physics body from
  56136. */
  56137. removePhysicsBody(impostor: PhysicsImpostor): void;
  56138. /**
  56139. * Generates a joint
  56140. * @param impostorJoint the imposter joint to create the joint with
  56141. */
  56142. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56143. /**
  56144. * Removes a joint
  56145. * @param impostorJoint the imposter joint to remove the joint from
  56146. */
  56147. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56148. private _addMeshVerts;
  56149. /**
  56150. * Initialise the soft body vertices to match its object's (mesh) vertices
  56151. * Softbody vertices (nodes) are in world space and to match this
  56152. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56153. * @param impostor to create the softbody for
  56154. */
  56155. private _softVertexData;
  56156. /**
  56157. * Create an impostor's soft body
  56158. * @param impostor to create the softbody for
  56159. */
  56160. private _createSoftbody;
  56161. /**
  56162. * Create cloth for an impostor
  56163. * @param impostor to create the softbody for
  56164. */
  56165. private _createCloth;
  56166. /**
  56167. * Create rope for an impostor
  56168. * @param impostor to create the softbody for
  56169. */
  56170. private _createRope;
  56171. /**
  56172. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56173. * @param impostor to create the custom physics shape for
  56174. */
  56175. private _createCustom;
  56176. private _addHullVerts;
  56177. private _createShape;
  56178. /**
  56179. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56180. * @param impostor imposter containing the physics body and babylon object
  56181. */
  56182. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56183. /**
  56184. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56185. * @param impostor imposter containing the physics body and babylon object
  56186. * @param newPosition new position
  56187. * @param newRotation new rotation
  56188. */
  56189. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56190. /**
  56191. * If this plugin is supported
  56192. * @returns true if its supported
  56193. */
  56194. isSupported(): boolean;
  56195. /**
  56196. * Sets the linear velocity of the physics body
  56197. * @param impostor imposter to set the velocity on
  56198. * @param velocity velocity to set
  56199. */
  56200. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56201. /**
  56202. * Sets the angular velocity of the physics body
  56203. * @param impostor imposter to set the velocity on
  56204. * @param velocity velocity to set
  56205. */
  56206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56207. /**
  56208. * gets the linear velocity
  56209. * @param impostor imposter to get linear velocity from
  56210. * @returns linear velocity
  56211. */
  56212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56213. /**
  56214. * gets the angular velocity
  56215. * @param impostor imposter to get angular velocity from
  56216. * @returns angular velocity
  56217. */
  56218. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56219. /**
  56220. * Sets the mass of physics body
  56221. * @param impostor imposter to set the mass on
  56222. * @param mass mass to set
  56223. */
  56224. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56225. /**
  56226. * Gets the mass of the physics body
  56227. * @param impostor imposter to get the mass from
  56228. * @returns mass
  56229. */
  56230. getBodyMass(impostor: PhysicsImpostor): number;
  56231. /**
  56232. * Gets friction of the impostor
  56233. * @param impostor impostor to get friction from
  56234. * @returns friction value
  56235. */
  56236. getBodyFriction(impostor: PhysicsImpostor): number;
  56237. /**
  56238. * Sets friction of the impostor
  56239. * @param impostor impostor to set friction on
  56240. * @param friction friction value
  56241. */
  56242. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56243. /**
  56244. * Gets restitution of the impostor
  56245. * @param impostor impostor to get restitution from
  56246. * @returns restitution value
  56247. */
  56248. getBodyRestitution(impostor: PhysicsImpostor): number;
  56249. /**
  56250. * Sets resitution of the impostor
  56251. * @param impostor impostor to set resitution on
  56252. * @param restitution resitution value
  56253. */
  56254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56255. /**
  56256. * Gets pressure inside the impostor
  56257. * @param impostor impostor to get pressure from
  56258. * @returns pressure value
  56259. */
  56260. getBodyPressure(impostor: PhysicsImpostor): number;
  56261. /**
  56262. * Sets pressure inside a soft body impostor
  56263. * Cloth and rope must remain 0 pressure
  56264. * @param impostor impostor to set pressure on
  56265. * @param pressure pressure value
  56266. */
  56267. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56268. /**
  56269. * Gets stiffness of the impostor
  56270. * @param impostor impostor to get stiffness from
  56271. * @returns pressure value
  56272. */
  56273. getBodyStiffness(impostor: PhysicsImpostor): number;
  56274. /**
  56275. * Sets stiffness of the impostor
  56276. * @param impostor impostor to set stiffness on
  56277. * @param stiffness stiffness value from 0 to 1
  56278. */
  56279. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56280. /**
  56281. * Gets velocityIterations of the impostor
  56282. * @param impostor impostor to get velocity iterations from
  56283. * @returns velocityIterations value
  56284. */
  56285. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56286. /**
  56287. * Sets velocityIterations of the impostor
  56288. * @param impostor impostor to set velocity iterations on
  56289. * @param velocityIterations velocityIterations value
  56290. */
  56291. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56292. /**
  56293. * Gets positionIterations of the impostor
  56294. * @param impostor impostor to get position iterations from
  56295. * @returns positionIterations value
  56296. */
  56297. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56298. /**
  56299. * Sets positionIterations of the impostor
  56300. * @param impostor impostor to set position on
  56301. * @param positionIterations positionIterations value
  56302. */
  56303. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56304. /**
  56305. * Append an anchor to a cloth object
  56306. * @param impostor is the cloth impostor to add anchor to
  56307. * @param otherImpostor is the rigid impostor to anchor to
  56308. * @param width ratio across width from 0 to 1
  56309. * @param height ratio up height from 0 to 1
  56310. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56311. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56312. */
  56313. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56314. /**
  56315. * Append an hook to a rope object
  56316. * @param impostor is the rope impostor to add hook to
  56317. * @param otherImpostor is the rigid impostor to hook to
  56318. * @param length ratio along the rope from 0 to 1
  56319. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56320. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56321. */
  56322. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56323. /**
  56324. * Sleeps the physics body and stops it from being active
  56325. * @param impostor impostor to sleep
  56326. */
  56327. sleepBody(impostor: PhysicsImpostor): void;
  56328. /**
  56329. * Activates the physics body
  56330. * @param impostor impostor to activate
  56331. */
  56332. wakeUpBody(impostor: PhysicsImpostor): void;
  56333. /**
  56334. * Updates the distance parameters of the joint
  56335. * @param joint joint to update
  56336. * @param maxDistance maximum distance of the joint
  56337. * @param minDistance minimum distance of the joint
  56338. */
  56339. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56340. /**
  56341. * Sets a motor on the joint
  56342. * @param joint joint to set motor on
  56343. * @param speed speed of the motor
  56344. * @param maxForce maximum force of the motor
  56345. * @param motorIndex index of the motor
  56346. */
  56347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56348. /**
  56349. * Sets the motors limit
  56350. * @param joint joint to set limit on
  56351. * @param upperLimit upper limit
  56352. * @param lowerLimit lower limit
  56353. */
  56354. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56355. /**
  56356. * Syncs the position and rotation of a mesh with the impostor
  56357. * @param mesh mesh to sync
  56358. * @param impostor impostor to update the mesh with
  56359. */
  56360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56361. /**
  56362. * Gets the radius of the impostor
  56363. * @param impostor impostor to get radius from
  56364. * @returns the radius
  56365. */
  56366. getRadius(impostor: PhysicsImpostor): number;
  56367. /**
  56368. * Gets the box size of the impostor
  56369. * @param impostor impostor to get box size from
  56370. * @param result the resulting box size
  56371. */
  56372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56373. /**
  56374. * Disposes of the impostor
  56375. */
  56376. dispose(): void;
  56377. /**
  56378. * Does a raycast in the physics world
  56379. * @param from when should the ray start?
  56380. * @param to when should the ray end?
  56381. * @returns PhysicsRaycastResult
  56382. */
  56383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56384. }
  56385. }
  56386. declare module BABYLON {
  56387. interface AbstractScene {
  56388. /**
  56389. * The list of reflection probes added to the scene
  56390. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56391. */
  56392. reflectionProbes: Array<ReflectionProbe>;
  56393. /**
  56394. * Removes the given reflection probe from this scene.
  56395. * @param toRemove The reflection probe to remove
  56396. * @returns The index of the removed reflection probe
  56397. */
  56398. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56399. /**
  56400. * Adds the given reflection probe to this scene.
  56401. * @param newReflectionProbe The reflection probe to add
  56402. */
  56403. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56404. }
  56405. /**
  56406. * Class used to generate realtime reflection / refraction cube textures
  56407. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56408. */
  56409. export class ReflectionProbe {
  56410. /** defines the name of the probe */
  56411. name: string;
  56412. private _scene;
  56413. private _renderTargetTexture;
  56414. private _projectionMatrix;
  56415. private _viewMatrix;
  56416. private _target;
  56417. private _add;
  56418. private _attachedMesh;
  56419. private _invertYAxis;
  56420. /** Gets or sets probe position (center of the cube map) */
  56421. position: Vector3;
  56422. /**
  56423. * Creates a new reflection probe
  56424. * @param name defines the name of the probe
  56425. * @param size defines the texture resolution (for each face)
  56426. * @param scene defines the hosting scene
  56427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56429. */
  56430. constructor(
  56431. /** defines the name of the probe */
  56432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56434. get samples(): number;
  56435. set samples(value: number);
  56436. /** Gets or sets the refresh rate to use (on every frame by default) */
  56437. get refreshRate(): number;
  56438. set refreshRate(value: number);
  56439. /**
  56440. * Gets the hosting scene
  56441. * @returns a Scene
  56442. */
  56443. getScene(): Scene;
  56444. /** Gets the internal CubeTexture used to render to */
  56445. get cubeTexture(): RenderTargetTexture;
  56446. /** Gets the list of meshes to render */
  56447. get renderList(): Nullable<AbstractMesh[]>;
  56448. /**
  56449. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56450. * @param mesh defines the mesh to attach to
  56451. */
  56452. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56453. /**
  56454. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56455. * @param renderingGroupId The rendering group id corresponding to its index
  56456. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56457. */
  56458. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56459. /**
  56460. * Clean all associated resources
  56461. */
  56462. dispose(): void;
  56463. /**
  56464. * Converts the reflection probe information to a readable string for debug purpose.
  56465. * @param fullDetails Supports for multiple levels of logging within scene loading
  56466. * @returns the human readable reflection probe info
  56467. */
  56468. toString(fullDetails?: boolean): string;
  56469. /**
  56470. * Get the class name of the relfection probe.
  56471. * @returns "ReflectionProbe"
  56472. */
  56473. getClassName(): string;
  56474. /**
  56475. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56476. * @returns The JSON representation of the texture
  56477. */
  56478. serialize(): any;
  56479. /**
  56480. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56481. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56482. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56483. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56484. * @returns The parsed reflection probe if successful
  56485. */
  56486. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /** @hidden */
  56491. export var _BabylonLoaderRegistered: boolean;
  56492. /**
  56493. * Helps setting up some configuration for the babylon file loader.
  56494. */
  56495. export class BabylonFileLoaderConfiguration {
  56496. /**
  56497. * The loader does not allow injecting custom physix engine into the plugins.
  56498. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56499. * So you could set this variable to your engine import to make it work.
  56500. */
  56501. static LoaderInjectedPhysicsEngine: any;
  56502. }
  56503. }
  56504. declare module BABYLON {
  56505. /**
  56506. * The Physically based simple base material of BJS.
  56507. *
  56508. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56509. * It is used as the base class for both the specGloss and metalRough conventions.
  56510. */
  56511. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56512. /**
  56513. * Number of Simultaneous lights allowed on the material.
  56514. */
  56515. maxSimultaneousLights: number;
  56516. /**
  56517. * If sets to true, disables all the lights affecting the material.
  56518. */
  56519. disableLighting: boolean;
  56520. /**
  56521. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56522. */
  56523. environmentTexture: BaseTexture;
  56524. /**
  56525. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56526. */
  56527. invertNormalMapX: boolean;
  56528. /**
  56529. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56530. */
  56531. invertNormalMapY: boolean;
  56532. /**
  56533. * Normal map used in the model.
  56534. */
  56535. normalTexture: BaseTexture;
  56536. /**
  56537. * Emissivie color used to self-illuminate the model.
  56538. */
  56539. emissiveColor: Color3;
  56540. /**
  56541. * Emissivie texture used to self-illuminate the model.
  56542. */
  56543. emissiveTexture: BaseTexture;
  56544. /**
  56545. * Occlusion Channel Strenght.
  56546. */
  56547. occlusionStrength: number;
  56548. /**
  56549. * Occlusion Texture of the material (adding extra occlusion effects).
  56550. */
  56551. occlusionTexture: BaseTexture;
  56552. /**
  56553. * Defines the alpha limits in alpha test mode.
  56554. */
  56555. alphaCutOff: number;
  56556. /**
  56557. * Gets the current double sided mode.
  56558. */
  56559. get doubleSided(): boolean;
  56560. /**
  56561. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56562. */
  56563. set doubleSided(value: boolean);
  56564. /**
  56565. * Stores the pre-calculated light information of a mesh in a texture.
  56566. */
  56567. lightmapTexture: BaseTexture;
  56568. /**
  56569. * If true, the light map contains occlusion information instead of lighting info.
  56570. */
  56571. useLightmapAsShadowmap: boolean;
  56572. /**
  56573. * Instantiates a new PBRMaterial instance.
  56574. *
  56575. * @param name The material name
  56576. * @param scene The scene the material will be use in.
  56577. */
  56578. constructor(name: string, scene: Scene);
  56579. getClassName(): string;
  56580. }
  56581. }
  56582. declare module BABYLON {
  56583. /**
  56584. * The PBR material of BJS following the metal roughness convention.
  56585. *
  56586. * This fits to the PBR convention in the GLTF definition:
  56587. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56588. */
  56589. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56590. /**
  56591. * The base color has two different interpretations depending on the value of metalness.
  56592. * When the material is a metal, the base color is the specific measured reflectance value
  56593. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56594. * of the material.
  56595. */
  56596. baseColor: Color3;
  56597. /**
  56598. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56599. * well as opacity information in the alpha channel.
  56600. */
  56601. baseTexture: BaseTexture;
  56602. /**
  56603. * Specifies the metallic scalar value of the material.
  56604. * Can also be used to scale the metalness values of the metallic texture.
  56605. */
  56606. metallic: number;
  56607. /**
  56608. * Specifies the roughness scalar value of the material.
  56609. * Can also be used to scale the roughness values of the metallic texture.
  56610. */
  56611. roughness: number;
  56612. /**
  56613. * Texture containing both the metallic value in the B channel and the
  56614. * roughness value in the G channel to keep better precision.
  56615. */
  56616. metallicRoughnessTexture: BaseTexture;
  56617. /**
  56618. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56619. *
  56620. * @param name The material name
  56621. * @param scene The scene the material will be use in.
  56622. */
  56623. constructor(name: string, scene: Scene);
  56624. /**
  56625. * Return the currrent class name of the material.
  56626. */
  56627. getClassName(): string;
  56628. /**
  56629. * Makes a duplicate of the current material.
  56630. * @param name - name to use for the new material.
  56631. */
  56632. clone(name: string): PBRMetallicRoughnessMaterial;
  56633. /**
  56634. * Serialize the material to a parsable JSON object.
  56635. */
  56636. serialize(): any;
  56637. /**
  56638. * Parses a JSON object correponding to the serialize function.
  56639. */
  56640. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /**
  56645. * The PBR material of BJS following the specular glossiness convention.
  56646. *
  56647. * This fits to the PBR convention in the GLTF definition:
  56648. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56649. */
  56650. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56651. /**
  56652. * Specifies the diffuse color of the material.
  56653. */
  56654. diffuseColor: Color3;
  56655. /**
  56656. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56657. * channel.
  56658. */
  56659. diffuseTexture: BaseTexture;
  56660. /**
  56661. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56662. */
  56663. specularColor: Color3;
  56664. /**
  56665. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56666. */
  56667. glossiness: number;
  56668. /**
  56669. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56670. */
  56671. specularGlossinessTexture: BaseTexture;
  56672. /**
  56673. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56674. *
  56675. * @param name The material name
  56676. * @param scene The scene the material will be use in.
  56677. */
  56678. constructor(name: string, scene: Scene);
  56679. /**
  56680. * Return the currrent class name of the material.
  56681. */
  56682. getClassName(): string;
  56683. /**
  56684. * Makes a duplicate of the current material.
  56685. * @param name - name to use for the new material.
  56686. */
  56687. clone(name: string): PBRSpecularGlossinessMaterial;
  56688. /**
  56689. * Serialize the material to a parsable JSON object.
  56690. */
  56691. serialize(): any;
  56692. /**
  56693. * Parses a JSON object correponding to the serialize function.
  56694. */
  56695. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56696. }
  56697. }
  56698. declare module BABYLON {
  56699. /**
  56700. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56701. * It can help converting any input color in a desired output one. This can then be used to create effects
  56702. * from sepia, black and white to sixties or futuristic rendering...
  56703. *
  56704. * The only supported format is currently 3dl.
  56705. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56706. */
  56707. export class ColorGradingTexture extends BaseTexture {
  56708. /**
  56709. * The texture URL.
  56710. */
  56711. url: string;
  56712. /**
  56713. * Empty line regex stored for GC.
  56714. */
  56715. private static _noneEmptyLineRegex;
  56716. private _textureMatrix;
  56717. private _onLoad;
  56718. /**
  56719. * Instantiates a ColorGradingTexture from the following parameters.
  56720. *
  56721. * @param url The location of the color gradind data (currently only supporting 3dl)
  56722. * @param sceneOrEngine The scene or engine the texture will be used in
  56723. * @param onLoad defines a callback triggered when the texture has been loaded
  56724. */
  56725. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56726. /**
  56727. * Fires the onload event from the constructor if requested.
  56728. */
  56729. private _triggerOnLoad;
  56730. /**
  56731. * Returns the texture matrix used in most of the material.
  56732. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56733. */
  56734. getTextureMatrix(): Matrix;
  56735. /**
  56736. * Occurs when the file being loaded is a .3dl LUT file.
  56737. */
  56738. private load3dlTexture;
  56739. /**
  56740. * Starts the loading process of the texture.
  56741. */
  56742. private loadTexture;
  56743. /**
  56744. * Clones the color gradind texture.
  56745. */
  56746. clone(): ColorGradingTexture;
  56747. /**
  56748. * Called during delayed load for textures.
  56749. */
  56750. delayLoad(): void;
  56751. /**
  56752. * Parses a color grading texture serialized by Babylon.
  56753. * @param parsedTexture The texture information being parsedTexture
  56754. * @param scene The scene to load the texture in
  56755. * @param rootUrl The root url of the data assets to load
  56756. * @return A color gradind texture
  56757. */
  56758. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56759. /**
  56760. * Serializes the LUT texture to json format.
  56761. */
  56762. serialize(): any;
  56763. }
  56764. }
  56765. declare module BABYLON {
  56766. /**
  56767. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56768. */
  56769. export class EquiRectangularCubeTexture extends BaseTexture {
  56770. /** The six faces of the cube. */
  56771. private static _FacesMapping;
  56772. private _noMipmap;
  56773. private _onLoad;
  56774. private _onError;
  56775. /** The size of the cubemap. */
  56776. private _size;
  56777. /** The buffer of the image. */
  56778. private _buffer;
  56779. /** The width of the input image. */
  56780. private _width;
  56781. /** The height of the input image. */
  56782. private _height;
  56783. /** The URL to the image. */
  56784. url: string;
  56785. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56786. coordinatesMode: number;
  56787. /**
  56788. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56789. * @param url The location of the image
  56790. * @param scene The scene the texture will be used in
  56791. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56792. * @param noMipmap Forces to not generate the mipmap if true
  56793. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56794. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56795. * @param onLoad — defines a callback called when texture is loaded
  56796. * @param onError — defines a callback called if there is an error
  56797. */
  56798. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56799. /**
  56800. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56801. */
  56802. private loadImage;
  56803. /**
  56804. * Convert the image buffer into a cubemap and create a CubeTexture.
  56805. */
  56806. private loadTexture;
  56807. /**
  56808. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56809. * @param buffer The ArrayBuffer that should be converted.
  56810. * @returns The buffer as Float32Array.
  56811. */
  56812. private getFloat32ArrayFromArrayBuffer;
  56813. /**
  56814. * Get the current class name of the texture useful for serialization or dynamic coding.
  56815. * @returns "EquiRectangularCubeTexture"
  56816. */
  56817. getClassName(): string;
  56818. /**
  56819. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56820. * @returns A clone of the current EquiRectangularCubeTexture.
  56821. */
  56822. clone(): EquiRectangularCubeTexture;
  56823. }
  56824. }
  56825. declare module BABYLON {
  56826. /**
  56827. * Based on jsTGALoader - Javascript loader for TGA file
  56828. * By Vincent Thibault
  56829. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56830. */
  56831. export class TGATools {
  56832. private static _TYPE_INDEXED;
  56833. private static _TYPE_RGB;
  56834. private static _TYPE_GREY;
  56835. private static _TYPE_RLE_INDEXED;
  56836. private static _TYPE_RLE_RGB;
  56837. private static _TYPE_RLE_GREY;
  56838. private static _ORIGIN_MASK;
  56839. private static _ORIGIN_SHIFT;
  56840. private static _ORIGIN_BL;
  56841. private static _ORIGIN_BR;
  56842. private static _ORIGIN_UL;
  56843. private static _ORIGIN_UR;
  56844. /**
  56845. * Gets the header of a TGA file
  56846. * @param data defines the TGA data
  56847. * @returns the header
  56848. */
  56849. static GetTGAHeader(data: Uint8Array): any;
  56850. /**
  56851. * Uploads TGA content to a Babylon Texture
  56852. * @hidden
  56853. */
  56854. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56855. /** @hidden */
  56856. 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;
  56857. /** @hidden */
  56858. 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;
  56859. /** @hidden */
  56860. 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;
  56861. /** @hidden */
  56862. 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;
  56863. /** @hidden */
  56864. 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;
  56865. /** @hidden */
  56866. 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;
  56867. }
  56868. }
  56869. declare module BABYLON {
  56870. /**
  56871. * Implementation of the TGA Texture Loader.
  56872. * @hidden
  56873. */
  56874. export class _TGATextureLoader implements IInternalTextureLoader {
  56875. /**
  56876. * Defines wether the loader supports cascade loading the different faces.
  56877. */
  56878. readonly supportCascades: boolean;
  56879. /**
  56880. * This returns if the loader support the current file information.
  56881. * @param extension defines the file extension of the file being loaded
  56882. * @returns true if the loader can load the specified file
  56883. */
  56884. canLoad(extension: string): boolean;
  56885. /**
  56886. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56887. * @param data contains the texture data
  56888. * @param texture defines the BabylonJS internal texture
  56889. * @param createPolynomials will be true if polynomials have been requested
  56890. * @param onLoad defines the callback to trigger once the texture is ready
  56891. * @param onError defines the callback to trigger in case of error
  56892. */
  56893. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56894. /**
  56895. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56896. * @param data contains the texture data
  56897. * @param texture defines the BabylonJS internal texture
  56898. * @param callback defines the method to call once ready to upload
  56899. */
  56900. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56901. }
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * Info about the .basis files
  56906. */
  56907. class BasisFileInfo {
  56908. /**
  56909. * If the file has alpha
  56910. */
  56911. hasAlpha: boolean;
  56912. /**
  56913. * Info about each image of the basis file
  56914. */
  56915. images: Array<{
  56916. levels: Array<{
  56917. width: number;
  56918. height: number;
  56919. transcodedPixels: ArrayBufferView;
  56920. }>;
  56921. }>;
  56922. }
  56923. /**
  56924. * Result of transcoding a basis file
  56925. */
  56926. class TranscodeResult {
  56927. /**
  56928. * Info about the .basis file
  56929. */
  56930. fileInfo: BasisFileInfo;
  56931. /**
  56932. * Format to use when loading the file
  56933. */
  56934. format: number;
  56935. }
  56936. /**
  56937. * Configuration options for the Basis transcoder
  56938. */
  56939. export class BasisTranscodeConfiguration {
  56940. /**
  56941. * Supported compression formats used to determine the supported output format of the transcoder
  56942. */
  56943. supportedCompressionFormats?: {
  56944. /**
  56945. * etc1 compression format
  56946. */
  56947. etc1?: boolean;
  56948. /**
  56949. * s3tc compression format
  56950. */
  56951. s3tc?: boolean;
  56952. /**
  56953. * pvrtc compression format
  56954. */
  56955. pvrtc?: boolean;
  56956. /**
  56957. * etc2 compression format
  56958. */
  56959. etc2?: boolean;
  56960. };
  56961. /**
  56962. * If mipmap levels should be loaded for transcoded images (Default: true)
  56963. */
  56964. loadMipmapLevels?: boolean;
  56965. /**
  56966. * Index of a single image to load (Default: all images)
  56967. */
  56968. loadSingleImage?: number;
  56969. }
  56970. /**
  56971. * Used to load .Basis files
  56972. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56973. */
  56974. export class BasisTools {
  56975. private static _IgnoreSupportedFormats;
  56976. /**
  56977. * URL to use when loading the basis transcoder
  56978. */
  56979. static JSModuleURL: string;
  56980. /**
  56981. * URL to use when loading the wasm module for the transcoder
  56982. */
  56983. static WasmModuleURL: string;
  56984. /**
  56985. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56986. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56987. * @returns internal format corresponding to the Basis format
  56988. */
  56989. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56990. private static _WorkerPromise;
  56991. private static _Worker;
  56992. private static _actionId;
  56993. private static _CreateWorkerAsync;
  56994. /**
  56995. * Transcodes a loaded image file to compressed pixel data
  56996. * @param data image data to transcode
  56997. * @param config configuration options for the transcoding
  56998. * @returns a promise resulting in the transcoded image
  56999. */
  57000. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57001. /**
  57002. * Loads a texture from the transcode result
  57003. * @param texture texture load to
  57004. * @param transcodeResult the result of transcoding the basis file to load from
  57005. */
  57006. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57007. }
  57008. }
  57009. declare module BABYLON {
  57010. /**
  57011. * Loader for .basis file format
  57012. */
  57013. export class _BasisTextureLoader implements IInternalTextureLoader {
  57014. /**
  57015. * Defines whether the loader supports cascade loading the different faces.
  57016. */
  57017. readonly supportCascades: boolean;
  57018. /**
  57019. * This returns if the loader support the current file information.
  57020. * @param extension defines the file extension of the file being loaded
  57021. * @returns true if the loader can load the specified file
  57022. */
  57023. canLoad(extension: string): boolean;
  57024. /**
  57025. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57026. * @param data contains the texture data
  57027. * @param texture defines the BabylonJS internal texture
  57028. * @param createPolynomials will be true if polynomials have been requested
  57029. * @param onLoad defines the callback to trigger once the texture is ready
  57030. * @param onError defines the callback to trigger in case of error
  57031. */
  57032. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57033. /**
  57034. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57035. * @param data contains the texture data
  57036. * @param texture defines the BabylonJS internal texture
  57037. * @param callback defines the method to call once ready to upload
  57038. */
  57039. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57040. }
  57041. }
  57042. declare module BABYLON {
  57043. /**
  57044. * 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.
  57045. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57046. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57047. */
  57048. export class CustomProceduralTexture extends ProceduralTexture {
  57049. private _animate;
  57050. private _time;
  57051. private _config;
  57052. private _texturePath;
  57053. /**
  57054. * Instantiates a new Custom Procedural Texture.
  57055. * 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.
  57056. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57057. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57058. * @param name Define the name of the texture
  57059. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57060. * @param size Define the size of the texture to create
  57061. * @param scene Define the scene the texture belongs to
  57062. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57063. * @param generateMipMaps Define if the texture should creates mip maps or not
  57064. */
  57065. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57066. private _loadJson;
  57067. /**
  57068. * Is the texture ready to be used ? (rendered at least once)
  57069. * @returns true if ready, otherwise, false.
  57070. */
  57071. isReady(): boolean;
  57072. /**
  57073. * Render the texture to its associated render target.
  57074. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57075. */
  57076. render(useCameraPostProcess?: boolean): void;
  57077. /**
  57078. * Update the list of dependant textures samplers in the shader.
  57079. */
  57080. updateTextures(): void;
  57081. /**
  57082. * Update the uniform values of the procedural texture in the shader.
  57083. */
  57084. updateShaderUniforms(): void;
  57085. /**
  57086. * Define if the texture animates or not.
  57087. */
  57088. get animate(): boolean;
  57089. set animate(value: boolean);
  57090. }
  57091. }
  57092. declare module BABYLON {
  57093. /** @hidden */
  57094. export var noisePixelShader: {
  57095. name: string;
  57096. shader: string;
  57097. };
  57098. }
  57099. declare module BABYLON {
  57100. /**
  57101. * Class used to generate noise procedural textures
  57102. */
  57103. export class NoiseProceduralTexture extends ProceduralTexture {
  57104. private _time;
  57105. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57106. brightness: number;
  57107. /** Defines the number of octaves to process */
  57108. octaves: number;
  57109. /** Defines the level of persistence (0.8 by default) */
  57110. persistence: number;
  57111. /** Gets or sets animation speed factor (default is 1) */
  57112. animationSpeedFactor: number;
  57113. /**
  57114. * Creates a new NoiseProceduralTexture
  57115. * @param name defines the name fo the texture
  57116. * @param size defines the size of the texture (default is 256)
  57117. * @param scene defines the hosting scene
  57118. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57119. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57120. */
  57121. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57122. private _updateShaderUniforms;
  57123. protected _getDefines(): string;
  57124. /** Generate the current state of the procedural texture */
  57125. render(useCameraPostProcess?: boolean): void;
  57126. /**
  57127. * Serializes this noise procedural texture
  57128. * @returns a serialized noise procedural texture object
  57129. */
  57130. serialize(): any;
  57131. /**
  57132. * Clone the texture.
  57133. * @returns the cloned texture
  57134. */
  57135. clone(): NoiseProceduralTexture;
  57136. /**
  57137. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57138. * @param parsedTexture defines parsed texture data
  57139. * @param scene defines the current scene
  57140. * @param rootUrl defines the root URL containing noise procedural texture information
  57141. * @returns a parsed NoiseProceduralTexture
  57142. */
  57143. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57144. }
  57145. }
  57146. declare module BABYLON {
  57147. /**
  57148. * Raw cube texture where the raw buffers are passed in
  57149. */
  57150. export class RawCubeTexture extends CubeTexture {
  57151. /**
  57152. * Creates a cube texture where the raw buffers are passed in.
  57153. * @param scene defines the scene the texture is attached to
  57154. * @param data defines the array of data to use to create each face
  57155. * @param size defines the size of the textures
  57156. * @param format defines the format of the data
  57157. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57158. * @param generateMipMaps defines if the engine should generate the mip levels
  57159. * @param invertY defines if data must be stored with Y axis inverted
  57160. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57161. * @param compression defines the compression used (null by default)
  57162. */
  57163. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57164. /**
  57165. * Updates the raw cube texture.
  57166. * @param data defines the data to store
  57167. * @param format defines the data format
  57168. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57169. * @param invertY defines if data must be stored with Y axis inverted
  57170. * @param compression defines the compression used (null by default)
  57171. * @param level defines which level of the texture to update
  57172. */
  57173. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57174. /**
  57175. * Updates a raw cube texture with RGBD encoded data.
  57176. * @param data defines the array of data [mipmap][face] to use to create each face
  57177. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57178. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57179. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57180. * @returns a promsie that resolves when the operation is complete
  57181. */
  57182. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57183. /**
  57184. * Clones the raw cube texture.
  57185. * @return a new cube texture
  57186. */
  57187. clone(): CubeTexture;
  57188. /** @hidden */
  57189. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57190. }
  57191. }
  57192. declare module BABYLON {
  57193. /**
  57194. * Class used to store 3D textures containing user data
  57195. */
  57196. export class RawTexture3D extends Texture {
  57197. /** Gets or sets the texture format to use */
  57198. format: number;
  57199. /**
  57200. * Create a new RawTexture3D
  57201. * @param data defines the data of the texture
  57202. * @param width defines the width of the texture
  57203. * @param height defines the height of the texture
  57204. * @param depth defines the depth of the texture
  57205. * @param format defines the texture format to use
  57206. * @param scene defines the hosting scene
  57207. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57208. * @param invertY defines if texture must be stored with Y axis inverted
  57209. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57210. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57211. */
  57212. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57213. /** Gets or sets the texture format to use */
  57214. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57215. /**
  57216. * Update the texture with new data
  57217. * @param data defines the data to store in the texture
  57218. */
  57219. update(data: ArrayBufferView): void;
  57220. }
  57221. }
  57222. declare module BABYLON {
  57223. /**
  57224. * Class used to store 2D array textures containing user data
  57225. */
  57226. export class RawTexture2DArray extends Texture {
  57227. /** Gets or sets the texture format to use */
  57228. format: number;
  57229. /**
  57230. * Create a new RawTexture2DArray
  57231. * @param data defines the data of the texture
  57232. * @param width defines the width of the texture
  57233. * @param height defines the height of the texture
  57234. * @param depth defines the number of layers of the texture
  57235. * @param format defines the texture format to use
  57236. * @param scene defines the hosting scene
  57237. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57238. * @param invertY defines if texture must be stored with Y axis inverted
  57239. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57240. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57241. */
  57242. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57243. /** Gets or sets the texture format to use */
  57244. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57245. /**
  57246. * Update the texture with new data
  57247. * @param data defines the data to store in the texture
  57248. */
  57249. update(data: ArrayBufferView): void;
  57250. }
  57251. }
  57252. declare module BABYLON {
  57253. /**
  57254. * Creates a refraction texture used by refraction channel of the standard material.
  57255. * It is like a mirror but to see through a material.
  57256. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57257. */
  57258. export class RefractionTexture extends RenderTargetTexture {
  57259. /**
  57260. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57261. * 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.
  57262. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57263. */
  57264. refractionPlane: Plane;
  57265. /**
  57266. * Define how deep under the surface we should see.
  57267. */
  57268. depth: number;
  57269. /**
  57270. * Creates a refraction texture used by refraction channel of the standard material.
  57271. * It is like a mirror but to see through a material.
  57272. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57273. * @param name Define the texture name
  57274. * @param size Define the size of the underlying texture
  57275. * @param scene Define the scene the refraction belongs to
  57276. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57277. */
  57278. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57279. /**
  57280. * Clone the refraction texture.
  57281. * @returns the cloned texture
  57282. */
  57283. clone(): RefractionTexture;
  57284. /**
  57285. * Serialize the texture to a JSON representation you could use in Parse later on
  57286. * @returns the serialized JSON representation
  57287. */
  57288. serialize(): any;
  57289. }
  57290. }
  57291. declare module BABYLON {
  57292. /**
  57293. * Defines the options related to the creation of an HtmlElementTexture
  57294. */
  57295. export interface IHtmlElementTextureOptions {
  57296. /**
  57297. * Defines wether mip maps should be created or not.
  57298. */
  57299. generateMipMaps?: boolean;
  57300. /**
  57301. * Defines the sampling mode of the texture.
  57302. */
  57303. samplingMode?: number;
  57304. /**
  57305. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57306. */
  57307. engine: Nullable<ThinEngine>;
  57308. /**
  57309. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57310. */
  57311. scene: Nullable<Scene>;
  57312. }
  57313. /**
  57314. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57315. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57316. * is automatically managed.
  57317. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57318. * in your application.
  57319. *
  57320. * As the update is not automatic, you need to call them manually.
  57321. */
  57322. export class HtmlElementTexture extends BaseTexture {
  57323. /**
  57324. * The texture URL.
  57325. */
  57326. element: HTMLVideoElement | HTMLCanvasElement;
  57327. private static readonly DefaultOptions;
  57328. private _textureMatrix;
  57329. private _isVideo;
  57330. private _generateMipMaps;
  57331. private _samplingMode;
  57332. /**
  57333. * Instantiates a HtmlElementTexture from the following parameters.
  57334. *
  57335. * @param name Defines the name of the texture
  57336. * @param element Defines the video or canvas the texture is filled with
  57337. * @param options Defines the other none mandatory texture creation options
  57338. */
  57339. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57340. private _createInternalTexture;
  57341. /**
  57342. * Returns the texture matrix used in most of the material.
  57343. */
  57344. getTextureMatrix(): Matrix;
  57345. /**
  57346. * Updates the content of the texture.
  57347. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57348. */
  57349. update(invertY?: Nullable<boolean>): void;
  57350. }
  57351. }
  57352. declare module BABYLON {
  57353. /**
  57354. * Defines the basic options interface of a TexturePacker Frame
  57355. */
  57356. export interface ITexturePackerFrame {
  57357. /**
  57358. * The frame ID
  57359. */
  57360. id: number;
  57361. /**
  57362. * The frames Scale
  57363. */
  57364. scale: Vector2;
  57365. /**
  57366. * The Frames offset
  57367. */
  57368. offset: Vector2;
  57369. }
  57370. /**
  57371. * This is a support class for frame Data on texture packer sets.
  57372. */
  57373. export class TexturePackerFrame implements ITexturePackerFrame {
  57374. /**
  57375. * The frame ID
  57376. */
  57377. id: number;
  57378. /**
  57379. * The frames Scale
  57380. */
  57381. scale: Vector2;
  57382. /**
  57383. * The Frames offset
  57384. */
  57385. offset: Vector2;
  57386. /**
  57387. * Initializes a texture package frame.
  57388. * @param id The numerical frame identifier
  57389. * @param scale Scalar Vector2 for UV frame
  57390. * @param offset Vector2 for the frame position in UV units.
  57391. * @returns TexturePackerFrame
  57392. */
  57393. constructor(id: number, scale: Vector2, offset: Vector2);
  57394. }
  57395. }
  57396. declare module BABYLON {
  57397. /**
  57398. * Defines the basic options interface of a TexturePacker
  57399. */
  57400. export interface ITexturePackerOptions {
  57401. /**
  57402. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57403. */
  57404. map?: string[];
  57405. /**
  57406. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57407. */
  57408. uvsIn?: string;
  57409. /**
  57410. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57411. */
  57412. uvsOut?: string;
  57413. /**
  57414. * number representing the layout style. Defaults to LAYOUT_STRIP
  57415. */
  57416. layout?: number;
  57417. /**
  57418. * number of columns if using custom column count layout(2). This defaults to 4.
  57419. */
  57420. colnum?: number;
  57421. /**
  57422. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57423. */
  57424. updateInputMeshes?: boolean;
  57425. /**
  57426. * boolean flag to dispose all the source textures. Defaults to true.
  57427. */
  57428. disposeSources?: boolean;
  57429. /**
  57430. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57431. */
  57432. fillBlanks?: boolean;
  57433. /**
  57434. * string value representing the context fill style color. Defaults to 'black'.
  57435. */
  57436. customFillColor?: string;
  57437. /**
  57438. * Width and Height Value of each Frame in the TexturePacker Sets
  57439. */
  57440. frameSize?: number;
  57441. /**
  57442. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57443. */
  57444. paddingRatio?: number;
  57445. /**
  57446. * Number that declares the fill method for the padding gutter.
  57447. */
  57448. paddingMode?: number;
  57449. /**
  57450. * If in SUBUV_COLOR padding mode what color to use.
  57451. */
  57452. paddingColor?: Color3 | Color4;
  57453. }
  57454. /**
  57455. * Defines the basic interface of a TexturePacker JSON File
  57456. */
  57457. export interface ITexturePackerJSON {
  57458. /**
  57459. * The frame ID
  57460. */
  57461. name: string;
  57462. /**
  57463. * The base64 channel data
  57464. */
  57465. sets: any;
  57466. /**
  57467. * The options of the Packer
  57468. */
  57469. options: ITexturePackerOptions;
  57470. /**
  57471. * The frame data of the Packer
  57472. */
  57473. frames: Array<number>;
  57474. }
  57475. /**
  57476. * This is a support class that generates a series of packed texture sets.
  57477. * @see https://doc.babylonjs.com/babylon101/materials
  57478. */
  57479. export class TexturePacker {
  57480. /** Packer Layout Constant 0 */
  57481. static readonly LAYOUT_STRIP: number;
  57482. /** Packer Layout Constant 1 */
  57483. static readonly LAYOUT_POWER2: number;
  57484. /** Packer Layout Constant 2 */
  57485. static readonly LAYOUT_COLNUM: number;
  57486. /** Packer Layout Constant 0 */
  57487. static readonly SUBUV_WRAP: number;
  57488. /** Packer Layout Constant 1 */
  57489. static readonly SUBUV_EXTEND: number;
  57490. /** Packer Layout Constant 2 */
  57491. static readonly SUBUV_COLOR: number;
  57492. /** The Name of the Texture Package */
  57493. name: string;
  57494. /** The scene scope of the TexturePacker */
  57495. scene: Scene;
  57496. /** The Meshes to target */
  57497. meshes: AbstractMesh[];
  57498. /** Arguments passed with the Constructor */
  57499. options: ITexturePackerOptions;
  57500. /** The promise that is started upon initialization */
  57501. promise: Nullable<Promise<TexturePacker | string>>;
  57502. /** The Container object for the channel sets that are generated */
  57503. sets: object;
  57504. /** The Container array for the frames that are generated */
  57505. frames: TexturePackerFrame[];
  57506. /** The expected number of textures the system is parsing. */
  57507. private _expecting;
  57508. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57509. private _paddingValue;
  57510. /**
  57511. * Initializes a texture package series from an array of meshes or a single mesh.
  57512. * @param name The name of the package
  57513. * @param meshes The target meshes to compose the package from
  57514. * @param options The arguments that texture packer should follow while building.
  57515. * @param scene The scene which the textures are scoped to.
  57516. * @returns TexturePacker
  57517. */
  57518. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57519. /**
  57520. * Starts the package process
  57521. * @param resolve The promises resolution function
  57522. * @returns TexturePacker
  57523. */
  57524. private _createFrames;
  57525. /**
  57526. * Calculates the Size of the Channel Sets
  57527. * @returns Vector2
  57528. */
  57529. private _calculateSize;
  57530. /**
  57531. * Calculates the UV data for the frames.
  57532. * @param baseSize the base frameSize
  57533. * @param padding the base frame padding
  57534. * @param dtSize size of the Dynamic Texture for that channel
  57535. * @param dtUnits is 1/dtSize
  57536. * @param update flag to update the input meshes
  57537. */
  57538. private _calculateMeshUVFrames;
  57539. /**
  57540. * Calculates the frames Offset.
  57541. * @param index of the frame
  57542. * @returns Vector2
  57543. */
  57544. private _getFrameOffset;
  57545. /**
  57546. * Updates a Mesh to the frame data
  57547. * @param mesh that is the target
  57548. * @param frameID or the frame index
  57549. */
  57550. private _updateMeshUV;
  57551. /**
  57552. * Updates a Meshes materials to use the texture packer channels
  57553. * @param m is the mesh to target
  57554. * @param force all channels on the packer to be set.
  57555. */
  57556. private _updateTextureReferences;
  57557. /**
  57558. * Public method to set a Mesh to a frame
  57559. * @param m that is the target
  57560. * @param frameID or the frame index
  57561. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57562. */
  57563. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57564. /**
  57565. * Starts the async promise to compile the texture packer.
  57566. * @returns Promise<void>
  57567. */
  57568. processAsync(): Promise<void>;
  57569. /**
  57570. * Disposes all textures associated with this packer
  57571. */
  57572. dispose(): void;
  57573. /**
  57574. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57575. * @param imageType is the image type to use.
  57576. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57577. */
  57578. download(imageType?: string, quality?: number): void;
  57579. /**
  57580. * Public method to load a texturePacker JSON file.
  57581. * @param data of the JSON file in string format.
  57582. */
  57583. updateFromJSON(data: string): void;
  57584. }
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * Enum used to define the target of a block
  57589. */
  57590. export enum NodeMaterialBlockTargets {
  57591. /** Vertex shader */
  57592. Vertex = 1,
  57593. /** Fragment shader */
  57594. Fragment = 2,
  57595. /** Neutral */
  57596. Neutral = 4,
  57597. /** Vertex and Fragment */
  57598. VertexAndFragment = 3
  57599. }
  57600. }
  57601. declare module BABYLON {
  57602. /**
  57603. * Defines the kind of connection point for node based material
  57604. */
  57605. export enum NodeMaterialBlockConnectionPointTypes {
  57606. /** Float */
  57607. Float = 1,
  57608. /** Int */
  57609. Int = 2,
  57610. /** Vector2 */
  57611. Vector2 = 4,
  57612. /** Vector3 */
  57613. Vector3 = 8,
  57614. /** Vector4 */
  57615. Vector4 = 16,
  57616. /** Color3 */
  57617. Color3 = 32,
  57618. /** Color4 */
  57619. Color4 = 64,
  57620. /** Matrix */
  57621. Matrix = 128,
  57622. /** Custom object */
  57623. Object = 256,
  57624. /** Detect type based on connection */
  57625. AutoDetect = 1024,
  57626. /** Output type that will be defined by input type */
  57627. BasedOnInput = 2048
  57628. }
  57629. }
  57630. declare module BABYLON {
  57631. /**
  57632. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57633. */
  57634. export enum NodeMaterialBlockConnectionPointMode {
  57635. /** Value is an uniform */
  57636. Uniform = 0,
  57637. /** Value is a mesh attribute */
  57638. Attribute = 1,
  57639. /** Value is a varying between vertex and fragment shaders */
  57640. Varying = 2,
  57641. /** Mode is undefined */
  57642. Undefined = 3
  57643. }
  57644. }
  57645. declare module BABYLON {
  57646. /**
  57647. * Enum used to define system values e.g. values automatically provided by the system
  57648. */
  57649. export enum NodeMaterialSystemValues {
  57650. /** World */
  57651. World = 1,
  57652. /** View */
  57653. View = 2,
  57654. /** Projection */
  57655. Projection = 3,
  57656. /** ViewProjection */
  57657. ViewProjection = 4,
  57658. /** WorldView */
  57659. WorldView = 5,
  57660. /** WorldViewProjection */
  57661. WorldViewProjection = 6,
  57662. /** CameraPosition */
  57663. CameraPosition = 7,
  57664. /** Fog Color */
  57665. FogColor = 8,
  57666. /** Delta time */
  57667. DeltaTime = 9
  57668. }
  57669. }
  57670. declare module BABYLON {
  57671. /**
  57672. * Enum used to define the material modes
  57673. */
  57674. export enum NodeMaterialModes {
  57675. /** Regular material */
  57676. Material = 0,
  57677. /** For post process */
  57678. PostProcess = 1
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /**
  57683. * Root class for all node material optimizers
  57684. */
  57685. export class NodeMaterialOptimizer {
  57686. /**
  57687. * Function used to optimize a NodeMaterial graph
  57688. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57689. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57690. */
  57691. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57692. }
  57693. }
  57694. declare module BABYLON {
  57695. /**
  57696. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57697. */
  57698. export class TransformBlock extends NodeMaterialBlock {
  57699. /**
  57700. * Defines the value to use to complement W value to transform it to a Vector4
  57701. */
  57702. complementW: number;
  57703. /**
  57704. * Defines the value to use to complement z value to transform it to a Vector4
  57705. */
  57706. complementZ: number;
  57707. /**
  57708. * Creates a new TransformBlock
  57709. * @param name defines the block name
  57710. */
  57711. constructor(name: string);
  57712. /**
  57713. * Gets the current class name
  57714. * @returns the class name
  57715. */
  57716. getClassName(): string;
  57717. /**
  57718. * Gets the vector input
  57719. */
  57720. get vector(): NodeMaterialConnectionPoint;
  57721. /**
  57722. * Gets the output component
  57723. */
  57724. get output(): NodeMaterialConnectionPoint;
  57725. /**
  57726. * Gets the xyz output component
  57727. */
  57728. get xyz(): NodeMaterialConnectionPoint;
  57729. /**
  57730. * Gets the matrix transform input
  57731. */
  57732. get transform(): NodeMaterialConnectionPoint;
  57733. protected _buildBlock(state: NodeMaterialBuildState): this;
  57734. serialize(): any;
  57735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57736. protected _dumpPropertiesCode(): string;
  57737. }
  57738. }
  57739. declare module BABYLON {
  57740. /**
  57741. * Block used to output the vertex position
  57742. */
  57743. export class VertexOutputBlock extends NodeMaterialBlock {
  57744. /**
  57745. * Creates a new VertexOutputBlock
  57746. * @param name defines the block name
  57747. */
  57748. constructor(name: string);
  57749. /**
  57750. * Gets the current class name
  57751. * @returns the class name
  57752. */
  57753. getClassName(): string;
  57754. /**
  57755. * Gets the vector input component
  57756. */
  57757. get vector(): NodeMaterialConnectionPoint;
  57758. protected _buildBlock(state: NodeMaterialBuildState): this;
  57759. }
  57760. }
  57761. declare module BABYLON {
  57762. /**
  57763. * Block used to output the final color
  57764. */
  57765. export class FragmentOutputBlock extends NodeMaterialBlock {
  57766. /**
  57767. * Create a new FragmentOutputBlock
  57768. * @param name defines the block name
  57769. */
  57770. constructor(name: string);
  57771. /**
  57772. * Gets the current class name
  57773. * @returns the class name
  57774. */
  57775. getClassName(): string;
  57776. /**
  57777. * Gets the rgba input component
  57778. */
  57779. get rgba(): NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the rgb input component
  57782. */
  57783. get rgb(): NodeMaterialConnectionPoint;
  57784. /**
  57785. * Gets the a input component
  57786. */
  57787. get a(): NodeMaterialConnectionPoint;
  57788. protected _buildBlock(state: NodeMaterialBuildState): this;
  57789. }
  57790. }
  57791. declare module BABYLON {
  57792. /**
  57793. * Base block used to read a reflection texture from a sampler
  57794. */
  57795. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  57796. /** @hidden */
  57797. _define3DName: string;
  57798. /** @hidden */
  57799. _defineCubicName: string;
  57800. /** @hidden */
  57801. _defineExplicitName: string;
  57802. /** @hidden */
  57803. _defineProjectionName: string;
  57804. /** @hidden */
  57805. _defineLocalCubicName: string;
  57806. /** @hidden */
  57807. _defineSphericalName: string;
  57808. /** @hidden */
  57809. _definePlanarName: string;
  57810. /** @hidden */
  57811. _defineEquirectangularName: string;
  57812. /** @hidden */
  57813. _defineMirroredEquirectangularFixedName: string;
  57814. /** @hidden */
  57815. _defineEquirectangularFixedName: string;
  57816. /** @hidden */
  57817. _defineSkyboxName: string;
  57818. /** @hidden */
  57819. _defineOppositeZ: string;
  57820. /** @hidden */
  57821. _cubeSamplerName: string;
  57822. /** @hidden */
  57823. _2DSamplerName: string;
  57824. protected _positionUVWName: string;
  57825. protected _directionWName: string;
  57826. protected _reflectionVectorName: string;
  57827. /** @hidden */
  57828. _reflectionCoordsName: string;
  57829. /** @hidden */
  57830. _reflectionMatrixName: string;
  57831. protected _reflectionColorName: string;
  57832. /**
  57833. * Gets or sets the texture associated with the node
  57834. */
  57835. texture: Nullable<BaseTexture>;
  57836. /**
  57837. * Create a new ReflectionTextureBaseBlock
  57838. * @param name defines the block name
  57839. */
  57840. constructor(name: string);
  57841. /**
  57842. * Gets the current class name
  57843. * @returns the class name
  57844. */
  57845. getClassName(): string;
  57846. /**
  57847. * Gets the world position input component
  57848. */
  57849. abstract get position(): NodeMaterialConnectionPoint;
  57850. /**
  57851. * Gets the world position input component
  57852. */
  57853. abstract get worldPosition(): NodeMaterialConnectionPoint;
  57854. /**
  57855. * Gets the world normal input component
  57856. */
  57857. abstract get worldNormal(): NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the world input component
  57860. */
  57861. abstract get world(): NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the camera (or eye) position component
  57864. */
  57865. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  57866. /**
  57867. * Gets the view input component
  57868. */
  57869. abstract get view(): NodeMaterialConnectionPoint;
  57870. protected _getTexture(): Nullable<BaseTexture>;
  57871. autoConfigure(material: NodeMaterial): void;
  57872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57873. isReady(): boolean;
  57874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57875. /**
  57876. * Gets the code to inject in the vertex shader
  57877. * @param state current state of the node material building
  57878. * @returns the shader code
  57879. */
  57880. handleVertexSide(state: NodeMaterialBuildState): string;
  57881. /**
  57882. * Handles the inits for the fragment code path
  57883. * @param state node material build state
  57884. */
  57885. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  57886. /**
  57887. * Generates the reflection coords code for the fragment code path
  57888. * @param worldNormalVarName name of the world normal variable
  57889. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  57890. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  57891. * @returns the shader code
  57892. */
  57893. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  57894. /**
  57895. * Generates the reflection color code for the fragment code path
  57896. * @param lodVarName name of the lod variable
  57897. * @param swizzleLookupTexture swizzle to use for the final color variable
  57898. * @returns the shader code
  57899. */
  57900. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  57901. /**
  57902. * Generates the code corresponding to the connected output points
  57903. * @param state node material build state
  57904. * @param varName name of the variable to output
  57905. * @returns the shader code
  57906. */
  57907. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  57908. protected _buildBlock(state: NodeMaterialBuildState): this;
  57909. protected _dumpPropertiesCode(): string;
  57910. serialize(): any;
  57911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57912. }
  57913. }
  57914. declare module BABYLON {
  57915. /**
  57916. * Defines a connection point to be used for points with a custom object type
  57917. */
  57918. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  57919. private _blockType;
  57920. private _blockName;
  57921. private _nameForCheking?;
  57922. /**
  57923. * Creates a new connection point
  57924. * @param name defines the connection point name
  57925. * @param ownerBlock defines the block hosting this connection point
  57926. * @param direction defines the direction of the connection point
  57927. */
  57928. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  57929. /**
  57930. * Gets a number indicating if the current point can be connected to another point
  57931. * @param connectionPoint defines the other connection point
  57932. * @returns a number defining the compatibility state
  57933. */
  57934. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57935. /**
  57936. * Creates a block suitable to be used as an input for this input point.
  57937. * If null is returned, a block based on the point type will be created.
  57938. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  57939. */
  57940. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  57941. }
  57942. }
  57943. declare module BABYLON {
  57944. /**
  57945. * Enum defining the type of properties that can be edited in the property pages in the NME
  57946. */
  57947. export enum PropertyTypeForEdition {
  57948. /** property is a boolean */
  57949. Boolean = 0,
  57950. /** property is a float */
  57951. Float = 1,
  57952. /** property is a Vector2 */
  57953. Vector2 = 2,
  57954. /** property is a list of values */
  57955. List = 3
  57956. }
  57957. /**
  57958. * Interface that defines an option in a variable of type list
  57959. */
  57960. export interface IEditablePropertyListOption {
  57961. /** label of the option */
  57962. "label": string;
  57963. /** value of the option */
  57964. "value": number;
  57965. }
  57966. /**
  57967. * Interface that defines the options available for an editable property
  57968. */
  57969. export interface IEditablePropertyOption {
  57970. /** min value */
  57971. "min"?: number;
  57972. /** max value */
  57973. "max"?: number;
  57974. /** notifiers: indicates which actions to take when the property is changed */
  57975. "notifiers"?: {
  57976. /** the material should be rebuilt */
  57977. "rebuild"?: boolean;
  57978. /** the preview should be updated */
  57979. "update"?: boolean;
  57980. };
  57981. /** list of the options for a variable of type list */
  57982. "options"?: IEditablePropertyListOption[];
  57983. }
  57984. /**
  57985. * Interface that describes an editable property
  57986. */
  57987. export interface IPropertyDescriptionForEdition {
  57988. /** name of the property */
  57989. "propertyName": string;
  57990. /** display name of the property */
  57991. "displayName": string;
  57992. /** type of the property */
  57993. "type": PropertyTypeForEdition;
  57994. /** group of the property - all properties with the same group value will be displayed in a specific section */
  57995. "groupName": string;
  57996. /** options for the property */
  57997. "options": IEditablePropertyOption;
  57998. }
  57999. /**
  58000. * Decorator that flags a property in a node material block as being editable
  58001. */
  58002. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  58003. }
  58004. declare module BABYLON {
  58005. /**
  58006. * Block used to implement the refraction part of the sub surface module of the PBR material
  58007. */
  58008. export class RefractionBlock extends NodeMaterialBlock {
  58009. /** @hidden */
  58010. _define3DName: string;
  58011. /** @hidden */
  58012. _refractionMatrixName: string;
  58013. /** @hidden */
  58014. _defineLODRefractionAlpha: string;
  58015. /** @hidden */
  58016. _defineLinearSpecularRefraction: string;
  58017. /** @hidden */
  58018. _defineOppositeZ: string;
  58019. /** @hidden */
  58020. _cubeSamplerName: string;
  58021. /** @hidden */
  58022. _2DSamplerName: string;
  58023. /** @hidden */
  58024. _vRefractionMicrosurfaceInfosName: string;
  58025. /** @hidden */
  58026. _vRefractionInfosName: string;
  58027. private _scene;
  58028. /**
  58029. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58030. * Materials half opaque for instance using refraction could benefit from this control.
  58031. */
  58032. linkRefractionWithTransparency: boolean;
  58033. /**
  58034. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58035. */
  58036. invertRefractionY: boolean;
  58037. /**
  58038. * Gets or sets the texture associated with the node
  58039. */
  58040. texture: Nullable<BaseTexture>;
  58041. /**
  58042. * Create a new RefractionBlock
  58043. * @param name defines the block name
  58044. */
  58045. constructor(name: string);
  58046. /**
  58047. * Gets the current class name
  58048. * @returns the class name
  58049. */
  58050. getClassName(): string;
  58051. /**
  58052. * Gets the intensity input component
  58053. */
  58054. get intensity(): NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the index of refraction input component
  58057. */
  58058. get indexOfRefraction(): NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the tint at distance input component
  58061. */
  58062. get tintAtDistance(): NodeMaterialConnectionPoint;
  58063. /**
  58064. * Gets the view input component
  58065. */
  58066. get view(): NodeMaterialConnectionPoint;
  58067. /**
  58068. * Gets the refraction object output component
  58069. */
  58070. get refraction(): NodeMaterialConnectionPoint;
  58071. /**
  58072. * Returns true if the block has a texture
  58073. */
  58074. get hasTexture(): boolean;
  58075. protected _getTexture(): Nullable<BaseTexture>;
  58076. autoConfigure(material: NodeMaterial): void;
  58077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58078. isReady(): boolean;
  58079. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58080. /**
  58081. * Gets the main code of the block (fragment side)
  58082. * @param state current state of the node material building
  58083. * @returns the shader code
  58084. */
  58085. getCode(state: NodeMaterialBuildState): string;
  58086. protected _buildBlock(state: NodeMaterialBuildState): this;
  58087. protected _dumpPropertiesCode(): string;
  58088. serialize(): any;
  58089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58090. }
  58091. }
  58092. declare module BABYLON {
  58093. /**
  58094. * Base block used as input for post process
  58095. */
  58096. export class CurrentScreenBlock extends NodeMaterialBlock {
  58097. private _samplerName;
  58098. private _linearDefineName;
  58099. private _gammaDefineName;
  58100. private _mainUVName;
  58101. private _tempTextureRead;
  58102. /**
  58103. * Gets or sets the texture associated with the node
  58104. */
  58105. texture: Nullable<BaseTexture>;
  58106. /**
  58107. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58108. */
  58109. convertToGammaSpace: boolean;
  58110. /**
  58111. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58112. */
  58113. convertToLinearSpace: boolean;
  58114. /**
  58115. * Create a new CurrentScreenBlock
  58116. * @param name defines the block name
  58117. */
  58118. constructor(name: string);
  58119. /**
  58120. * Gets the current class name
  58121. * @returns the class name
  58122. */
  58123. getClassName(): string;
  58124. /**
  58125. * Gets the uv input component
  58126. */
  58127. get uv(): NodeMaterialConnectionPoint;
  58128. /**
  58129. * Gets the rgba output component
  58130. */
  58131. get rgba(): NodeMaterialConnectionPoint;
  58132. /**
  58133. * Gets the rgb output component
  58134. */
  58135. get rgb(): NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the r output component
  58138. */
  58139. get r(): NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the g output component
  58142. */
  58143. get g(): NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the b output component
  58146. */
  58147. get b(): NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the a output component
  58150. */
  58151. get a(): NodeMaterialConnectionPoint;
  58152. /**
  58153. * Initialize the block and prepare the context for build
  58154. * @param state defines the state that will be used for the build
  58155. */
  58156. initialize(state: NodeMaterialBuildState): void;
  58157. get target(): NodeMaterialBlockTargets;
  58158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58159. isReady(): boolean;
  58160. private _injectVertexCode;
  58161. private _writeTextureRead;
  58162. private _writeOutput;
  58163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58164. serialize(): any;
  58165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /**
  58170. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58171. */
  58172. export class VectorMergerBlock extends NodeMaterialBlock {
  58173. /**
  58174. * Create a new VectorMergerBlock
  58175. * @param name defines the block name
  58176. */
  58177. constructor(name: string);
  58178. /**
  58179. * Gets the current class name
  58180. * @returns the class name
  58181. */
  58182. getClassName(): string;
  58183. /**
  58184. * Gets the xyz component (input)
  58185. */
  58186. get xyzIn(): NodeMaterialConnectionPoint;
  58187. /**
  58188. * Gets the xy component (input)
  58189. */
  58190. get xyIn(): NodeMaterialConnectionPoint;
  58191. /**
  58192. * Gets the x component (input)
  58193. */
  58194. get x(): NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the y component (input)
  58197. */
  58198. get y(): NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the z component (input)
  58201. */
  58202. get z(): NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the w component (input)
  58205. */
  58206. get w(): NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the xyzw component (output)
  58209. */
  58210. get xyzw(): NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the xyz component (output)
  58213. */
  58214. get xyzOut(): NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the xy component (output)
  58217. */
  58218. get xyOut(): NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the xy component (output)
  58221. * @deprecated Please use xyOut instead.
  58222. */
  58223. get xy(): NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the xyz component (output)
  58226. * @deprecated Please use xyzOut instead.
  58227. */
  58228. get xyz(): NodeMaterialConnectionPoint;
  58229. protected _buildBlock(state: NodeMaterialBuildState): this;
  58230. }
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. * Block used to remap a float from a range to a new one
  58235. */
  58236. export class RemapBlock extends NodeMaterialBlock {
  58237. /**
  58238. * Gets or sets the source range
  58239. */
  58240. sourceRange: Vector2;
  58241. /**
  58242. * Gets or sets the target range
  58243. */
  58244. targetRange: Vector2;
  58245. /**
  58246. * Creates a new RemapBlock
  58247. * @param name defines the block name
  58248. */
  58249. constructor(name: string);
  58250. /**
  58251. * Gets the current class name
  58252. * @returns the class name
  58253. */
  58254. getClassName(): string;
  58255. /**
  58256. * Gets the input component
  58257. */
  58258. get input(): NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the source min input component
  58261. */
  58262. get sourceMin(): NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the source max input component
  58265. */
  58266. get sourceMax(): NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the target min input component
  58269. */
  58270. get targetMin(): NodeMaterialConnectionPoint;
  58271. /**
  58272. * Gets the target max input component
  58273. */
  58274. get targetMax(): NodeMaterialConnectionPoint;
  58275. /**
  58276. * Gets the output component
  58277. */
  58278. get output(): NodeMaterialConnectionPoint;
  58279. protected _buildBlock(state: NodeMaterialBuildState): this;
  58280. protected _dumpPropertiesCode(): string;
  58281. serialize(): any;
  58282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58283. }
  58284. }
  58285. declare module BABYLON {
  58286. /**
  58287. * Block used to multiply 2 values
  58288. */
  58289. export class MultiplyBlock extends NodeMaterialBlock {
  58290. /**
  58291. * Creates a new MultiplyBlock
  58292. * @param name defines the block name
  58293. */
  58294. constructor(name: string);
  58295. /**
  58296. * Gets the current class name
  58297. * @returns the class name
  58298. */
  58299. getClassName(): string;
  58300. /**
  58301. * Gets the left operand input component
  58302. */
  58303. get left(): NodeMaterialConnectionPoint;
  58304. /**
  58305. * Gets the right operand input component
  58306. */
  58307. get right(): NodeMaterialConnectionPoint;
  58308. /**
  58309. * Gets the output component
  58310. */
  58311. get output(): NodeMaterialConnectionPoint;
  58312. protected _buildBlock(state: NodeMaterialBuildState): this;
  58313. }
  58314. }
  58315. declare module BABYLON {
  58316. /**
  58317. * Interface used to configure the node material editor
  58318. */
  58319. export interface INodeMaterialEditorOptions {
  58320. /** Define the URl to load node editor script */
  58321. editorURL?: string;
  58322. }
  58323. /** @hidden */
  58324. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58325. NORMAL: boolean;
  58326. TANGENT: boolean;
  58327. UV1: boolean;
  58328. /** BONES */
  58329. NUM_BONE_INFLUENCERS: number;
  58330. BonesPerMesh: number;
  58331. BONETEXTURE: boolean;
  58332. /** MORPH TARGETS */
  58333. MORPHTARGETS: boolean;
  58334. MORPHTARGETS_NORMAL: boolean;
  58335. MORPHTARGETS_TANGENT: boolean;
  58336. MORPHTARGETS_UV: boolean;
  58337. NUM_MORPH_INFLUENCERS: number;
  58338. /** IMAGE PROCESSING */
  58339. IMAGEPROCESSING: boolean;
  58340. VIGNETTE: boolean;
  58341. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58342. VIGNETTEBLENDMODEOPAQUE: boolean;
  58343. TONEMAPPING: boolean;
  58344. TONEMAPPING_ACES: boolean;
  58345. CONTRAST: boolean;
  58346. EXPOSURE: boolean;
  58347. COLORCURVES: boolean;
  58348. COLORGRADING: boolean;
  58349. COLORGRADING3D: boolean;
  58350. SAMPLER3DGREENDEPTH: boolean;
  58351. SAMPLER3DBGRMAP: boolean;
  58352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58353. /** MISC. */
  58354. BUMPDIRECTUV: number;
  58355. constructor();
  58356. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  58357. }
  58358. /**
  58359. * Class used to configure NodeMaterial
  58360. */
  58361. export interface INodeMaterialOptions {
  58362. /**
  58363. * Defines if blocks should emit comments
  58364. */
  58365. emitComments: boolean;
  58366. }
  58367. /**
  58368. * Class used to create a node based material built by assembling shader blocks
  58369. */
  58370. export class NodeMaterial extends PushMaterial {
  58371. private static _BuildIdGenerator;
  58372. private _options;
  58373. private _vertexCompilationState;
  58374. private _fragmentCompilationState;
  58375. private _sharedData;
  58376. private _buildId;
  58377. private _buildWasSuccessful;
  58378. private _cachedWorldViewMatrix;
  58379. private _cachedWorldViewProjectionMatrix;
  58380. private _optimizers;
  58381. private _animationFrame;
  58382. /** Define the Url to load node editor script */
  58383. static EditorURL: string;
  58384. /** Define the Url to load snippets */
  58385. static SnippetUrl: string;
  58386. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  58387. static IgnoreTexturesAtLoadTime: boolean;
  58388. private BJSNODEMATERIALEDITOR;
  58389. /** Get the inspector from bundle or global */
  58390. private _getGlobalNodeMaterialEditor;
  58391. /**
  58392. * Snippet ID if the material was created from the snippet server
  58393. */
  58394. snippetId: string;
  58395. /**
  58396. * Gets or sets data used by visual editor
  58397. * @see https://nme.babylonjs.com
  58398. */
  58399. editorData: any;
  58400. /**
  58401. * 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)
  58402. */
  58403. ignoreAlpha: boolean;
  58404. /**
  58405. * Defines the maximum number of lights that can be used in the material
  58406. */
  58407. maxSimultaneousLights: number;
  58408. /**
  58409. * Observable raised when the material is built
  58410. */
  58411. onBuildObservable: Observable<NodeMaterial>;
  58412. /**
  58413. * Gets or sets the root nodes of the material vertex shader
  58414. */
  58415. _vertexOutputNodes: NodeMaterialBlock[];
  58416. /**
  58417. * Gets or sets the root nodes of the material fragment (pixel) shader
  58418. */
  58419. _fragmentOutputNodes: NodeMaterialBlock[];
  58420. /** Gets or sets options to control the node material overall behavior */
  58421. get options(): INodeMaterialOptions;
  58422. set options(options: INodeMaterialOptions);
  58423. /**
  58424. * Default configuration related to image processing available in the standard Material.
  58425. */
  58426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58427. /**
  58428. * Gets the image processing configuration used either in this material.
  58429. */
  58430. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58431. /**
  58432. * Sets the Default image processing configuration used either in the this material.
  58433. *
  58434. * If sets to null, the scene one is in use.
  58435. */
  58436. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58437. /**
  58438. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58439. */
  58440. attachedBlocks: NodeMaterialBlock[];
  58441. /**
  58442. * Specifies the mode of the node material
  58443. * @hidden
  58444. */
  58445. _mode: NodeMaterialModes;
  58446. /**
  58447. * Gets the mode property
  58448. */
  58449. get mode(): NodeMaterialModes;
  58450. /**
  58451. * Create a new node based material
  58452. * @param name defines the material name
  58453. * @param scene defines the hosting scene
  58454. * @param options defines creation option
  58455. */
  58456. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58457. /**
  58458. * Gets the current class name of the material e.g. "NodeMaterial"
  58459. * @returns the class name
  58460. */
  58461. getClassName(): string;
  58462. /**
  58463. * Keep track of the image processing observer to allow dispose and replace.
  58464. */
  58465. private _imageProcessingObserver;
  58466. /**
  58467. * Attaches a new image processing configuration to the Standard Material.
  58468. * @param configuration
  58469. */
  58470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58471. /**
  58472. * Get a block by its name
  58473. * @param name defines the name of the block to retrieve
  58474. * @returns the required block or null if not found
  58475. */
  58476. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58477. /**
  58478. * Get a block by its name
  58479. * @param predicate defines the predicate used to find the good candidate
  58480. * @returns the required block or null if not found
  58481. */
  58482. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58483. /**
  58484. * Get an input block by its name
  58485. * @param predicate defines the predicate used to find the good candidate
  58486. * @returns the required input block or null if not found
  58487. */
  58488. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58489. /**
  58490. * Gets the list of input blocks attached to this material
  58491. * @returns an array of InputBlocks
  58492. */
  58493. getInputBlocks(): InputBlock[];
  58494. /**
  58495. * Adds a new optimizer to the list of optimizers
  58496. * @param optimizer defines the optimizers to add
  58497. * @returns the current material
  58498. */
  58499. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58500. /**
  58501. * Remove an optimizer from the list of optimizers
  58502. * @param optimizer defines the optimizers to remove
  58503. * @returns the current material
  58504. */
  58505. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58506. /**
  58507. * Add a new block to the list of output nodes
  58508. * @param node defines the node to add
  58509. * @returns the current material
  58510. */
  58511. addOutputNode(node: NodeMaterialBlock): this;
  58512. /**
  58513. * Remove a block from the list of root nodes
  58514. * @param node defines the node to remove
  58515. * @returns the current material
  58516. */
  58517. removeOutputNode(node: NodeMaterialBlock): this;
  58518. private _addVertexOutputNode;
  58519. private _removeVertexOutputNode;
  58520. private _addFragmentOutputNode;
  58521. private _removeFragmentOutputNode;
  58522. /**
  58523. * Specifies if the material will require alpha blending
  58524. * @returns a boolean specifying if alpha blending is needed
  58525. */
  58526. needAlphaBlending(): boolean;
  58527. /**
  58528. * Specifies if this material should be rendered in alpha test mode
  58529. * @returns a boolean specifying if an alpha test is needed.
  58530. */
  58531. needAlphaTesting(): boolean;
  58532. private _initializeBlock;
  58533. private _resetDualBlocks;
  58534. /**
  58535. * Remove a block from the current node material
  58536. * @param block defines the block to remove
  58537. */
  58538. removeBlock(block: NodeMaterialBlock): void;
  58539. /**
  58540. * Build the material and generates the inner effect
  58541. * @param verbose defines if the build should log activity
  58542. */
  58543. build(verbose?: boolean): void;
  58544. /**
  58545. * Runs an otpimization phase to try to improve the shader code
  58546. */
  58547. optimize(): void;
  58548. private _prepareDefinesForAttributes;
  58549. /**
  58550. * Create a post process from the material
  58551. * @param camera The camera to apply the render pass to.
  58552. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  58553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58554. * @param engine The engine which the post process will be applied. (default: current engine)
  58555. * @param reusable If the post process can be reused on the same frame. (default: false)
  58556. * @param textureType Type of textures used when performing the post process. (default: 0)
  58557. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  58558. * @returns the post process created
  58559. */
  58560. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  58561. private _processDefines;
  58562. /**
  58563. * Get if the submesh is ready to be used and all its information available.
  58564. * Child classes can use it to update shaders
  58565. * @param mesh defines the mesh to check
  58566. * @param subMesh defines which submesh to check
  58567. * @param useInstances specifies that instances should be used
  58568. * @returns a boolean indicating that the submesh is ready or not
  58569. */
  58570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58571. /**
  58572. * Get a string representing the shaders built by the current node graph
  58573. */
  58574. get compiledShaders(): string;
  58575. /**
  58576. * Binds the world matrix to the material
  58577. * @param world defines the world transformation matrix
  58578. */
  58579. bindOnlyWorldMatrix(world: Matrix): void;
  58580. /**
  58581. * Binds the submesh to this material by preparing the effect and shader to draw
  58582. * @param world defines the world transformation matrix
  58583. * @param mesh defines the mesh containing the submesh
  58584. * @param subMesh defines the submesh to bind the material to
  58585. */
  58586. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58587. /**
  58588. * Gets the active textures from the material
  58589. * @returns an array of textures
  58590. */
  58591. getActiveTextures(): BaseTexture[];
  58592. /**
  58593. * Gets the list of texture blocks
  58594. * @returns an array of texture blocks
  58595. */
  58596. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  58597. /**
  58598. * Specifies if the material uses a texture
  58599. * @param texture defines the texture to check against the material
  58600. * @returns a boolean specifying if the material uses the texture
  58601. */
  58602. hasTexture(texture: BaseTexture): boolean;
  58603. /**
  58604. * Disposes the material
  58605. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58606. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58607. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58608. */
  58609. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58610. /** Creates the node editor window. */
  58611. private _createNodeEditor;
  58612. /**
  58613. * Launch the node material editor
  58614. * @param config Define the configuration of the editor
  58615. * @return a promise fulfilled when the node editor is visible
  58616. */
  58617. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58618. /**
  58619. * Clear the current material
  58620. */
  58621. clear(): void;
  58622. /**
  58623. * Clear the current material and set it to a default state
  58624. */
  58625. setToDefault(): void;
  58626. /**
  58627. * Clear the current material and set it to a default state for post process
  58628. */
  58629. setToDefaultPostProcess(): void;
  58630. /**
  58631. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58632. * @param url defines the url to load from
  58633. * @returns a promise that will fullfil when the material is fully loaded
  58634. */
  58635. loadAsync(url: string): Promise<void>;
  58636. private _gatherBlocks;
  58637. /**
  58638. * Generate a string containing the code declaration required to create an equivalent of this material
  58639. * @returns a string
  58640. */
  58641. generateCode(): string;
  58642. /**
  58643. * Serializes this material in a JSON representation
  58644. * @returns the serialized material object
  58645. */
  58646. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58647. private _restoreConnections;
  58648. /**
  58649. * Clear the current graph and load a new one from a serialization object
  58650. * @param source defines the JSON representation of the material
  58651. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58652. */
  58653. loadFromSerialization(source: any, rootUrl?: string): void;
  58654. /**
  58655. * Makes a duplicate of the current material.
  58656. * @param name - name to use for the new material.
  58657. */
  58658. clone(name: string): NodeMaterial;
  58659. /**
  58660. * Creates a node material from parsed material data
  58661. * @param source defines the JSON representation of the material
  58662. * @param scene defines the hosting scene
  58663. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58664. * @returns a new node material
  58665. */
  58666. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58667. /**
  58668. * Creates a node material from a snippet saved in a remote file
  58669. * @param name defines the name of the material to create
  58670. * @param url defines the url to load from
  58671. * @param scene defines the hosting scene
  58672. * @returns a promise that will resolve to the new node material
  58673. */
  58674. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58675. /**
  58676. * Creates a node material from a snippet saved by the node material editor
  58677. * @param snippetId defines the snippet to load
  58678. * @param scene defines the hosting scene
  58679. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58680. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58681. * @returns a promise that will resolve to the new node material
  58682. */
  58683. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58684. /**
  58685. * Creates a new node material set to default basic configuration
  58686. * @param name defines the name of the material
  58687. * @param scene defines the hosting scene
  58688. * @returns a new NodeMaterial
  58689. */
  58690. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58691. }
  58692. }
  58693. declare module BABYLON {
  58694. /**
  58695. * Block used to read a texture from a sampler
  58696. */
  58697. export class TextureBlock extends NodeMaterialBlock {
  58698. private _defineName;
  58699. private _linearDefineName;
  58700. private _gammaDefineName;
  58701. private _tempTextureRead;
  58702. private _samplerName;
  58703. private _transformedUVName;
  58704. private _textureTransformName;
  58705. private _textureInfoName;
  58706. private _mainUVName;
  58707. private _mainUVDefineName;
  58708. /**
  58709. * Gets or sets the texture associated with the node
  58710. */
  58711. texture: Nullable<Texture>;
  58712. /**
  58713. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58714. */
  58715. convertToGammaSpace: boolean;
  58716. /**
  58717. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58718. */
  58719. convertToLinearSpace: boolean;
  58720. /**
  58721. * Create a new TextureBlock
  58722. * @param name defines the block name
  58723. */
  58724. constructor(name: string);
  58725. /**
  58726. * Gets the current class name
  58727. * @returns the class name
  58728. */
  58729. getClassName(): string;
  58730. /**
  58731. * Gets the uv input component
  58732. */
  58733. get uv(): NodeMaterialConnectionPoint;
  58734. /**
  58735. * Gets the rgba output component
  58736. */
  58737. get rgba(): NodeMaterialConnectionPoint;
  58738. /**
  58739. * Gets the rgb output component
  58740. */
  58741. get rgb(): NodeMaterialConnectionPoint;
  58742. /**
  58743. * Gets the r output component
  58744. */
  58745. get r(): NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the g output component
  58748. */
  58749. get g(): NodeMaterialConnectionPoint;
  58750. /**
  58751. * Gets the b output component
  58752. */
  58753. get b(): NodeMaterialConnectionPoint;
  58754. /**
  58755. * Gets the a output component
  58756. */
  58757. get a(): NodeMaterialConnectionPoint;
  58758. get target(): NodeMaterialBlockTargets;
  58759. autoConfigure(material: NodeMaterial): void;
  58760. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58762. isReady(): boolean;
  58763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58764. private get _isMixed();
  58765. private _injectVertexCode;
  58766. private _writeTextureRead;
  58767. private _writeOutput;
  58768. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58769. protected _dumpPropertiesCode(): string;
  58770. serialize(): any;
  58771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58772. }
  58773. }
  58774. declare module BABYLON {
  58775. /**
  58776. * Class used to store shared data between 2 NodeMaterialBuildState
  58777. */
  58778. export class NodeMaterialBuildStateSharedData {
  58779. /**
  58780. * Gets the list of emitted varyings
  58781. */
  58782. temps: string[];
  58783. /**
  58784. * Gets the list of emitted varyings
  58785. */
  58786. varyings: string[];
  58787. /**
  58788. * Gets the varying declaration string
  58789. */
  58790. varyingDeclaration: string;
  58791. /**
  58792. * Input blocks
  58793. */
  58794. inputBlocks: InputBlock[];
  58795. /**
  58796. * Input blocks
  58797. */
  58798. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  58799. /**
  58800. * Bindable blocks (Blocks that need to set data to the effect)
  58801. */
  58802. bindableBlocks: NodeMaterialBlock[];
  58803. /**
  58804. * List of blocks that can provide a compilation fallback
  58805. */
  58806. blocksWithFallbacks: NodeMaterialBlock[];
  58807. /**
  58808. * List of blocks that can provide a define update
  58809. */
  58810. blocksWithDefines: NodeMaterialBlock[];
  58811. /**
  58812. * List of blocks that can provide a repeatable content
  58813. */
  58814. repeatableContentBlocks: NodeMaterialBlock[];
  58815. /**
  58816. * List of blocks that can provide a dynamic list of uniforms
  58817. */
  58818. dynamicUniformBlocks: NodeMaterialBlock[];
  58819. /**
  58820. * List of blocks that can block the isReady function for the material
  58821. */
  58822. blockingBlocks: NodeMaterialBlock[];
  58823. /**
  58824. * Gets the list of animated inputs
  58825. */
  58826. animatedInputs: InputBlock[];
  58827. /**
  58828. * Build Id used to avoid multiple recompilations
  58829. */
  58830. buildId: number;
  58831. /** List of emitted variables */
  58832. variableNames: {
  58833. [key: string]: number;
  58834. };
  58835. /** List of emitted defines */
  58836. defineNames: {
  58837. [key: string]: number;
  58838. };
  58839. /** Should emit comments? */
  58840. emitComments: boolean;
  58841. /** Emit build activity */
  58842. verbose: boolean;
  58843. /** Gets or sets the hosting scene */
  58844. scene: Scene;
  58845. /**
  58846. * Gets the compilation hints emitted at compilation time
  58847. */
  58848. hints: {
  58849. needWorldViewMatrix: boolean;
  58850. needWorldViewProjectionMatrix: boolean;
  58851. needAlphaBlending: boolean;
  58852. needAlphaTesting: boolean;
  58853. };
  58854. /**
  58855. * List of compilation checks
  58856. */
  58857. checks: {
  58858. emitVertex: boolean;
  58859. emitFragment: boolean;
  58860. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58861. };
  58862. /** Creates a new shared data */
  58863. constructor();
  58864. /**
  58865. * Emits console errors and exceptions if there is a failing check
  58866. */
  58867. emitErrors(): void;
  58868. }
  58869. }
  58870. declare module BABYLON {
  58871. /**
  58872. * Class used to store node based material build state
  58873. */
  58874. export class NodeMaterialBuildState {
  58875. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58876. supportUniformBuffers: boolean;
  58877. /**
  58878. * Gets the list of emitted attributes
  58879. */
  58880. attributes: string[];
  58881. /**
  58882. * Gets the list of emitted uniforms
  58883. */
  58884. uniforms: string[];
  58885. /**
  58886. * Gets the list of emitted constants
  58887. */
  58888. constants: string[];
  58889. /**
  58890. * Gets the list of emitted samplers
  58891. */
  58892. samplers: string[];
  58893. /**
  58894. * Gets the list of emitted functions
  58895. */
  58896. functions: {
  58897. [key: string]: string;
  58898. };
  58899. /**
  58900. * Gets the list of emitted extensions
  58901. */
  58902. extensions: {
  58903. [key: string]: string;
  58904. };
  58905. /**
  58906. * Gets the target of the compilation state
  58907. */
  58908. target: NodeMaterialBlockTargets;
  58909. /**
  58910. * Gets the list of emitted counters
  58911. */
  58912. counters: {
  58913. [key: string]: number;
  58914. };
  58915. /**
  58916. * Shared data between multiple NodeMaterialBuildState instances
  58917. */
  58918. sharedData: NodeMaterialBuildStateSharedData;
  58919. /** @hidden */
  58920. _vertexState: NodeMaterialBuildState;
  58921. /** @hidden */
  58922. _attributeDeclaration: string;
  58923. /** @hidden */
  58924. _uniformDeclaration: string;
  58925. /** @hidden */
  58926. _constantDeclaration: string;
  58927. /** @hidden */
  58928. _samplerDeclaration: string;
  58929. /** @hidden */
  58930. _varyingTransfer: string;
  58931. /** @hidden */
  58932. _injectAtEnd: string;
  58933. private _repeatableContentAnchorIndex;
  58934. /** @hidden */
  58935. _builtCompilationString: string;
  58936. /**
  58937. * Gets the emitted compilation strings
  58938. */
  58939. compilationString: string;
  58940. /**
  58941. * Finalize the compilation strings
  58942. * @param state defines the current compilation state
  58943. */
  58944. finalize(state: NodeMaterialBuildState): void;
  58945. /** @hidden */
  58946. get _repeatableContentAnchor(): string;
  58947. /** @hidden */
  58948. _getFreeVariableName(prefix: string): string;
  58949. /** @hidden */
  58950. _getFreeDefineName(prefix: string): string;
  58951. /** @hidden */
  58952. _excludeVariableName(name: string): void;
  58953. /** @hidden */
  58954. _emit2DSampler(name: string): void;
  58955. /** @hidden */
  58956. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58957. /** @hidden */
  58958. _emitExtension(name: string, extension: string, define?: string): void;
  58959. /** @hidden */
  58960. _emitFunction(name: string, code: string, comments: string): void;
  58961. /** @hidden */
  58962. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58963. replaceStrings?: {
  58964. search: RegExp;
  58965. replace: string;
  58966. }[];
  58967. repeatKey?: string;
  58968. }): string;
  58969. /** @hidden */
  58970. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58971. repeatKey?: string;
  58972. removeAttributes?: boolean;
  58973. removeUniforms?: boolean;
  58974. removeVaryings?: boolean;
  58975. removeIfDef?: boolean;
  58976. replaceStrings?: {
  58977. search: RegExp;
  58978. replace: string;
  58979. }[];
  58980. }, storeKey?: string): void;
  58981. /** @hidden */
  58982. _registerTempVariable(name: string): boolean;
  58983. /** @hidden */
  58984. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58985. /** @hidden */
  58986. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58987. /** @hidden */
  58988. _emitFloat(value: number): string;
  58989. }
  58990. }
  58991. declare module BABYLON {
  58992. /**
  58993. * Defines a block that can be used inside a node based material
  58994. */
  58995. export class NodeMaterialBlock {
  58996. private _buildId;
  58997. private _buildTarget;
  58998. private _target;
  58999. private _isFinalMerger;
  59000. private _isInput;
  59001. protected _isUnique: boolean;
  59002. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  59003. inputsAreExclusive: boolean;
  59004. /** @hidden */
  59005. _codeVariableName: string;
  59006. /** @hidden */
  59007. _inputs: NodeMaterialConnectionPoint[];
  59008. /** @hidden */
  59009. _outputs: NodeMaterialConnectionPoint[];
  59010. /** @hidden */
  59011. _preparationId: number;
  59012. /**
  59013. * Gets or sets the name of the block
  59014. */
  59015. name: string;
  59016. /**
  59017. * Gets or sets the unique id of the node
  59018. */
  59019. uniqueId: number;
  59020. /**
  59021. * Gets or sets the comments associated with this block
  59022. */
  59023. comments: string;
  59024. /**
  59025. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59026. */
  59027. get isUnique(): boolean;
  59028. /**
  59029. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59030. */
  59031. get isFinalMerger(): boolean;
  59032. /**
  59033. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59034. */
  59035. get isInput(): boolean;
  59036. /**
  59037. * Gets or sets the build Id
  59038. */
  59039. get buildId(): number;
  59040. set buildId(value: number);
  59041. /**
  59042. * Gets or sets the target of the block
  59043. */
  59044. get target(): NodeMaterialBlockTargets;
  59045. set target(value: NodeMaterialBlockTargets);
  59046. /**
  59047. * Gets the list of input points
  59048. */
  59049. get inputs(): NodeMaterialConnectionPoint[];
  59050. /** Gets the list of output points */
  59051. get outputs(): NodeMaterialConnectionPoint[];
  59052. /**
  59053. * Find an input by its name
  59054. * @param name defines the name of the input to look for
  59055. * @returns the input or null if not found
  59056. */
  59057. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59058. /**
  59059. * Find an output by its name
  59060. * @param name defines the name of the outputto look for
  59061. * @returns the output or null if not found
  59062. */
  59063. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59064. /**
  59065. * Creates a new NodeMaterialBlock
  59066. * @param name defines the block name
  59067. * @param target defines the target of that block (Vertex by default)
  59068. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59069. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59070. */
  59071. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59072. /**
  59073. * Initialize the block and prepare the context for build
  59074. * @param state defines the state that will be used for the build
  59075. */
  59076. initialize(state: NodeMaterialBuildState): void;
  59077. /**
  59078. * Bind data to effect. Will only be called for blocks with isBindable === true
  59079. * @param effect defines the effect to bind data to
  59080. * @param nodeMaterial defines the hosting NodeMaterial
  59081. * @param mesh defines the mesh that will be rendered
  59082. * @param subMesh defines the submesh that will be rendered
  59083. */
  59084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  59085. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59086. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59087. protected _writeFloat(value: number): string;
  59088. /**
  59089. * Gets the current class name e.g. "NodeMaterialBlock"
  59090. * @returns the class name
  59091. */
  59092. getClassName(): string;
  59093. /**
  59094. * Register a new input. Must be called inside a block constructor
  59095. * @param name defines the connection point name
  59096. * @param type defines the connection point type
  59097. * @param isOptional defines a boolean indicating that this input can be omitted
  59098. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59099. * @param point an already created connection point. If not provided, create a new one
  59100. * @returns the current block
  59101. */
  59102. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59103. /**
  59104. * Register a new output. Must be called inside a block constructor
  59105. * @param name defines the connection point name
  59106. * @param type defines the connection point type
  59107. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59108. * @param point an already created connection point. If not provided, create a new one
  59109. * @returns the current block
  59110. */
  59111. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59112. /**
  59113. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59114. * @param forOutput defines an optional connection point to check compatibility with
  59115. * @returns the first available input or null
  59116. */
  59117. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59118. /**
  59119. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59120. * @param forBlock defines an optional block to check compatibility with
  59121. * @returns the first available input or null
  59122. */
  59123. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59124. /**
  59125. * Gets the sibling of the given output
  59126. * @param current defines the current output
  59127. * @returns the next output in the list or null
  59128. */
  59129. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59130. /**
  59131. * Connect current block with another block
  59132. * @param other defines the block to connect with
  59133. * @param options define the various options to help pick the right connections
  59134. * @returns the current block
  59135. */
  59136. connectTo(other: NodeMaterialBlock, options?: {
  59137. input?: string;
  59138. output?: string;
  59139. outputSwizzle?: string;
  59140. }): this | undefined;
  59141. protected _buildBlock(state: NodeMaterialBuildState): void;
  59142. /**
  59143. * Add uniforms, samplers and uniform buffers at compilation time
  59144. * @param state defines the state to update
  59145. * @param nodeMaterial defines the node material requesting the update
  59146. * @param defines defines the material defines to update
  59147. * @param uniformBuffers defines the list of uniform buffer names
  59148. */
  59149. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59150. /**
  59151. * Add potential fallbacks if shader compilation fails
  59152. * @param mesh defines the mesh to be rendered
  59153. * @param fallbacks defines the current prioritized list of fallbacks
  59154. */
  59155. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59156. /**
  59157. * Initialize defines for shader compilation
  59158. * @param mesh defines the mesh to be rendered
  59159. * @param nodeMaterial defines the node material requesting the update
  59160. * @param defines defines the material defines to update
  59161. * @param useInstances specifies that instances should be used
  59162. */
  59163. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59164. /**
  59165. * Update defines for shader compilation
  59166. * @param mesh defines the mesh to be rendered
  59167. * @param nodeMaterial defines the node material requesting the update
  59168. * @param defines defines the material defines to update
  59169. * @param useInstances specifies that instances should be used
  59170. */
  59171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59172. /**
  59173. * Lets the block try to connect some inputs automatically
  59174. * @param material defines the hosting NodeMaterial
  59175. */
  59176. autoConfigure(material: NodeMaterial): void;
  59177. /**
  59178. * Function called when a block is declared as repeatable content generator
  59179. * @param vertexShaderState defines the current compilation state for the vertex shader
  59180. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59181. * @param mesh defines the mesh to be rendered
  59182. * @param defines defines the material defines to update
  59183. */
  59184. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59185. /**
  59186. * Checks if the block is ready
  59187. * @param mesh defines the mesh to be rendered
  59188. * @param nodeMaterial defines the node material requesting the update
  59189. * @param defines defines the material defines to update
  59190. * @param useInstances specifies that instances should be used
  59191. * @returns true if the block is ready
  59192. */
  59193. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59194. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59195. private _processBuild;
  59196. /**
  59197. * Compile the current node and generate the shader code
  59198. * @param state defines the current compilation state (uniforms, samplers, current string)
  59199. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59200. * @returns true if already built
  59201. */
  59202. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59203. protected _inputRename(name: string): string;
  59204. protected _outputRename(name: string): string;
  59205. protected _dumpPropertiesCode(): string;
  59206. /** @hidden */
  59207. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59208. /** @hidden */
  59209. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59210. /**
  59211. * Clone the current block to a new identical block
  59212. * @param scene defines the hosting scene
  59213. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59214. * @returns a copy of the current block
  59215. */
  59216. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59217. /**
  59218. * Serializes this block in a JSON representation
  59219. * @returns the serialized block object
  59220. */
  59221. serialize(): any;
  59222. /** @hidden */
  59223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59224. private _deserializePortDisplayNames;
  59225. /**
  59226. * Release resources
  59227. */
  59228. dispose(): void;
  59229. }
  59230. }
  59231. declare module BABYLON {
  59232. /**
  59233. * Enum defining the type of animations supported by InputBlock
  59234. */
  59235. export enum AnimatedInputBlockTypes {
  59236. /** No animation */
  59237. None = 0,
  59238. /** Time based animation. Will only work for floats */
  59239. Time = 1
  59240. }
  59241. }
  59242. declare module BABYLON {
  59243. /**
  59244. * Block used to expose an input value
  59245. */
  59246. export class InputBlock extends NodeMaterialBlock {
  59247. private _mode;
  59248. private _associatedVariableName;
  59249. private _storedValue;
  59250. private _valueCallback;
  59251. private _type;
  59252. private _animationType;
  59253. /** Gets or set a value used to limit the range of float values */
  59254. min: number;
  59255. /** Gets or set a value used to limit the range of float values */
  59256. max: number;
  59257. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  59258. isBoolean: boolean;
  59259. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59260. matrixMode: number;
  59261. /** @hidden */
  59262. _systemValue: Nullable<NodeMaterialSystemValues>;
  59263. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59264. visibleInInspector: boolean;
  59265. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59266. isConstant: boolean;
  59267. /** Gets or sets the group to use to display this block in the Inspector */
  59268. groupInInspector: string;
  59269. /** Gets an observable raised when the value is changed */
  59270. onValueChangedObservable: Observable<InputBlock>;
  59271. /**
  59272. * Gets or sets the connection point type (default is float)
  59273. */
  59274. get type(): NodeMaterialBlockConnectionPointTypes;
  59275. /**
  59276. * Creates a new InputBlock
  59277. * @param name defines the block name
  59278. * @param target defines the target of that block (Vertex by default)
  59279. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59280. */
  59281. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59282. /**
  59283. * Gets the output component
  59284. */
  59285. get output(): NodeMaterialConnectionPoint;
  59286. /**
  59287. * Set the source of this connection point to a vertex attribute
  59288. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59289. * @returns the current connection point
  59290. */
  59291. setAsAttribute(attributeName?: string): InputBlock;
  59292. /**
  59293. * Set the source of this connection point to a system value
  59294. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59295. * @returns the current connection point
  59296. */
  59297. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59298. /**
  59299. * Gets or sets the value of that point.
  59300. * Please note that this value will be ignored if valueCallback is defined
  59301. */
  59302. get value(): any;
  59303. set value(value: any);
  59304. /**
  59305. * Gets or sets a callback used to get the value of that point.
  59306. * Please note that setting this value will force the connection point to ignore the value property
  59307. */
  59308. get valueCallback(): () => any;
  59309. set valueCallback(value: () => any);
  59310. /**
  59311. * Gets or sets the associated variable name in the shader
  59312. */
  59313. get associatedVariableName(): string;
  59314. set associatedVariableName(value: string);
  59315. /** Gets or sets the type of animation applied to the input */
  59316. get animationType(): AnimatedInputBlockTypes;
  59317. set animationType(value: AnimatedInputBlockTypes);
  59318. /**
  59319. * Gets a boolean indicating that this connection point not defined yet
  59320. */
  59321. get isUndefined(): boolean;
  59322. /**
  59323. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59324. * In this case the connection point name must be the name of the uniform to use.
  59325. * Can only be set on inputs
  59326. */
  59327. get isUniform(): boolean;
  59328. set isUniform(value: boolean);
  59329. /**
  59330. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59331. * In this case the connection point name must be the name of the attribute to use
  59332. * Can only be set on inputs
  59333. */
  59334. get isAttribute(): boolean;
  59335. set isAttribute(value: boolean);
  59336. /**
  59337. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59338. * Can only be set on exit points
  59339. */
  59340. get isVarying(): boolean;
  59341. set isVarying(value: boolean);
  59342. /**
  59343. * Gets a boolean indicating that the current connection point is a system value
  59344. */
  59345. get isSystemValue(): boolean;
  59346. /**
  59347. * Gets or sets the current well known value or null if not defined as a system value
  59348. */
  59349. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59350. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59351. /**
  59352. * Gets the current class name
  59353. * @returns the class name
  59354. */
  59355. getClassName(): string;
  59356. /**
  59357. * Animate the input if animationType !== None
  59358. * @param scene defines the rendering scene
  59359. */
  59360. animate(scene: Scene): void;
  59361. private _emitDefine;
  59362. initialize(state: NodeMaterialBuildState): void;
  59363. /**
  59364. * Set the input block to its default value (based on its type)
  59365. */
  59366. setDefaultValue(): void;
  59367. private _emitConstant;
  59368. private _emit;
  59369. /** @hidden */
  59370. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59371. /** @hidden */
  59372. _transmit(effect: Effect, scene: Scene): void;
  59373. protected _buildBlock(state: NodeMaterialBuildState): void;
  59374. protected _dumpPropertiesCode(): string;
  59375. dispose(): void;
  59376. serialize(): any;
  59377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59378. }
  59379. }
  59380. declare module BABYLON {
  59381. /**
  59382. * Enum used to define the compatibility state between two connection points
  59383. */
  59384. export enum NodeMaterialConnectionPointCompatibilityStates {
  59385. /** Points are compatibles */
  59386. Compatible = 0,
  59387. /** Points are incompatible because of their types */
  59388. TypeIncompatible = 1,
  59389. /** Points are incompatible because of their targets (vertex vs fragment) */
  59390. TargetIncompatible = 2
  59391. }
  59392. /**
  59393. * Defines the direction of a connection point
  59394. */
  59395. export enum NodeMaterialConnectionPointDirection {
  59396. /** Input */
  59397. Input = 0,
  59398. /** Output */
  59399. Output = 1
  59400. }
  59401. /**
  59402. * Defines a connection point for a block
  59403. */
  59404. export class NodeMaterialConnectionPoint {
  59405. /** @hidden */
  59406. _ownerBlock: NodeMaterialBlock;
  59407. /** @hidden */
  59408. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59409. private _endpoints;
  59410. private _associatedVariableName;
  59411. private _direction;
  59412. /** @hidden */
  59413. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59414. /** @hidden */
  59415. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59416. private _type;
  59417. /** @hidden */
  59418. _enforceAssociatedVariableName: boolean;
  59419. /** Gets the direction of the point */
  59420. get direction(): NodeMaterialConnectionPointDirection;
  59421. /** Indicates that this connection point needs dual validation before being connected to another point */
  59422. needDualDirectionValidation: boolean;
  59423. /**
  59424. * Gets or sets the additional types supported by this connection point
  59425. */
  59426. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59427. /**
  59428. * Gets or sets the additional types excluded by this connection point
  59429. */
  59430. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59431. /**
  59432. * Observable triggered when this point is connected
  59433. */
  59434. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59435. /**
  59436. * Gets or sets the associated variable name in the shader
  59437. */
  59438. get associatedVariableName(): string;
  59439. set associatedVariableName(value: string);
  59440. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  59441. get innerType(): NodeMaterialBlockConnectionPointTypes;
  59442. /**
  59443. * Gets or sets the connection point type (default is float)
  59444. */
  59445. get type(): NodeMaterialBlockConnectionPointTypes;
  59446. set type(value: NodeMaterialBlockConnectionPointTypes);
  59447. /**
  59448. * Gets or sets the connection point name
  59449. */
  59450. name: string;
  59451. /**
  59452. * Gets or sets the connection point name
  59453. */
  59454. displayName: string;
  59455. /**
  59456. * Gets or sets a boolean indicating that this connection point can be omitted
  59457. */
  59458. isOptional: boolean;
  59459. /**
  59460. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59461. */
  59462. define: string;
  59463. /** @hidden */
  59464. _prioritizeVertex: boolean;
  59465. private _target;
  59466. /** Gets or sets the target of that connection point */
  59467. get target(): NodeMaterialBlockTargets;
  59468. set target(value: NodeMaterialBlockTargets);
  59469. /**
  59470. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  59471. */
  59472. get isConnected(): boolean;
  59473. /**
  59474. * Gets a boolean indicating that the current point is connected to an input block
  59475. */
  59476. get isConnectedToInputBlock(): boolean;
  59477. /**
  59478. * Gets a the connected input block (if any)
  59479. */
  59480. get connectInputBlock(): Nullable<InputBlock>;
  59481. /** Get the other side of the connection (if any) */
  59482. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59483. /** Get the block that owns this connection point */
  59484. get ownerBlock(): NodeMaterialBlock;
  59485. /** Get the block connected on the other side of this connection (if any) */
  59486. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59487. /** Get the block connected on the endpoints of this connection (if any) */
  59488. get connectedBlocks(): Array<NodeMaterialBlock>;
  59489. /** Gets the list of connected endpoints */
  59490. get endpoints(): NodeMaterialConnectionPoint[];
  59491. /** Gets a boolean indicating if that output point is connected to at least one input */
  59492. get hasEndpoints(): boolean;
  59493. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59494. get isConnectedInVertexShader(): boolean;
  59495. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59496. get isConnectedInFragmentShader(): boolean;
  59497. /**
  59498. * Creates a block suitable to be used as an input for this input point.
  59499. * If null is returned, a block based on the point type will be created.
  59500. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  59501. */
  59502. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  59503. /**
  59504. * Creates a new connection point
  59505. * @param name defines the connection point name
  59506. * @param ownerBlock defines the block hosting this connection point
  59507. * @param direction defines the direction of the connection point
  59508. */
  59509. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59510. /**
  59511. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59512. * @returns the class name
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Gets a boolean indicating if the current point can be connected to another point
  59517. * @param connectionPoint defines the other connection point
  59518. * @returns a boolean
  59519. */
  59520. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59521. /**
  59522. * Gets a number indicating if the current point can be connected to another point
  59523. * @param connectionPoint defines the other connection point
  59524. * @returns a number defining the compatibility state
  59525. */
  59526. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59527. /**
  59528. * Connect this point to another connection point
  59529. * @param connectionPoint defines the other connection point
  59530. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59531. * @returns the current connection point
  59532. */
  59533. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Disconnect this point from one of his endpoint
  59536. * @param endpoint defines the other connection point
  59537. * @returns the current connection point
  59538. */
  59539. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Serializes this point in a JSON representation
  59542. * @param isInput defines if the connection point is an input (default is true)
  59543. * @returns the serialized point object
  59544. */
  59545. serialize(isInput?: boolean): any;
  59546. /**
  59547. * Release resources
  59548. */
  59549. dispose(): void;
  59550. }
  59551. }
  59552. declare module BABYLON {
  59553. /**
  59554. * Block used to add support for vertex skinning (bones)
  59555. */
  59556. export class BonesBlock extends NodeMaterialBlock {
  59557. /**
  59558. * Creates a new BonesBlock
  59559. * @param name defines the block name
  59560. */
  59561. constructor(name: string);
  59562. /**
  59563. * Initialize the block and prepare the context for build
  59564. * @param state defines the state that will be used for the build
  59565. */
  59566. initialize(state: NodeMaterialBuildState): void;
  59567. /**
  59568. * Gets the current class name
  59569. * @returns the class name
  59570. */
  59571. getClassName(): string;
  59572. /**
  59573. * Gets the matrix indices input component
  59574. */
  59575. get matricesIndices(): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the matrix weights input component
  59578. */
  59579. get matricesWeights(): NodeMaterialConnectionPoint;
  59580. /**
  59581. * Gets the extra matrix indices input component
  59582. */
  59583. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the extra matrix weights input component
  59586. */
  59587. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the world input component
  59590. */
  59591. get world(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the output component
  59594. */
  59595. get output(): NodeMaterialConnectionPoint;
  59596. autoConfigure(material: NodeMaterial): void;
  59597. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59600. protected _buildBlock(state: NodeMaterialBuildState): this;
  59601. }
  59602. }
  59603. declare module BABYLON {
  59604. /**
  59605. * Block used to add support for instances
  59606. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59607. */
  59608. export class InstancesBlock extends NodeMaterialBlock {
  59609. /**
  59610. * Creates a new InstancesBlock
  59611. * @param name defines the block name
  59612. */
  59613. constructor(name: string);
  59614. /**
  59615. * Gets the current class name
  59616. * @returns the class name
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Gets the first world row input component
  59621. */
  59622. get world0(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the second world row input component
  59625. */
  59626. get world1(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the third world row input component
  59629. */
  59630. get world2(): NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the forth world row input component
  59633. */
  59634. get world3(): NodeMaterialConnectionPoint;
  59635. /**
  59636. * Gets the world input component
  59637. */
  59638. get world(): NodeMaterialConnectionPoint;
  59639. /**
  59640. * Gets the output component
  59641. */
  59642. get output(): NodeMaterialConnectionPoint;
  59643. /**
  59644. * Gets the isntanceID component
  59645. */
  59646. get instanceID(): NodeMaterialConnectionPoint;
  59647. autoConfigure(material: NodeMaterial): void;
  59648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59649. protected _buildBlock(state: NodeMaterialBuildState): this;
  59650. }
  59651. }
  59652. declare module BABYLON {
  59653. /**
  59654. * Block used to add morph targets support to vertex shader
  59655. */
  59656. export class MorphTargetsBlock extends NodeMaterialBlock {
  59657. private _repeatableContentAnchor;
  59658. /**
  59659. * Create a new MorphTargetsBlock
  59660. * @param name defines the block name
  59661. */
  59662. constructor(name: string);
  59663. /**
  59664. * Gets the current class name
  59665. * @returns the class name
  59666. */
  59667. getClassName(): string;
  59668. /**
  59669. * Gets the position input component
  59670. */
  59671. get position(): NodeMaterialConnectionPoint;
  59672. /**
  59673. * Gets the normal input component
  59674. */
  59675. get normal(): NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the tangent input component
  59678. */
  59679. get tangent(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the tangent input component
  59682. */
  59683. get uv(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the position output component
  59686. */
  59687. get positionOutput(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the normal output component
  59690. */
  59691. get normalOutput(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the tangent output component
  59694. */
  59695. get tangentOutput(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the tangent output component
  59698. */
  59699. get uvOutput(): NodeMaterialConnectionPoint;
  59700. initialize(state: NodeMaterialBuildState): void;
  59701. autoConfigure(material: NodeMaterial): void;
  59702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59704. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59705. protected _buildBlock(state: NodeMaterialBuildState): this;
  59706. }
  59707. }
  59708. declare module BABYLON {
  59709. /**
  59710. * Block used to get data information from a light
  59711. */
  59712. export class LightInformationBlock extends NodeMaterialBlock {
  59713. private _lightDataUniformName;
  59714. private _lightColorUniformName;
  59715. private _lightTypeDefineName;
  59716. /**
  59717. * Gets or sets the light associated with this block
  59718. */
  59719. light: Nullable<Light>;
  59720. /**
  59721. * Creates a new LightInformationBlock
  59722. * @param name defines the block name
  59723. */
  59724. constructor(name: string);
  59725. /**
  59726. * Gets the current class name
  59727. * @returns the class name
  59728. */
  59729. getClassName(): string;
  59730. /**
  59731. * Gets the world position input component
  59732. */
  59733. get worldPosition(): NodeMaterialConnectionPoint;
  59734. /**
  59735. * Gets the direction output component
  59736. */
  59737. get direction(): NodeMaterialConnectionPoint;
  59738. /**
  59739. * Gets the direction output component
  59740. */
  59741. get color(): NodeMaterialConnectionPoint;
  59742. /**
  59743. * Gets the direction output component
  59744. */
  59745. get intensity(): NodeMaterialConnectionPoint;
  59746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59748. protected _buildBlock(state: NodeMaterialBuildState): this;
  59749. serialize(): any;
  59750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59751. }
  59752. }
  59753. declare module BABYLON {
  59754. /**
  59755. * Block used to add image processing support to fragment shader
  59756. */
  59757. export class ImageProcessingBlock extends NodeMaterialBlock {
  59758. /**
  59759. * Create a new ImageProcessingBlock
  59760. * @param name defines the block name
  59761. */
  59762. constructor(name: string);
  59763. /**
  59764. * Gets the current class name
  59765. * @returns the class name
  59766. */
  59767. getClassName(): string;
  59768. /**
  59769. * Gets the color input component
  59770. */
  59771. get color(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the output component
  59774. */
  59775. get output(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Initialize the block and prepare the context for build
  59778. * @param state defines the state that will be used for the build
  59779. */
  59780. initialize(state: NodeMaterialBuildState): void;
  59781. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59784. protected _buildBlock(state: NodeMaterialBuildState): this;
  59785. }
  59786. }
  59787. declare module BABYLON {
  59788. /**
  59789. * Block used to pertub normals based on a normal map
  59790. */
  59791. export class PerturbNormalBlock extends NodeMaterialBlock {
  59792. private _tangentSpaceParameterName;
  59793. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59794. invertX: boolean;
  59795. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59796. invertY: boolean;
  59797. /**
  59798. * Create a new PerturbNormalBlock
  59799. * @param name defines the block name
  59800. */
  59801. constructor(name: string);
  59802. /**
  59803. * Gets the current class name
  59804. * @returns the class name
  59805. */
  59806. getClassName(): string;
  59807. /**
  59808. * Gets the world position input component
  59809. */
  59810. get worldPosition(): NodeMaterialConnectionPoint;
  59811. /**
  59812. * Gets the world normal input component
  59813. */
  59814. get worldNormal(): NodeMaterialConnectionPoint;
  59815. /**
  59816. * Gets the world tangent input component
  59817. */
  59818. get worldTangent(): NodeMaterialConnectionPoint;
  59819. /**
  59820. * Gets the uv input component
  59821. */
  59822. get uv(): NodeMaterialConnectionPoint;
  59823. /**
  59824. * Gets the normal map color input component
  59825. */
  59826. get normalMapColor(): NodeMaterialConnectionPoint;
  59827. /**
  59828. * Gets the strength input component
  59829. */
  59830. get strength(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the output component
  59833. */
  59834. get output(): NodeMaterialConnectionPoint;
  59835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59837. autoConfigure(material: NodeMaterial): void;
  59838. protected _buildBlock(state: NodeMaterialBuildState): this;
  59839. protected _dumpPropertiesCode(): string;
  59840. serialize(): any;
  59841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59842. }
  59843. }
  59844. declare module BABYLON {
  59845. /**
  59846. * Block used to discard a pixel if a value is smaller than a cutoff
  59847. */
  59848. export class DiscardBlock extends NodeMaterialBlock {
  59849. /**
  59850. * Create a new DiscardBlock
  59851. * @param name defines the block name
  59852. */
  59853. constructor(name: string);
  59854. /**
  59855. * Gets the current class name
  59856. * @returns the class name
  59857. */
  59858. getClassName(): string;
  59859. /**
  59860. * Gets the color input component
  59861. */
  59862. get value(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the cutoff input component
  59865. */
  59866. get cutoff(): NodeMaterialConnectionPoint;
  59867. protected _buildBlock(state: NodeMaterialBuildState): this;
  59868. }
  59869. }
  59870. declare module BABYLON {
  59871. /**
  59872. * Block used to test if the fragment shader is front facing
  59873. */
  59874. export class FrontFacingBlock extends NodeMaterialBlock {
  59875. /**
  59876. * Creates a new FrontFacingBlock
  59877. * @param name defines the block name
  59878. */
  59879. constructor(name: string);
  59880. /**
  59881. * Gets the current class name
  59882. * @returns the class name
  59883. */
  59884. getClassName(): string;
  59885. /**
  59886. * Gets the output component
  59887. */
  59888. get output(): NodeMaterialConnectionPoint;
  59889. protected _buildBlock(state: NodeMaterialBuildState): this;
  59890. }
  59891. }
  59892. declare module BABYLON {
  59893. /**
  59894. * Block used to get the derivative value on x and y of a given input
  59895. */
  59896. export class DerivativeBlock extends NodeMaterialBlock {
  59897. /**
  59898. * Create a new DerivativeBlock
  59899. * @param name defines the block name
  59900. */
  59901. constructor(name: string);
  59902. /**
  59903. * Gets the current class name
  59904. * @returns the class name
  59905. */
  59906. getClassName(): string;
  59907. /**
  59908. * Gets the input component
  59909. */
  59910. get input(): NodeMaterialConnectionPoint;
  59911. /**
  59912. * Gets the derivative output on x
  59913. */
  59914. get dx(): NodeMaterialConnectionPoint;
  59915. /**
  59916. * Gets the derivative output on y
  59917. */
  59918. get dy(): NodeMaterialConnectionPoint;
  59919. protected _buildBlock(state: NodeMaterialBuildState): this;
  59920. }
  59921. }
  59922. declare module BABYLON {
  59923. /**
  59924. * Block used to add support for scene fog
  59925. */
  59926. export class FogBlock extends NodeMaterialBlock {
  59927. private _fogDistanceName;
  59928. private _fogParameters;
  59929. /**
  59930. * Create a new FogBlock
  59931. * @param name defines the block name
  59932. */
  59933. constructor(name: string);
  59934. /**
  59935. * Gets the current class name
  59936. * @returns the class name
  59937. */
  59938. getClassName(): string;
  59939. /**
  59940. * Gets the world position input component
  59941. */
  59942. get worldPosition(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the view input component
  59945. */
  59946. get view(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the color input component
  59949. */
  59950. get input(): NodeMaterialConnectionPoint;
  59951. /**
  59952. * Gets the fog color input component
  59953. */
  59954. get fogColor(): NodeMaterialConnectionPoint;
  59955. /**
  59956. * Gets the output component
  59957. */
  59958. get output(): NodeMaterialConnectionPoint;
  59959. autoConfigure(material: NodeMaterial): void;
  59960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59962. protected _buildBlock(state: NodeMaterialBuildState): this;
  59963. }
  59964. }
  59965. declare module BABYLON {
  59966. /**
  59967. * Block used to add light in the fragment shader
  59968. */
  59969. export class LightBlock extends NodeMaterialBlock {
  59970. private _lightId;
  59971. /**
  59972. * Gets or sets the light associated with this block
  59973. */
  59974. light: Nullable<Light>;
  59975. /**
  59976. * Create a new LightBlock
  59977. * @param name defines the block name
  59978. */
  59979. constructor(name: string);
  59980. /**
  59981. * Gets the current class name
  59982. * @returns the class name
  59983. */
  59984. getClassName(): string;
  59985. /**
  59986. * Gets the world position input component
  59987. */
  59988. get worldPosition(): NodeMaterialConnectionPoint;
  59989. /**
  59990. * Gets the world normal input component
  59991. */
  59992. get worldNormal(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the camera (or eye) position component
  59995. */
  59996. get cameraPosition(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the glossiness component
  59999. */
  60000. get glossiness(): NodeMaterialConnectionPoint;
  60001. /**
  60002. * Gets the glossinness power component
  60003. */
  60004. get glossPower(): NodeMaterialConnectionPoint;
  60005. /**
  60006. * Gets the diffuse color component
  60007. */
  60008. get diffuseColor(): NodeMaterialConnectionPoint;
  60009. /**
  60010. * Gets the specular color component
  60011. */
  60012. get specularColor(): NodeMaterialConnectionPoint;
  60013. /**
  60014. * Gets the diffuse output component
  60015. */
  60016. get diffuseOutput(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the specular output component
  60019. */
  60020. get specularOutput(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the shadow output component
  60023. */
  60024. get shadow(): NodeMaterialConnectionPoint;
  60025. autoConfigure(material: NodeMaterial): void;
  60026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60027. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60029. private _injectVertexCode;
  60030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60031. serialize(): any;
  60032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60033. }
  60034. }
  60035. declare module BABYLON {
  60036. /**
  60037. * Block used to read a reflection texture from a sampler
  60038. */
  60039. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60040. /**
  60041. * Create a new ReflectionTextureBlock
  60042. * @param name defines the block name
  60043. */
  60044. constructor(name: string);
  60045. /**
  60046. * Gets the current class name
  60047. * @returns the class name
  60048. */
  60049. getClassName(): string;
  60050. /**
  60051. * Gets the world position input component
  60052. */
  60053. get position(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the world position input component
  60056. */
  60057. get worldPosition(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the world normal input component
  60060. */
  60061. get worldNormal(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the world input component
  60064. */
  60065. get world(): NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the camera (or eye) position component
  60068. */
  60069. get cameraPosition(): NodeMaterialConnectionPoint;
  60070. /**
  60071. * Gets the view input component
  60072. */
  60073. get view(): NodeMaterialConnectionPoint;
  60074. /**
  60075. * Gets the rgb output component
  60076. */
  60077. get rgb(): NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the r output component
  60080. */
  60081. get r(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the g output component
  60084. */
  60085. get g(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the b output component
  60088. */
  60089. get b(): NodeMaterialConnectionPoint;
  60090. autoConfigure(material: NodeMaterial): void;
  60091. protected _buildBlock(state: NodeMaterialBuildState): this;
  60092. }
  60093. }
  60094. declare module BABYLON {
  60095. /**
  60096. * Block used to add 2 vectors
  60097. */
  60098. export class AddBlock extends NodeMaterialBlock {
  60099. /**
  60100. * Creates a new AddBlock
  60101. * @param name defines the block name
  60102. */
  60103. constructor(name: string);
  60104. /**
  60105. * Gets the current class name
  60106. * @returns the class name
  60107. */
  60108. getClassName(): string;
  60109. /**
  60110. * Gets the left operand input component
  60111. */
  60112. get left(): NodeMaterialConnectionPoint;
  60113. /**
  60114. * Gets the right operand input component
  60115. */
  60116. get right(): NodeMaterialConnectionPoint;
  60117. /**
  60118. * Gets the output component
  60119. */
  60120. get output(): NodeMaterialConnectionPoint;
  60121. protected _buildBlock(state: NodeMaterialBuildState): this;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /**
  60126. * Block used to scale a vector by a float
  60127. */
  60128. export class ScaleBlock extends NodeMaterialBlock {
  60129. /**
  60130. * Creates a new ScaleBlock
  60131. * @param name defines the block name
  60132. */
  60133. constructor(name: string);
  60134. /**
  60135. * Gets the current class name
  60136. * @returns the class name
  60137. */
  60138. getClassName(): string;
  60139. /**
  60140. * Gets the input component
  60141. */
  60142. get input(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the factor input component
  60145. */
  60146. get factor(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the output component
  60149. */
  60150. get output(): NodeMaterialConnectionPoint;
  60151. protected _buildBlock(state: NodeMaterialBuildState): this;
  60152. }
  60153. }
  60154. declare module BABYLON {
  60155. /**
  60156. * Block used to clamp a float
  60157. */
  60158. export class ClampBlock extends NodeMaterialBlock {
  60159. /** Gets or sets the minimum range */
  60160. minimum: number;
  60161. /** Gets or sets the maximum range */
  60162. maximum: number;
  60163. /**
  60164. * Creates a new ClampBlock
  60165. * @param name defines the block name
  60166. */
  60167. constructor(name: string);
  60168. /**
  60169. * Gets the current class name
  60170. * @returns the class name
  60171. */
  60172. getClassName(): string;
  60173. /**
  60174. * Gets the value input component
  60175. */
  60176. get value(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the output component
  60179. */
  60180. get output(): NodeMaterialConnectionPoint;
  60181. protected _buildBlock(state: NodeMaterialBuildState): this;
  60182. protected _dumpPropertiesCode(): string;
  60183. serialize(): any;
  60184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60185. }
  60186. }
  60187. declare module BABYLON {
  60188. /**
  60189. * Block used to apply a cross product between 2 vectors
  60190. */
  60191. export class CrossBlock extends NodeMaterialBlock {
  60192. /**
  60193. * Creates a new CrossBlock
  60194. * @param name defines the block name
  60195. */
  60196. constructor(name: string);
  60197. /**
  60198. * Gets the current class name
  60199. * @returns the class name
  60200. */
  60201. getClassName(): string;
  60202. /**
  60203. * Gets the left operand input component
  60204. */
  60205. get left(): NodeMaterialConnectionPoint;
  60206. /**
  60207. * Gets the right operand input component
  60208. */
  60209. get right(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the output component
  60212. */
  60213. get output(): NodeMaterialConnectionPoint;
  60214. protected _buildBlock(state: NodeMaterialBuildState): this;
  60215. }
  60216. }
  60217. declare module BABYLON {
  60218. /**
  60219. * Block used to apply a dot product between 2 vectors
  60220. */
  60221. export class DotBlock extends NodeMaterialBlock {
  60222. /**
  60223. * Creates a new DotBlock
  60224. * @param name defines the block name
  60225. */
  60226. constructor(name: string);
  60227. /**
  60228. * Gets the current class name
  60229. * @returns the class name
  60230. */
  60231. getClassName(): string;
  60232. /**
  60233. * Gets the left operand input component
  60234. */
  60235. get left(): NodeMaterialConnectionPoint;
  60236. /**
  60237. * Gets the right operand input component
  60238. */
  60239. get right(): NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the output component
  60242. */
  60243. get output(): NodeMaterialConnectionPoint;
  60244. protected _buildBlock(state: NodeMaterialBuildState): this;
  60245. }
  60246. }
  60247. declare module BABYLON {
  60248. /**
  60249. * Block used to normalize a vector
  60250. */
  60251. export class NormalizeBlock extends NodeMaterialBlock {
  60252. /**
  60253. * Creates a new NormalizeBlock
  60254. * @param name defines the block name
  60255. */
  60256. constructor(name: string);
  60257. /**
  60258. * Gets the current class name
  60259. * @returns the class name
  60260. */
  60261. getClassName(): string;
  60262. /**
  60263. * Gets the input component
  60264. */
  60265. get input(): NodeMaterialConnectionPoint;
  60266. /**
  60267. * Gets the output component
  60268. */
  60269. get output(): NodeMaterialConnectionPoint;
  60270. protected _buildBlock(state: NodeMaterialBuildState): this;
  60271. }
  60272. }
  60273. declare module BABYLON {
  60274. /**
  60275. * Operations supported by the Trigonometry block
  60276. */
  60277. export enum TrigonometryBlockOperations {
  60278. /** Cos */
  60279. Cos = 0,
  60280. /** Sin */
  60281. Sin = 1,
  60282. /** Abs */
  60283. Abs = 2,
  60284. /** Exp */
  60285. Exp = 3,
  60286. /** Exp2 */
  60287. Exp2 = 4,
  60288. /** Round */
  60289. Round = 5,
  60290. /** Floor */
  60291. Floor = 6,
  60292. /** Ceiling */
  60293. Ceiling = 7,
  60294. /** Square root */
  60295. Sqrt = 8,
  60296. /** Log */
  60297. Log = 9,
  60298. /** Tangent */
  60299. Tan = 10,
  60300. /** Arc tangent */
  60301. ArcTan = 11,
  60302. /** Arc cosinus */
  60303. ArcCos = 12,
  60304. /** Arc sinus */
  60305. ArcSin = 13,
  60306. /** Fraction */
  60307. Fract = 14,
  60308. /** Sign */
  60309. Sign = 15,
  60310. /** To radians (from degrees) */
  60311. Radians = 16,
  60312. /** To degrees (from radians) */
  60313. Degrees = 17
  60314. }
  60315. /**
  60316. * Block used to apply trigonometry operation to floats
  60317. */
  60318. export class TrigonometryBlock extends NodeMaterialBlock {
  60319. /**
  60320. * Gets or sets the operation applied by the block
  60321. */
  60322. operation: TrigonometryBlockOperations;
  60323. /**
  60324. * Creates a new TrigonometryBlock
  60325. * @param name defines the block name
  60326. */
  60327. constructor(name: string);
  60328. /**
  60329. * Gets the current class name
  60330. * @returns the class name
  60331. */
  60332. getClassName(): string;
  60333. /**
  60334. * Gets the input component
  60335. */
  60336. get input(): NodeMaterialConnectionPoint;
  60337. /**
  60338. * Gets the output component
  60339. */
  60340. get output(): NodeMaterialConnectionPoint;
  60341. protected _buildBlock(state: NodeMaterialBuildState): this;
  60342. serialize(): any;
  60343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60344. protected _dumpPropertiesCode(): string;
  60345. }
  60346. }
  60347. declare module BABYLON {
  60348. /**
  60349. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60350. */
  60351. export class ColorMergerBlock extends NodeMaterialBlock {
  60352. /**
  60353. * Create a new ColorMergerBlock
  60354. * @param name defines the block name
  60355. */
  60356. constructor(name: string);
  60357. /**
  60358. * Gets the current class name
  60359. * @returns the class name
  60360. */
  60361. getClassName(): string;
  60362. /**
  60363. * Gets the rgb component (input)
  60364. */
  60365. get rgbIn(): NodeMaterialConnectionPoint;
  60366. /**
  60367. * Gets the r component (input)
  60368. */
  60369. get r(): NodeMaterialConnectionPoint;
  60370. /**
  60371. * Gets the g component (input)
  60372. */
  60373. get g(): NodeMaterialConnectionPoint;
  60374. /**
  60375. * Gets the b component (input)
  60376. */
  60377. get b(): NodeMaterialConnectionPoint;
  60378. /**
  60379. * Gets the a component (input)
  60380. */
  60381. get a(): NodeMaterialConnectionPoint;
  60382. /**
  60383. * Gets the rgba component (output)
  60384. */
  60385. get rgba(): NodeMaterialConnectionPoint;
  60386. /**
  60387. * Gets the rgb component (output)
  60388. */
  60389. get rgbOut(): NodeMaterialConnectionPoint;
  60390. /**
  60391. * Gets the rgb component (output)
  60392. * @deprecated Please use rgbOut instead.
  60393. */
  60394. get rgb(): NodeMaterialConnectionPoint;
  60395. protected _buildBlock(state: NodeMaterialBuildState): this;
  60396. }
  60397. }
  60398. declare module BABYLON {
  60399. /**
  60400. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60401. */
  60402. export class ColorSplitterBlock extends NodeMaterialBlock {
  60403. /**
  60404. * Create a new ColorSplitterBlock
  60405. * @param name defines the block name
  60406. */
  60407. constructor(name: string);
  60408. /**
  60409. * Gets the current class name
  60410. * @returns the class name
  60411. */
  60412. getClassName(): string;
  60413. /**
  60414. * Gets the rgba component (input)
  60415. */
  60416. get rgba(): NodeMaterialConnectionPoint;
  60417. /**
  60418. * Gets the rgb component (input)
  60419. */
  60420. get rgbIn(): NodeMaterialConnectionPoint;
  60421. /**
  60422. * Gets the rgb component (output)
  60423. */
  60424. get rgbOut(): NodeMaterialConnectionPoint;
  60425. /**
  60426. * Gets the r component (output)
  60427. */
  60428. get r(): NodeMaterialConnectionPoint;
  60429. /**
  60430. * Gets the g component (output)
  60431. */
  60432. get g(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the b component (output)
  60435. */
  60436. get b(): NodeMaterialConnectionPoint;
  60437. /**
  60438. * Gets the a component (output)
  60439. */
  60440. get a(): NodeMaterialConnectionPoint;
  60441. protected _inputRename(name: string): string;
  60442. protected _outputRename(name: string): string;
  60443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60444. }
  60445. }
  60446. declare module BABYLON {
  60447. /**
  60448. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60449. */
  60450. export class VectorSplitterBlock extends NodeMaterialBlock {
  60451. /**
  60452. * Create a new VectorSplitterBlock
  60453. * @param name defines the block name
  60454. */
  60455. constructor(name: string);
  60456. /**
  60457. * Gets the current class name
  60458. * @returns the class name
  60459. */
  60460. getClassName(): string;
  60461. /**
  60462. * Gets the xyzw component (input)
  60463. */
  60464. get xyzw(): NodeMaterialConnectionPoint;
  60465. /**
  60466. * Gets the xyz component (input)
  60467. */
  60468. get xyzIn(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the xy component (input)
  60471. */
  60472. get xyIn(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the xyz component (output)
  60475. */
  60476. get xyzOut(): NodeMaterialConnectionPoint;
  60477. /**
  60478. * Gets the xy component (output)
  60479. */
  60480. get xyOut(): NodeMaterialConnectionPoint;
  60481. /**
  60482. * Gets the x component (output)
  60483. */
  60484. get x(): NodeMaterialConnectionPoint;
  60485. /**
  60486. * Gets the y component (output)
  60487. */
  60488. get y(): NodeMaterialConnectionPoint;
  60489. /**
  60490. * Gets the z component (output)
  60491. */
  60492. get z(): NodeMaterialConnectionPoint;
  60493. /**
  60494. * Gets the w component (output)
  60495. */
  60496. get w(): NodeMaterialConnectionPoint;
  60497. protected _inputRename(name: string): string;
  60498. protected _outputRename(name: string): string;
  60499. protected _buildBlock(state: NodeMaterialBuildState): this;
  60500. }
  60501. }
  60502. declare module BABYLON {
  60503. /**
  60504. * Block used to lerp between 2 values
  60505. */
  60506. export class LerpBlock extends NodeMaterialBlock {
  60507. /**
  60508. * Creates a new LerpBlock
  60509. * @param name defines the block name
  60510. */
  60511. constructor(name: string);
  60512. /**
  60513. * Gets the current class name
  60514. * @returns the class name
  60515. */
  60516. getClassName(): string;
  60517. /**
  60518. * Gets the left operand input component
  60519. */
  60520. get left(): NodeMaterialConnectionPoint;
  60521. /**
  60522. * Gets the right operand input component
  60523. */
  60524. get right(): NodeMaterialConnectionPoint;
  60525. /**
  60526. * Gets the gradient operand input component
  60527. */
  60528. get gradient(): NodeMaterialConnectionPoint;
  60529. /**
  60530. * Gets the output component
  60531. */
  60532. get output(): NodeMaterialConnectionPoint;
  60533. protected _buildBlock(state: NodeMaterialBuildState): this;
  60534. }
  60535. }
  60536. declare module BABYLON {
  60537. /**
  60538. * Block used to divide 2 vectors
  60539. */
  60540. export class DivideBlock extends NodeMaterialBlock {
  60541. /**
  60542. * Creates a new DivideBlock
  60543. * @param name defines the block name
  60544. */
  60545. constructor(name: string);
  60546. /**
  60547. * Gets the current class name
  60548. * @returns the class name
  60549. */
  60550. getClassName(): string;
  60551. /**
  60552. * Gets the left operand input component
  60553. */
  60554. get left(): NodeMaterialConnectionPoint;
  60555. /**
  60556. * Gets the right operand input component
  60557. */
  60558. get right(): NodeMaterialConnectionPoint;
  60559. /**
  60560. * Gets the output component
  60561. */
  60562. get output(): NodeMaterialConnectionPoint;
  60563. protected _buildBlock(state: NodeMaterialBuildState): this;
  60564. }
  60565. }
  60566. declare module BABYLON {
  60567. /**
  60568. * Block used to subtract 2 vectors
  60569. */
  60570. export class SubtractBlock extends NodeMaterialBlock {
  60571. /**
  60572. * Creates a new SubtractBlock
  60573. * @param name defines the block name
  60574. */
  60575. constructor(name: string);
  60576. /**
  60577. * Gets the current class name
  60578. * @returns the class name
  60579. */
  60580. getClassName(): string;
  60581. /**
  60582. * Gets the left operand input component
  60583. */
  60584. get left(): NodeMaterialConnectionPoint;
  60585. /**
  60586. * Gets the right operand input component
  60587. */
  60588. get right(): NodeMaterialConnectionPoint;
  60589. /**
  60590. * Gets the output component
  60591. */
  60592. get output(): NodeMaterialConnectionPoint;
  60593. protected _buildBlock(state: NodeMaterialBuildState): this;
  60594. }
  60595. }
  60596. declare module BABYLON {
  60597. /**
  60598. * Block used to step a value
  60599. */
  60600. export class StepBlock extends NodeMaterialBlock {
  60601. /**
  60602. * Creates a new StepBlock
  60603. * @param name defines the block name
  60604. */
  60605. constructor(name: string);
  60606. /**
  60607. * Gets the current class name
  60608. * @returns the class name
  60609. */
  60610. getClassName(): string;
  60611. /**
  60612. * Gets the value operand input component
  60613. */
  60614. get value(): NodeMaterialConnectionPoint;
  60615. /**
  60616. * Gets the edge operand input component
  60617. */
  60618. get edge(): NodeMaterialConnectionPoint;
  60619. /**
  60620. * Gets the output component
  60621. */
  60622. get output(): NodeMaterialConnectionPoint;
  60623. protected _buildBlock(state: NodeMaterialBuildState): this;
  60624. }
  60625. }
  60626. declare module BABYLON {
  60627. /**
  60628. * Block used to get the opposite (1 - x) of a value
  60629. */
  60630. export class OneMinusBlock extends NodeMaterialBlock {
  60631. /**
  60632. * Creates a new OneMinusBlock
  60633. * @param name defines the block name
  60634. */
  60635. constructor(name: string);
  60636. /**
  60637. * Gets the current class name
  60638. * @returns the class name
  60639. */
  60640. getClassName(): string;
  60641. /**
  60642. * Gets the input component
  60643. */
  60644. get input(): NodeMaterialConnectionPoint;
  60645. /**
  60646. * Gets the output component
  60647. */
  60648. get output(): NodeMaterialConnectionPoint;
  60649. protected _buildBlock(state: NodeMaterialBuildState): this;
  60650. }
  60651. }
  60652. declare module BABYLON {
  60653. /**
  60654. * Block used to get the view direction
  60655. */
  60656. export class ViewDirectionBlock extends NodeMaterialBlock {
  60657. /**
  60658. * Creates a new ViewDirectionBlock
  60659. * @param name defines the block name
  60660. */
  60661. constructor(name: string);
  60662. /**
  60663. * Gets the current class name
  60664. * @returns the class name
  60665. */
  60666. getClassName(): string;
  60667. /**
  60668. * Gets the world position component
  60669. */
  60670. get worldPosition(): NodeMaterialConnectionPoint;
  60671. /**
  60672. * Gets the camera position component
  60673. */
  60674. get cameraPosition(): NodeMaterialConnectionPoint;
  60675. /**
  60676. * Gets the output component
  60677. */
  60678. get output(): NodeMaterialConnectionPoint;
  60679. autoConfigure(material: NodeMaterial): void;
  60680. protected _buildBlock(state: NodeMaterialBuildState): this;
  60681. }
  60682. }
  60683. declare module BABYLON {
  60684. /**
  60685. * Block used to compute fresnel value
  60686. */
  60687. export class FresnelBlock extends NodeMaterialBlock {
  60688. /**
  60689. * Create a new FresnelBlock
  60690. * @param name defines the block name
  60691. */
  60692. constructor(name: string);
  60693. /**
  60694. * Gets the current class name
  60695. * @returns the class name
  60696. */
  60697. getClassName(): string;
  60698. /**
  60699. * Gets the world normal input component
  60700. */
  60701. get worldNormal(): NodeMaterialConnectionPoint;
  60702. /**
  60703. * Gets the view direction input component
  60704. */
  60705. get viewDirection(): NodeMaterialConnectionPoint;
  60706. /**
  60707. * Gets the bias input component
  60708. */
  60709. get bias(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the camera (or eye) position component
  60712. */
  60713. get power(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the fresnel output component
  60716. */
  60717. get fresnel(): NodeMaterialConnectionPoint;
  60718. autoConfigure(material: NodeMaterial): void;
  60719. protected _buildBlock(state: NodeMaterialBuildState): this;
  60720. }
  60721. }
  60722. declare module BABYLON {
  60723. /**
  60724. * Block used to get the max of 2 values
  60725. */
  60726. export class MaxBlock extends NodeMaterialBlock {
  60727. /**
  60728. * Creates a new MaxBlock
  60729. * @param name defines the block name
  60730. */
  60731. constructor(name: string);
  60732. /**
  60733. * Gets the current class name
  60734. * @returns the class name
  60735. */
  60736. getClassName(): string;
  60737. /**
  60738. * Gets the left operand input component
  60739. */
  60740. get left(): NodeMaterialConnectionPoint;
  60741. /**
  60742. * Gets the right operand input component
  60743. */
  60744. get right(): NodeMaterialConnectionPoint;
  60745. /**
  60746. * Gets the output component
  60747. */
  60748. get output(): NodeMaterialConnectionPoint;
  60749. protected _buildBlock(state: NodeMaterialBuildState): this;
  60750. }
  60751. }
  60752. declare module BABYLON {
  60753. /**
  60754. * Block used to get the min of 2 values
  60755. */
  60756. export class MinBlock extends NodeMaterialBlock {
  60757. /**
  60758. * Creates a new MinBlock
  60759. * @param name defines the block name
  60760. */
  60761. constructor(name: string);
  60762. /**
  60763. * Gets the current class name
  60764. * @returns the class name
  60765. */
  60766. getClassName(): string;
  60767. /**
  60768. * Gets the left operand input component
  60769. */
  60770. get left(): NodeMaterialConnectionPoint;
  60771. /**
  60772. * Gets the right operand input component
  60773. */
  60774. get right(): NodeMaterialConnectionPoint;
  60775. /**
  60776. * Gets the output component
  60777. */
  60778. get output(): NodeMaterialConnectionPoint;
  60779. protected _buildBlock(state: NodeMaterialBuildState): this;
  60780. }
  60781. }
  60782. declare module BABYLON {
  60783. /**
  60784. * Block used to get the distance between 2 values
  60785. */
  60786. export class DistanceBlock extends NodeMaterialBlock {
  60787. /**
  60788. * Creates a new DistanceBlock
  60789. * @param name defines the block name
  60790. */
  60791. constructor(name: string);
  60792. /**
  60793. * Gets the current class name
  60794. * @returns the class name
  60795. */
  60796. getClassName(): string;
  60797. /**
  60798. * Gets the left operand input component
  60799. */
  60800. get left(): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Gets the right operand input component
  60803. */
  60804. get right(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the output component
  60807. */
  60808. get output(): NodeMaterialConnectionPoint;
  60809. protected _buildBlock(state: NodeMaterialBuildState): this;
  60810. }
  60811. }
  60812. declare module BABYLON {
  60813. /**
  60814. * Block used to get the length of a vector
  60815. */
  60816. export class LengthBlock extends NodeMaterialBlock {
  60817. /**
  60818. * Creates a new LengthBlock
  60819. * @param name defines the block name
  60820. */
  60821. constructor(name: string);
  60822. /**
  60823. * Gets the current class name
  60824. * @returns the class name
  60825. */
  60826. getClassName(): string;
  60827. /**
  60828. * Gets the value input component
  60829. */
  60830. get value(): NodeMaterialConnectionPoint;
  60831. /**
  60832. * Gets the output component
  60833. */
  60834. get output(): NodeMaterialConnectionPoint;
  60835. protected _buildBlock(state: NodeMaterialBuildState): this;
  60836. }
  60837. }
  60838. declare module BABYLON {
  60839. /**
  60840. * Block used to get negative version of a value (i.e. x * -1)
  60841. */
  60842. export class NegateBlock extends NodeMaterialBlock {
  60843. /**
  60844. * Creates a new NegateBlock
  60845. * @param name defines the block name
  60846. */
  60847. constructor(name: string);
  60848. /**
  60849. * Gets the current class name
  60850. * @returns the class name
  60851. */
  60852. getClassName(): string;
  60853. /**
  60854. * Gets the value input component
  60855. */
  60856. get value(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the output component
  60859. */
  60860. get output(): NodeMaterialConnectionPoint;
  60861. protected _buildBlock(state: NodeMaterialBuildState): this;
  60862. }
  60863. }
  60864. declare module BABYLON {
  60865. /**
  60866. * Block used to get the value of the first parameter raised to the power of the second
  60867. */
  60868. export class PowBlock extends NodeMaterialBlock {
  60869. /**
  60870. * Creates a new PowBlock
  60871. * @param name defines the block name
  60872. */
  60873. constructor(name: string);
  60874. /**
  60875. * Gets the current class name
  60876. * @returns the class name
  60877. */
  60878. getClassName(): string;
  60879. /**
  60880. * Gets the value operand input component
  60881. */
  60882. get value(): NodeMaterialConnectionPoint;
  60883. /**
  60884. * Gets the power operand input component
  60885. */
  60886. get power(): NodeMaterialConnectionPoint;
  60887. /**
  60888. * Gets the output component
  60889. */
  60890. get output(): NodeMaterialConnectionPoint;
  60891. protected _buildBlock(state: NodeMaterialBuildState): this;
  60892. }
  60893. }
  60894. declare module BABYLON {
  60895. /**
  60896. * Block used to get a random number
  60897. */
  60898. export class RandomNumberBlock extends NodeMaterialBlock {
  60899. /**
  60900. * Creates a new RandomNumberBlock
  60901. * @param name defines the block name
  60902. */
  60903. constructor(name: string);
  60904. /**
  60905. * Gets the current class name
  60906. * @returns the class name
  60907. */
  60908. getClassName(): string;
  60909. /**
  60910. * Gets the seed input component
  60911. */
  60912. get seed(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the output component
  60915. */
  60916. get output(): NodeMaterialConnectionPoint;
  60917. protected _buildBlock(state: NodeMaterialBuildState): this;
  60918. }
  60919. }
  60920. declare module BABYLON {
  60921. /**
  60922. * Block used to compute arc tangent of 2 values
  60923. */
  60924. export class ArcTan2Block extends NodeMaterialBlock {
  60925. /**
  60926. * Creates a new ArcTan2Block
  60927. * @param name defines the block name
  60928. */
  60929. constructor(name: string);
  60930. /**
  60931. * Gets the current class name
  60932. * @returns the class name
  60933. */
  60934. getClassName(): string;
  60935. /**
  60936. * Gets the x operand input component
  60937. */
  60938. get x(): NodeMaterialConnectionPoint;
  60939. /**
  60940. * Gets the y operand input component
  60941. */
  60942. get y(): NodeMaterialConnectionPoint;
  60943. /**
  60944. * Gets the output component
  60945. */
  60946. get output(): NodeMaterialConnectionPoint;
  60947. protected _buildBlock(state: NodeMaterialBuildState): this;
  60948. }
  60949. }
  60950. declare module BABYLON {
  60951. /**
  60952. * Block used to smooth step a value
  60953. */
  60954. export class SmoothStepBlock extends NodeMaterialBlock {
  60955. /**
  60956. * Creates a new SmoothStepBlock
  60957. * @param name defines the block name
  60958. */
  60959. constructor(name: string);
  60960. /**
  60961. * Gets the current class name
  60962. * @returns the class name
  60963. */
  60964. getClassName(): string;
  60965. /**
  60966. * Gets the value operand input component
  60967. */
  60968. get value(): NodeMaterialConnectionPoint;
  60969. /**
  60970. * Gets the first edge operand input component
  60971. */
  60972. get edge0(): NodeMaterialConnectionPoint;
  60973. /**
  60974. * Gets the second edge operand input component
  60975. */
  60976. get edge1(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the output component
  60979. */
  60980. get output(): NodeMaterialConnectionPoint;
  60981. protected _buildBlock(state: NodeMaterialBuildState): this;
  60982. }
  60983. }
  60984. declare module BABYLON {
  60985. /**
  60986. * Block used to get the reciprocal (1 / x) of a value
  60987. */
  60988. export class ReciprocalBlock extends NodeMaterialBlock {
  60989. /**
  60990. * Creates a new ReciprocalBlock
  60991. * @param name defines the block name
  60992. */
  60993. constructor(name: string);
  60994. /**
  60995. * Gets the current class name
  60996. * @returns the class name
  60997. */
  60998. getClassName(): string;
  60999. /**
  61000. * Gets the input component
  61001. */
  61002. get input(): NodeMaterialConnectionPoint;
  61003. /**
  61004. * Gets the output component
  61005. */
  61006. get output(): NodeMaterialConnectionPoint;
  61007. protected _buildBlock(state: NodeMaterialBuildState): this;
  61008. }
  61009. }
  61010. declare module BABYLON {
  61011. /**
  61012. * Block used to replace a color by another one
  61013. */
  61014. export class ReplaceColorBlock extends NodeMaterialBlock {
  61015. /**
  61016. * Creates a new ReplaceColorBlock
  61017. * @param name defines the block name
  61018. */
  61019. constructor(name: string);
  61020. /**
  61021. * Gets the current class name
  61022. * @returns the class name
  61023. */
  61024. getClassName(): string;
  61025. /**
  61026. * Gets the value input component
  61027. */
  61028. get value(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the reference input component
  61031. */
  61032. get reference(): NodeMaterialConnectionPoint;
  61033. /**
  61034. * Gets the distance input component
  61035. */
  61036. get distance(): NodeMaterialConnectionPoint;
  61037. /**
  61038. * Gets the replacement input component
  61039. */
  61040. get replacement(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the output component
  61043. */
  61044. get output(): NodeMaterialConnectionPoint;
  61045. protected _buildBlock(state: NodeMaterialBuildState): this;
  61046. }
  61047. }
  61048. declare module BABYLON {
  61049. /**
  61050. * Block used to posterize a value
  61051. * @see https://en.wikipedia.org/wiki/Posterization
  61052. */
  61053. export class PosterizeBlock extends NodeMaterialBlock {
  61054. /**
  61055. * Creates a new PosterizeBlock
  61056. * @param name defines the block name
  61057. */
  61058. constructor(name: string);
  61059. /**
  61060. * Gets the current class name
  61061. * @returns the class name
  61062. */
  61063. getClassName(): string;
  61064. /**
  61065. * Gets the value input component
  61066. */
  61067. get value(): NodeMaterialConnectionPoint;
  61068. /**
  61069. * Gets the steps input component
  61070. */
  61071. get steps(): NodeMaterialConnectionPoint;
  61072. /**
  61073. * Gets the output component
  61074. */
  61075. get output(): NodeMaterialConnectionPoint;
  61076. protected _buildBlock(state: NodeMaterialBuildState): this;
  61077. }
  61078. }
  61079. declare module BABYLON {
  61080. /**
  61081. * Operations supported by the Wave block
  61082. */
  61083. export enum WaveBlockKind {
  61084. /** SawTooth */
  61085. SawTooth = 0,
  61086. /** Square */
  61087. Square = 1,
  61088. /** Triangle */
  61089. Triangle = 2
  61090. }
  61091. /**
  61092. * Block used to apply wave operation to floats
  61093. */
  61094. export class WaveBlock extends NodeMaterialBlock {
  61095. /**
  61096. * Gets or sets the kibnd of wave to be applied by the block
  61097. */
  61098. kind: WaveBlockKind;
  61099. /**
  61100. * Creates a new WaveBlock
  61101. * @param name defines the block name
  61102. */
  61103. constructor(name: string);
  61104. /**
  61105. * Gets the current class name
  61106. * @returns the class name
  61107. */
  61108. getClassName(): string;
  61109. /**
  61110. * Gets the input component
  61111. */
  61112. get input(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the output component
  61115. */
  61116. get output(): NodeMaterialConnectionPoint;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. serialize(): any;
  61119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Class used to store a color step for the GradientBlock
  61125. */
  61126. export class GradientBlockColorStep {
  61127. /**
  61128. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61129. */
  61130. step: number;
  61131. /**
  61132. * Gets or sets the color associated with this step
  61133. */
  61134. color: Color3;
  61135. /**
  61136. * Creates a new GradientBlockColorStep
  61137. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61138. * @param color defines the color associated with this step
  61139. */
  61140. constructor(
  61141. /**
  61142. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61143. */
  61144. step: number,
  61145. /**
  61146. * Gets or sets the color associated with this step
  61147. */
  61148. color: Color3);
  61149. }
  61150. /**
  61151. * Block used to return a color from a gradient based on an input value between 0 and 1
  61152. */
  61153. export class GradientBlock extends NodeMaterialBlock {
  61154. /**
  61155. * Gets or sets the list of color steps
  61156. */
  61157. colorSteps: GradientBlockColorStep[];
  61158. /**
  61159. * Creates a new GradientBlock
  61160. * @param name defines the block name
  61161. */
  61162. constructor(name: string);
  61163. /**
  61164. * Gets the current class name
  61165. * @returns the class name
  61166. */
  61167. getClassName(): string;
  61168. /**
  61169. * Gets the gradient input component
  61170. */
  61171. get gradient(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Gets the output component
  61174. */
  61175. get output(): NodeMaterialConnectionPoint;
  61176. private _writeColorConstant;
  61177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61178. serialize(): any;
  61179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61180. protected _dumpPropertiesCode(): string;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * Block used to normalize lerp between 2 values
  61186. */
  61187. export class NLerpBlock extends NodeMaterialBlock {
  61188. /**
  61189. * Creates a new NLerpBlock
  61190. * @param name defines the block name
  61191. */
  61192. constructor(name: string);
  61193. /**
  61194. * Gets the current class name
  61195. * @returns the class name
  61196. */
  61197. getClassName(): string;
  61198. /**
  61199. * Gets the left operand input component
  61200. */
  61201. get left(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the right operand input component
  61204. */
  61205. get right(): NodeMaterialConnectionPoint;
  61206. /**
  61207. * Gets the gradient operand input component
  61208. */
  61209. get gradient(): NodeMaterialConnectionPoint;
  61210. /**
  61211. * Gets the output component
  61212. */
  61213. get output(): NodeMaterialConnectionPoint;
  61214. protected _buildBlock(state: NodeMaterialBuildState): this;
  61215. }
  61216. }
  61217. declare module BABYLON {
  61218. /**
  61219. * block used to Generate a Worley Noise 3D Noise Pattern
  61220. */
  61221. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61222. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61223. manhattanDistance: boolean;
  61224. /**
  61225. * Creates a new WorleyNoise3DBlock
  61226. * @param name defines the block name
  61227. */
  61228. constructor(name: string);
  61229. /**
  61230. * Gets the current class name
  61231. * @returns the class name
  61232. */
  61233. getClassName(): string;
  61234. /**
  61235. * Gets the seed input component
  61236. */
  61237. get seed(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the jitter input component
  61240. */
  61241. get jitter(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the output component
  61244. */
  61245. get output(): NodeMaterialConnectionPoint;
  61246. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61247. /**
  61248. * Exposes the properties to the UI?
  61249. */
  61250. protected _dumpPropertiesCode(): string;
  61251. /**
  61252. * Exposes the properties to the Seralize?
  61253. */
  61254. serialize(): any;
  61255. /**
  61256. * Exposes the properties to the deseralize?
  61257. */
  61258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61259. }
  61260. }
  61261. declare module BABYLON {
  61262. /**
  61263. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61264. */
  61265. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61266. /**
  61267. * Creates a new SimplexPerlin3DBlock
  61268. * @param name defines the block name
  61269. */
  61270. constructor(name: string);
  61271. /**
  61272. * Gets the current class name
  61273. * @returns the class name
  61274. */
  61275. getClassName(): string;
  61276. /**
  61277. * Gets the seed operand input component
  61278. */
  61279. get seed(): NodeMaterialConnectionPoint;
  61280. /**
  61281. * Gets the output component
  61282. */
  61283. get output(): NodeMaterialConnectionPoint;
  61284. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61285. }
  61286. }
  61287. declare module BABYLON {
  61288. /**
  61289. * Block used to blend normals
  61290. */
  61291. export class NormalBlendBlock extends NodeMaterialBlock {
  61292. /**
  61293. * Creates a new NormalBlendBlock
  61294. * @param name defines the block name
  61295. */
  61296. constructor(name: string);
  61297. /**
  61298. * Gets the current class name
  61299. * @returns the class name
  61300. */
  61301. getClassName(): string;
  61302. /**
  61303. * Gets the first input component
  61304. */
  61305. get normalMap0(): NodeMaterialConnectionPoint;
  61306. /**
  61307. * Gets the second input component
  61308. */
  61309. get normalMap1(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the output component
  61312. */
  61313. get output(): NodeMaterialConnectionPoint;
  61314. protected _buildBlock(state: NodeMaterialBuildState): this;
  61315. }
  61316. }
  61317. declare module BABYLON {
  61318. /**
  61319. * Block used to rotate a 2d vector by a given angle
  61320. */
  61321. export class Rotate2dBlock extends NodeMaterialBlock {
  61322. /**
  61323. * Creates a new Rotate2dBlock
  61324. * @param name defines the block name
  61325. */
  61326. constructor(name: string);
  61327. /**
  61328. * Gets the current class name
  61329. * @returns the class name
  61330. */
  61331. getClassName(): string;
  61332. /**
  61333. * Gets the input vector
  61334. */
  61335. get input(): NodeMaterialConnectionPoint;
  61336. /**
  61337. * Gets the input angle
  61338. */
  61339. get angle(): NodeMaterialConnectionPoint;
  61340. /**
  61341. * Gets the output component
  61342. */
  61343. get output(): NodeMaterialConnectionPoint;
  61344. autoConfigure(material: NodeMaterial): void;
  61345. protected _buildBlock(state: NodeMaterialBuildState): this;
  61346. }
  61347. }
  61348. declare module BABYLON {
  61349. /**
  61350. * Block used to get the reflected vector from a direction and a normal
  61351. */
  61352. export class ReflectBlock extends NodeMaterialBlock {
  61353. /**
  61354. * Creates a new ReflectBlock
  61355. * @param name defines the block name
  61356. */
  61357. constructor(name: string);
  61358. /**
  61359. * Gets the current class name
  61360. * @returns the class name
  61361. */
  61362. getClassName(): string;
  61363. /**
  61364. * Gets the incident component
  61365. */
  61366. get incident(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the normal component
  61369. */
  61370. get normal(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the output component
  61373. */
  61374. get output(): NodeMaterialConnectionPoint;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Block used to get the refracted vector from a direction and a normal
  61381. */
  61382. export class RefractBlock extends NodeMaterialBlock {
  61383. /**
  61384. * Creates a new RefractBlock
  61385. * @param name defines the block name
  61386. */
  61387. constructor(name: string);
  61388. /**
  61389. * Gets the current class name
  61390. * @returns the class name
  61391. */
  61392. getClassName(): string;
  61393. /**
  61394. * Gets the incident component
  61395. */
  61396. get incident(): NodeMaterialConnectionPoint;
  61397. /**
  61398. * Gets the normal component
  61399. */
  61400. get normal(): NodeMaterialConnectionPoint;
  61401. /**
  61402. * Gets the index of refraction component
  61403. */
  61404. get ior(): NodeMaterialConnectionPoint;
  61405. /**
  61406. * Gets the output component
  61407. */
  61408. get output(): NodeMaterialConnectionPoint;
  61409. protected _buildBlock(state: NodeMaterialBuildState): this;
  61410. }
  61411. }
  61412. declare module BABYLON {
  61413. /**
  61414. * Block used to desaturate a color
  61415. */
  61416. export class DesaturateBlock extends NodeMaterialBlock {
  61417. /**
  61418. * Creates a new DesaturateBlock
  61419. * @param name defines the block name
  61420. */
  61421. constructor(name: string);
  61422. /**
  61423. * Gets the current class name
  61424. * @returns the class name
  61425. */
  61426. getClassName(): string;
  61427. /**
  61428. * Gets the color operand input component
  61429. */
  61430. get color(): NodeMaterialConnectionPoint;
  61431. /**
  61432. * Gets the level operand input component
  61433. */
  61434. get level(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the output component
  61437. */
  61438. get output(): NodeMaterialConnectionPoint;
  61439. protected _buildBlock(state: NodeMaterialBuildState): this;
  61440. }
  61441. }
  61442. declare module BABYLON {
  61443. /**
  61444. * Block used to implement the ambient occlusion module of the PBR material
  61445. */
  61446. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  61447. /**
  61448. * Create a new AmbientOcclusionBlock
  61449. * @param name defines the block name
  61450. */
  61451. constructor(name: string);
  61452. /**
  61453. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  61454. */
  61455. useAmbientInGrayScale: boolean;
  61456. /**
  61457. * Initialize the block and prepare the context for build
  61458. * @param state defines the state that will be used for the build
  61459. */
  61460. initialize(state: NodeMaterialBuildState): void;
  61461. /**
  61462. * Gets the current class name
  61463. * @returns the class name
  61464. */
  61465. getClassName(): string;
  61466. /**
  61467. * Gets the texture input component
  61468. */
  61469. get texture(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the texture intensity component
  61472. */
  61473. get intensity(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the direct light intensity input component
  61476. */
  61477. get directLightIntensity(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the ambient occlusion object output component
  61480. */
  61481. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the main code of the block (fragment side)
  61484. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  61485. * @returns the shader code
  61486. */
  61487. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  61488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61489. protected _buildBlock(state: NodeMaterialBuildState): this;
  61490. protected _dumpPropertiesCode(): string;
  61491. serialize(): any;
  61492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61493. }
  61494. }
  61495. declare module BABYLON {
  61496. /**
  61497. * Block used to implement the reflection module of the PBR material
  61498. */
  61499. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  61500. /** @hidden */
  61501. _defineLODReflectionAlpha: string;
  61502. /** @hidden */
  61503. _defineLinearSpecularReflection: string;
  61504. private _vEnvironmentIrradianceName;
  61505. /** @hidden */
  61506. _vReflectionMicrosurfaceInfosName: string;
  61507. /** @hidden */
  61508. _vReflectionInfosName: string;
  61509. private _scene;
  61510. /**
  61511. * The three properties below are set by the main PBR block prior to calling methods of this class.
  61512. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61513. * It's less burden on the user side in the editor part.
  61514. */
  61515. /** @hidden */
  61516. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61517. /** @hidden */
  61518. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61519. /** @hidden */
  61520. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  61521. /**
  61522. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  61523. * diffuse part of the IBL.
  61524. */
  61525. useSphericalHarmonics: boolean;
  61526. /**
  61527. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61528. */
  61529. forceIrradianceInFragment: boolean;
  61530. /**
  61531. * Create a new ReflectionBlock
  61532. * @param name defines the block name
  61533. */
  61534. constructor(name: string);
  61535. /**
  61536. * Gets the current class name
  61537. * @returns the class name
  61538. */
  61539. getClassName(): string;
  61540. /**
  61541. * Gets the position input component
  61542. */
  61543. get position(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the world position input component
  61546. */
  61547. get worldPosition(): NodeMaterialConnectionPoint;
  61548. /**
  61549. * Gets the world normal input component
  61550. */
  61551. get worldNormal(): NodeMaterialConnectionPoint;
  61552. /**
  61553. * Gets the world input component
  61554. */
  61555. get world(): NodeMaterialConnectionPoint;
  61556. /**
  61557. * Gets the camera (or eye) position component
  61558. */
  61559. get cameraPosition(): NodeMaterialConnectionPoint;
  61560. /**
  61561. * Gets the view input component
  61562. */
  61563. get view(): NodeMaterialConnectionPoint;
  61564. /**
  61565. * Gets the color input component
  61566. */
  61567. get color(): NodeMaterialConnectionPoint;
  61568. /**
  61569. * Gets the reflection object output component
  61570. */
  61571. get reflection(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  61574. */
  61575. get hasTexture(): boolean;
  61576. /**
  61577. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  61578. */
  61579. get reflectionColor(): string;
  61580. protected _getTexture(): Nullable<BaseTexture>;
  61581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61583. /**
  61584. * Gets the code to inject in the vertex shader
  61585. * @param state current state of the node material building
  61586. * @returns the shader code
  61587. */
  61588. handleVertexSide(state: NodeMaterialBuildState): string;
  61589. /**
  61590. * Gets the main code of the block (fragment side)
  61591. * @param state current state of the node material building
  61592. * @param normalVarName name of the existing variable corresponding to the normal
  61593. * @returns the shader code
  61594. */
  61595. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  61596. protected _buildBlock(state: NodeMaterialBuildState): this;
  61597. protected _dumpPropertiesCode(): string;
  61598. serialize(): any;
  61599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61600. }
  61601. }
  61602. declare module BABYLON {
  61603. /**
  61604. * Block used to implement the sheen module of the PBR material
  61605. */
  61606. export class SheenBlock extends NodeMaterialBlock {
  61607. /**
  61608. * Create a new SheenBlock
  61609. * @param name defines the block name
  61610. */
  61611. constructor(name: string);
  61612. /**
  61613. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  61614. * It allows the strength of the sheen effect to not depend on the base color of the material,
  61615. * making it easier to setup and tweak the effect
  61616. */
  61617. albedoScaling: boolean;
  61618. /**
  61619. * Defines if the sheen is linked to the sheen color.
  61620. */
  61621. linkSheenWithAlbedo: boolean;
  61622. /**
  61623. * Initialize the block and prepare the context for build
  61624. * @param state defines the state that will be used for the build
  61625. */
  61626. initialize(state: NodeMaterialBuildState): void;
  61627. /**
  61628. * Gets the current class name
  61629. * @returns the class name
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Gets the intensity input component
  61634. */
  61635. get intensity(): NodeMaterialConnectionPoint;
  61636. /**
  61637. * Gets the color input component
  61638. */
  61639. get color(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the roughness input component
  61642. */
  61643. get roughness(): NodeMaterialConnectionPoint;
  61644. /**
  61645. * Gets the texture input component
  61646. */
  61647. get texture(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the sheen object output component
  61650. */
  61651. get sheen(): NodeMaterialConnectionPoint;
  61652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61653. /**
  61654. * Gets the main code of the block (fragment side)
  61655. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61656. * @returns the shader code
  61657. */
  61658. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  61659. protected _buildBlock(state: NodeMaterialBuildState): this;
  61660. protected _dumpPropertiesCode(): string;
  61661. serialize(): any;
  61662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61663. }
  61664. }
  61665. declare module BABYLON {
  61666. /**
  61667. * Block used to implement the reflectivity module of the PBR material
  61668. */
  61669. export class ReflectivityBlock extends NodeMaterialBlock {
  61670. /**
  61671. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  61672. */
  61673. useAmbientOcclusionFromMetallicTextureRed: boolean;
  61674. /**
  61675. * Specifies if the metallic texture contains the metallness information in its blue channel.
  61676. */
  61677. useMetallnessFromMetallicTextureBlue: boolean;
  61678. /**
  61679. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  61680. */
  61681. useRoughnessFromMetallicTextureAlpha: boolean;
  61682. /**
  61683. * Specifies if the metallic texture contains the roughness information in its green channel.
  61684. */
  61685. useRoughnessFromMetallicTextureGreen: boolean;
  61686. /**
  61687. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  61688. */
  61689. useMetallicF0FactorFromMetallicTexture: boolean;
  61690. /**
  61691. * Create a new ReflectivityBlock
  61692. * @param name defines the block name
  61693. */
  61694. constructor(name: string);
  61695. /**
  61696. * Initialize the block and prepare the context for build
  61697. * @param state defines the state that will be used for the build
  61698. */
  61699. initialize(state: NodeMaterialBuildState): void;
  61700. /**
  61701. * Gets the current class name
  61702. * @returns the class name
  61703. */
  61704. getClassName(): string;
  61705. /**
  61706. * Gets the metallic input component
  61707. */
  61708. get metallic(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the roughness input component
  61711. */
  61712. get roughness(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the texture input component
  61715. */
  61716. get texture(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the reflectivity object output component
  61719. */
  61720. get reflectivity(): NodeMaterialConnectionPoint;
  61721. /**
  61722. * Gets the main code of the block (fragment side)
  61723. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  61724. * @returns the shader code
  61725. */
  61726. getCode(aoIntensityVarName: string): string;
  61727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61728. protected _buildBlock(state: NodeMaterialBuildState): this;
  61729. protected _dumpPropertiesCode(): string;
  61730. serialize(): any;
  61731. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61732. }
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Block used to implement the anisotropy module of the PBR material
  61737. */
  61738. export class AnisotropyBlock extends NodeMaterialBlock {
  61739. /**
  61740. * The two properties below are set by the main PBR block prior to calling methods of this class.
  61741. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61742. * It's less burden on the user side in the editor part.
  61743. */
  61744. /** @hidden */
  61745. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61746. /** @hidden */
  61747. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61748. /**
  61749. * Create a new AnisotropyBlock
  61750. * @param name defines the block name
  61751. */
  61752. constructor(name: string);
  61753. /**
  61754. * Initialize the block and prepare the context for build
  61755. * @param state defines the state that will be used for the build
  61756. */
  61757. initialize(state: NodeMaterialBuildState): void;
  61758. /**
  61759. * Gets the current class name
  61760. * @returns the class name
  61761. */
  61762. getClassName(): string;
  61763. /**
  61764. * Gets the intensity input component
  61765. */
  61766. get intensity(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the direction input component
  61769. */
  61770. get direction(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the texture input component
  61773. */
  61774. get texture(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the uv input component
  61777. */
  61778. get uv(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the worldTangent input component
  61781. */
  61782. get worldTangent(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the anisotropy object output component
  61785. */
  61786. get anisotropy(): NodeMaterialConnectionPoint;
  61787. private _generateTBNSpace;
  61788. /**
  61789. * Gets the main code of the block (fragment side)
  61790. * @param state current state of the node material building
  61791. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61792. * @returns the shader code
  61793. */
  61794. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  61795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61796. protected _buildBlock(state: NodeMaterialBuildState): this;
  61797. }
  61798. }
  61799. declare module BABYLON {
  61800. /**
  61801. * Block used to implement the clear coat module of the PBR material
  61802. */
  61803. export class ClearCoatBlock extends NodeMaterialBlock {
  61804. private _scene;
  61805. /**
  61806. * Create a new ClearCoatBlock
  61807. * @param name defines the block name
  61808. */
  61809. constructor(name: string);
  61810. /**
  61811. * Initialize the block and prepare the context for build
  61812. * @param state defines the state that will be used for the build
  61813. */
  61814. initialize(state: NodeMaterialBuildState): void;
  61815. /**
  61816. * Gets the current class name
  61817. * @returns the class name
  61818. */
  61819. getClassName(): string;
  61820. /**
  61821. * Gets the intensity input component
  61822. */
  61823. get intensity(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the roughness input component
  61826. */
  61827. get roughness(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the ior input component
  61830. */
  61831. get ior(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the texture input component
  61834. */
  61835. get texture(): NodeMaterialConnectionPoint;
  61836. /**
  61837. * Gets the bump texture input component
  61838. */
  61839. get bumpTexture(): NodeMaterialConnectionPoint;
  61840. /**
  61841. * Gets the uv input component
  61842. */
  61843. get uv(): NodeMaterialConnectionPoint;
  61844. /**
  61845. * Gets the tint color input component
  61846. */
  61847. get tintColor(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the tint "at distance" input component
  61850. */
  61851. get tintAtDistance(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the tint thickness input component
  61854. */
  61855. get tintThickness(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the tint texture input component
  61858. */
  61859. get tintTexture(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the world tangent input component
  61862. */
  61863. get worldTangent(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the clear coat object output component
  61866. */
  61867. get clearcoat(): NodeMaterialConnectionPoint;
  61868. autoConfigure(material: NodeMaterial): void;
  61869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61870. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61871. private _generateTBNSpace;
  61872. /**
  61873. * Gets the main code of the block (fragment side)
  61874. * @param state current state of the node material building
  61875. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  61876. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61877. * @param worldPosVarName name of the variable holding the world position
  61878. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61879. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  61880. * @param worldNormalVarName name of the variable holding the world normal
  61881. * @returns the shader code
  61882. */
  61883. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  61884. protected _buildBlock(state: NodeMaterialBuildState): this;
  61885. }
  61886. }
  61887. declare module BABYLON {
  61888. /**
  61889. * Block used to implement the sub surface module of the PBR material
  61890. */
  61891. export class SubSurfaceBlock extends NodeMaterialBlock {
  61892. /**
  61893. * Create a new SubSurfaceBlock
  61894. * @param name defines the block name
  61895. */
  61896. constructor(name: string);
  61897. /**
  61898. * Stores the intensity of the different subsurface effects in the thickness texture.
  61899. * * the green channel is the translucency intensity.
  61900. * * the blue channel is the scattering intensity.
  61901. * * the alpha channel is the refraction intensity.
  61902. */
  61903. useMaskFromThicknessTexture: boolean;
  61904. /**
  61905. * Initialize the block and prepare the context for build
  61906. * @param state defines the state that will be used for the build
  61907. */
  61908. initialize(state: NodeMaterialBuildState): void;
  61909. /**
  61910. * Gets the current class name
  61911. * @returns the class name
  61912. */
  61913. getClassName(): string;
  61914. /**
  61915. * Gets the min thickness input component
  61916. */
  61917. get minThickness(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the max thickness input component
  61920. */
  61921. get maxThickness(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the thickness texture component
  61924. */
  61925. get thicknessTexture(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the tint color input component
  61928. */
  61929. get tintColor(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the translucency intensity input component
  61932. */
  61933. get translucencyIntensity(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the translucency diffusion distance input component
  61936. */
  61937. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the refraction object parameters
  61940. */
  61941. get refraction(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the sub surface object output component
  61944. */
  61945. get subsurface(): NodeMaterialConnectionPoint;
  61946. autoConfigure(material: NodeMaterial): void;
  61947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61948. /**
  61949. * Gets the main code of the block (fragment side)
  61950. * @param state current state of the node material building
  61951. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  61952. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61953. * @param worldPosVarName name of the variable holding the world position
  61954. * @returns the shader code
  61955. */
  61956. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  61957. protected _buildBlock(state: NodeMaterialBuildState): this;
  61958. }
  61959. }
  61960. declare module BABYLON {
  61961. /**
  61962. * Block used to implement the PBR metallic/roughness model
  61963. */
  61964. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  61965. /**
  61966. * Gets or sets the light associated with this block
  61967. */
  61968. light: Nullable<Light>;
  61969. private _lightId;
  61970. private _scene;
  61971. private _environmentBRDFTexture;
  61972. private _environmentBrdfSamplerName;
  61973. private _vNormalWName;
  61974. private _invertNormalName;
  61975. /**
  61976. * Create a new ReflectionBlock
  61977. * @param name defines the block name
  61978. */
  61979. constructor(name: string);
  61980. /**
  61981. * Intensity of the direct lights e.g. the four lights available in your scene.
  61982. * This impacts both the direct diffuse and specular highlights.
  61983. */
  61984. directIntensity: number;
  61985. /**
  61986. * Intensity of the environment e.g. how much the environment will light the object
  61987. * either through harmonics for rough material or through the refelction for shiny ones.
  61988. */
  61989. environmentIntensity: number;
  61990. /**
  61991. * This is a special control allowing the reduction of the specular highlights coming from the
  61992. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  61993. */
  61994. specularIntensity: number;
  61995. /**
  61996. * Defines the falloff type used in this material.
  61997. * It by default is Physical.
  61998. */
  61999. lightFalloff: number;
  62000. /**
  62001. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62002. */
  62003. useAlphaFromAlbedoTexture: boolean;
  62004. /**
  62005. * Specifies that alpha test should be used
  62006. */
  62007. useAlphaTest: boolean;
  62008. /**
  62009. * Defines the alpha limits in alpha test mode.
  62010. */
  62011. alphaTestCutoff: number;
  62012. /**
  62013. * Specifies that alpha blending should be used
  62014. */
  62015. useAlphaBlending: boolean;
  62016. /**
  62017. * Defines if the alpha value should be determined via the rgb values.
  62018. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62019. */
  62020. opacityRGB: boolean;
  62021. /**
  62022. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62023. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62024. */
  62025. useRadianceOverAlpha: boolean;
  62026. /**
  62027. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62029. */
  62030. useSpecularOverAlpha: boolean;
  62031. /**
  62032. * Enables specular anti aliasing in the PBR shader.
  62033. * It will both interacts on the Geometry for analytical and IBL lighting.
  62034. * It also prefilter the roughness map based on the bump values.
  62035. */
  62036. enableSpecularAntiAliasing: boolean;
  62037. /**
  62038. * Defines if the material uses energy conservation.
  62039. */
  62040. useEnergyConservation: boolean;
  62041. /**
  62042. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62043. * too much the area relying on ambient texture to define their ambient occlusion.
  62044. */
  62045. useRadianceOcclusion: boolean;
  62046. /**
  62047. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62048. * makes the reflect vector face the model (under horizon).
  62049. */
  62050. useHorizonOcclusion: boolean;
  62051. /**
  62052. * If set to true, no lighting calculations will be applied.
  62053. */
  62054. unlit: boolean;
  62055. /**
  62056. * Force normal to face away from face.
  62057. */
  62058. forceNormalForward: boolean;
  62059. /**
  62060. * Defines the material debug mode.
  62061. * It helps seeing only some components of the material while troubleshooting.
  62062. */
  62063. debugMode: number;
  62064. /**
  62065. * Specify from where on screen the debug mode should start.
  62066. * The value goes from -1 (full screen) to 1 (not visible)
  62067. * It helps with side by side comparison against the final render
  62068. * This defaults to 0
  62069. */
  62070. debugLimit: number;
  62071. /**
  62072. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62073. * You can use the factor to better multiply the final value.
  62074. */
  62075. debugFactor: number;
  62076. /**
  62077. * Initialize the block and prepare the context for build
  62078. * @param state defines the state that will be used for the build
  62079. */
  62080. initialize(state: NodeMaterialBuildState): void;
  62081. /**
  62082. * Gets the current class name
  62083. * @returns the class name
  62084. */
  62085. getClassName(): string;
  62086. /**
  62087. * Gets the world position input component
  62088. */
  62089. get worldPosition(): NodeMaterialConnectionPoint;
  62090. /**
  62091. * Gets the world normal input component
  62092. */
  62093. get worldNormal(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the perturbed normal input component
  62096. */
  62097. get perturbedNormal(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the camera position input component
  62100. */
  62101. get cameraPosition(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the base color input component
  62104. */
  62105. get baseColor(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the base texture input component
  62108. */
  62109. get baseTexture(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the opacity texture input component
  62112. */
  62113. get opacityTexture(): NodeMaterialConnectionPoint;
  62114. /**
  62115. * Gets the ambient color input component
  62116. */
  62117. get ambientColor(): NodeMaterialConnectionPoint;
  62118. /**
  62119. * Gets the reflectivity object parameters
  62120. */
  62121. get reflectivity(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the ambient occlusion object parameters
  62124. */
  62125. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the reflection object parameters
  62128. */
  62129. get reflection(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the sheen object parameters
  62132. */
  62133. get sheen(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the clear coat object parameters
  62136. */
  62137. get clearcoat(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the sub surface object parameters
  62140. */
  62141. get subsurface(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the anisotropy object parameters
  62144. */
  62145. get anisotropy(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the ambient output component
  62148. */
  62149. get ambient(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the diffuse output component
  62152. */
  62153. get diffuse(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the specular output component
  62156. */
  62157. get specular(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the sheen output component
  62160. */
  62161. get sheenDir(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the clear coat output component
  62164. */
  62165. get clearcoatDir(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the indirect diffuse output component
  62168. */
  62169. get diffuseIndirect(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the indirect specular output component
  62172. */
  62173. get specularIndirect(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the indirect sheen output component
  62176. */
  62177. get sheenIndirect(): NodeMaterialConnectionPoint;
  62178. /**
  62179. * Gets the indirect clear coat output component
  62180. */
  62181. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62182. /**
  62183. * Gets the refraction output component
  62184. */
  62185. get refraction(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the global lighting output component
  62188. */
  62189. get lighting(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the shadow output component
  62192. */
  62193. get shadow(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the alpha output component
  62196. */
  62197. get alpha(): NodeMaterialConnectionPoint;
  62198. autoConfigure(material: NodeMaterial): void;
  62199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62200. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62201. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62202. private _injectVertexCode;
  62203. /**
  62204. * Gets the code corresponding to the albedo/opacity module
  62205. * @returns the shader code
  62206. */
  62207. getAlbedoOpacityCode(): string;
  62208. protected _buildBlock(state: NodeMaterialBuildState): this;
  62209. protected _dumpPropertiesCode(): string;
  62210. serialize(): any;
  62211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62212. }
  62213. }
  62214. declare module BABYLON {
  62215. /**
  62216. * Effect Render Options
  62217. */
  62218. export interface IEffectRendererOptions {
  62219. /**
  62220. * Defines the vertices positions.
  62221. */
  62222. positions?: number[];
  62223. /**
  62224. * Defines the indices.
  62225. */
  62226. indices?: number[];
  62227. }
  62228. /**
  62229. * Helper class to render one or more effects.
  62230. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62231. */
  62232. export class EffectRenderer {
  62233. private engine;
  62234. private static _DefaultOptions;
  62235. private _vertexBuffers;
  62236. private _indexBuffer;
  62237. private _fullscreenViewport;
  62238. /**
  62239. * Creates an effect renderer
  62240. * @param engine the engine to use for rendering
  62241. * @param options defines the options of the effect renderer
  62242. */
  62243. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62244. /**
  62245. * Sets the current viewport in normalized coordinates 0-1
  62246. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62247. */
  62248. setViewport(viewport?: Viewport): void;
  62249. /**
  62250. * Binds the embedded attributes buffer to the effect.
  62251. * @param effect Defines the effect to bind the attributes for
  62252. */
  62253. bindBuffers(effect: Effect): void;
  62254. /**
  62255. * Sets the current effect wrapper to use during draw.
  62256. * The effect needs to be ready before calling this api.
  62257. * This also sets the default full screen position attribute.
  62258. * @param effectWrapper Defines the effect to draw with
  62259. */
  62260. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62261. /**
  62262. * Draws a full screen quad.
  62263. */
  62264. draw(): void;
  62265. private isRenderTargetTexture;
  62266. /**
  62267. * renders one or more effects to a specified texture
  62268. * @param effectWrapper the effect to renderer
  62269. * @param outputTexture texture to draw to, if null it will render to the screen.
  62270. */
  62271. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62272. /**
  62273. * Disposes of the effect renderer
  62274. */
  62275. dispose(): void;
  62276. }
  62277. /**
  62278. * Options to create an EffectWrapper
  62279. */
  62280. interface EffectWrapperCreationOptions {
  62281. /**
  62282. * Engine to use to create the effect
  62283. */
  62284. engine: ThinEngine;
  62285. /**
  62286. * Fragment shader for the effect
  62287. */
  62288. fragmentShader: string;
  62289. /**
  62290. * Vertex shader for the effect
  62291. */
  62292. vertexShader?: string;
  62293. /**
  62294. * Attributes to use in the shader
  62295. */
  62296. attributeNames?: Array<string>;
  62297. /**
  62298. * Uniforms to use in the shader
  62299. */
  62300. uniformNames?: Array<string>;
  62301. /**
  62302. * Texture sampler names to use in the shader
  62303. */
  62304. samplerNames?: Array<string>;
  62305. /**
  62306. * The friendly name of the effect displayed in Spector.
  62307. */
  62308. name?: string;
  62309. }
  62310. /**
  62311. * Wraps an effect to be used for rendering
  62312. */
  62313. export class EffectWrapper {
  62314. /**
  62315. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62316. */
  62317. onApplyObservable: Observable<{}>;
  62318. /**
  62319. * The underlying effect
  62320. */
  62321. effect: Effect;
  62322. /**
  62323. * Creates an effect to be renderer
  62324. * @param creationOptions options to create the effect
  62325. */
  62326. constructor(creationOptions: EffectWrapperCreationOptions);
  62327. /**
  62328. * Disposes of the effect wrapper
  62329. */
  62330. dispose(): void;
  62331. }
  62332. }
  62333. declare module BABYLON {
  62334. /**
  62335. * Helper class to push actions to a pool of workers.
  62336. */
  62337. export class WorkerPool implements IDisposable {
  62338. private _workerInfos;
  62339. private _pendingActions;
  62340. /**
  62341. * Constructor
  62342. * @param workers Array of workers to use for actions
  62343. */
  62344. constructor(workers: Array<Worker>);
  62345. /**
  62346. * Terminates all workers and clears any pending actions.
  62347. */
  62348. dispose(): void;
  62349. /**
  62350. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62351. * pended until a worker has completed its action.
  62352. * @param action The action to perform. Call onComplete when the action is complete.
  62353. */
  62354. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62355. private _execute;
  62356. }
  62357. }
  62358. declare module BABYLON {
  62359. /**
  62360. * Configuration for Draco compression
  62361. */
  62362. export interface IDracoCompressionConfiguration {
  62363. /**
  62364. * Configuration for the decoder.
  62365. */
  62366. decoder: {
  62367. /**
  62368. * The url to the WebAssembly module.
  62369. */
  62370. wasmUrl?: string;
  62371. /**
  62372. * The url to the WebAssembly binary.
  62373. */
  62374. wasmBinaryUrl?: string;
  62375. /**
  62376. * The url to the fallback JavaScript module.
  62377. */
  62378. fallbackUrl?: string;
  62379. };
  62380. }
  62381. /**
  62382. * Draco compression (https://google.github.io/draco/)
  62383. *
  62384. * This class wraps the Draco module.
  62385. *
  62386. * **Encoder**
  62387. *
  62388. * The encoder is not currently implemented.
  62389. *
  62390. * **Decoder**
  62391. *
  62392. * 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.
  62393. *
  62394. * To update the configuration, use the following code:
  62395. * ```javascript
  62396. * DracoCompression.Configuration = {
  62397. * decoder: {
  62398. * wasmUrl: "<url to the WebAssembly library>",
  62399. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62400. * fallbackUrl: "<url to the fallback JavaScript library>",
  62401. * }
  62402. * };
  62403. * ```
  62404. *
  62405. * 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.
  62406. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62407. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62408. *
  62409. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62410. * ```javascript
  62411. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62412. * ```
  62413. *
  62414. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62415. */
  62416. export class DracoCompression implements IDisposable {
  62417. private _workerPoolPromise?;
  62418. private _decoderModulePromise?;
  62419. /**
  62420. * The configuration. Defaults to the following urls:
  62421. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62422. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62423. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62424. */
  62425. static Configuration: IDracoCompressionConfiguration;
  62426. /**
  62427. * Returns true if the decoder configuration is available.
  62428. */
  62429. static get DecoderAvailable(): boolean;
  62430. /**
  62431. * Default number of workers to create when creating the draco compression object.
  62432. */
  62433. static DefaultNumWorkers: number;
  62434. private static GetDefaultNumWorkers;
  62435. private static _Default;
  62436. /**
  62437. * Default instance for the draco compression object.
  62438. */
  62439. static get Default(): DracoCompression;
  62440. /**
  62441. * Constructor
  62442. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62443. */
  62444. constructor(numWorkers?: number);
  62445. /**
  62446. * Stop all async operations and release resources.
  62447. */
  62448. dispose(): void;
  62449. /**
  62450. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62451. * @returns a promise that resolves when ready
  62452. */
  62453. whenReadyAsync(): Promise<void>;
  62454. /**
  62455. * Decode Draco compressed mesh data to vertex data.
  62456. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62457. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62458. * @returns A promise that resolves with the decoded vertex data
  62459. */
  62460. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62461. [kind: string]: number;
  62462. }): Promise<VertexData>;
  62463. }
  62464. }
  62465. declare module BABYLON {
  62466. /**
  62467. * Class for building Constructive Solid Geometry
  62468. */
  62469. export class CSG {
  62470. private polygons;
  62471. /**
  62472. * The world matrix
  62473. */
  62474. matrix: Matrix;
  62475. /**
  62476. * Stores the position
  62477. */
  62478. position: Vector3;
  62479. /**
  62480. * Stores the rotation
  62481. */
  62482. rotation: Vector3;
  62483. /**
  62484. * Stores the rotation quaternion
  62485. */
  62486. rotationQuaternion: Nullable<Quaternion>;
  62487. /**
  62488. * Stores the scaling vector
  62489. */
  62490. scaling: Vector3;
  62491. /**
  62492. * Convert the Mesh to CSG
  62493. * @param mesh The Mesh to convert to CSG
  62494. * @returns A new CSG from the Mesh
  62495. */
  62496. static FromMesh(mesh: Mesh): CSG;
  62497. /**
  62498. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62499. * @param polygons Polygons used to construct a CSG solid
  62500. */
  62501. private static FromPolygons;
  62502. /**
  62503. * Clones, or makes a deep copy, of the CSG
  62504. * @returns A new CSG
  62505. */
  62506. clone(): CSG;
  62507. /**
  62508. * Unions this CSG with another CSG
  62509. * @param csg The CSG to union against this CSG
  62510. * @returns The unioned CSG
  62511. */
  62512. union(csg: CSG): CSG;
  62513. /**
  62514. * Unions this CSG with another CSG in place
  62515. * @param csg The CSG to union against this CSG
  62516. */
  62517. unionInPlace(csg: CSG): void;
  62518. /**
  62519. * Subtracts this CSG with another CSG
  62520. * @param csg The CSG to subtract against this CSG
  62521. * @returns A new CSG
  62522. */
  62523. subtract(csg: CSG): CSG;
  62524. /**
  62525. * Subtracts this CSG with another CSG in place
  62526. * @param csg The CSG to subtact against this CSG
  62527. */
  62528. subtractInPlace(csg: CSG): void;
  62529. /**
  62530. * Intersect this CSG with another CSG
  62531. * @param csg The CSG to intersect against this CSG
  62532. * @returns A new CSG
  62533. */
  62534. intersect(csg: CSG): CSG;
  62535. /**
  62536. * Intersects this CSG with another CSG in place
  62537. * @param csg The CSG to intersect against this CSG
  62538. */
  62539. intersectInPlace(csg: CSG): void;
  62540. /**
  62541. * Return a new CSG solid with solid and empty space switched. This solid is
  62542. * not modified.
  62543. * @returns A new CSG solid with solid and empty space switched
  62544. */
  62545. inverse(): CSG;
  62546. /**
  62547. * Inverses the CSG in place
  62548. */
  62549. inverseInPlace(): void;
  62550. /**
  62551. * This is used to keep meshes transformations so they can be restored
  62552. * when we build back a Babylon Mesh
  62553. * NB : All CSG operations are performed in world coordinates
  62554. * @param csg The CSG to copy the transform attributes from
  62555. * @returns This CSG
  62556. */
  62557. copyTransformAttributes(csg: CSG): CSG;
  62558. /**
  62559. * Build Raw mesh from CSG
  62560. * Coordinates here are in world space
  62561. * @param name The name of the mesh geometry
  62562. * @param scene The Scene
  62563. * @param keepSubMeshes Specifies if the submeshes should be kept
  62564. * @returns A new Mesh
  62565. */
  62566. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62567. /**
  62568. * Build Mesh from CSG taking material and transforms into account
  62569. * @param name The name of the Mesh
  62570. * @param material The material of the Mesh
  62571. * @param scene The Scene
  62572. * @param keepSubMeshes Specifies if submeshes should be kept
  62573. * @returns The new Mesh
  62574. */
  62575. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * Class used to create a trail following a mesh
  62581. */
  62582. export class TrailMesh extends Mesh {
  62583. private _generator;
  62584. private _autoStart;
  62585. private _running;
  62586. private _diameter;
  62587. private _length;
  62588. private _sectionPolygonPointsCount;
  62589. private _sectionVectors;
  62590. private _sectionNormalVectors;
  62591. private _beforeRenderObserver;
  62592. /**
  62593. * @constructor
  62594. * @param name The value used by scene.getMeshByName() to do a lookup.
  62595. * @param generator The mesh or transform node to generate a trail.
  62596. * @param scene The scene to add this mesh to.
  62597. * @param diameter Diameter of trailing mesh. Default is 1.
  62598. * @param length Length of trailing mesh. Default is 60.
  62599. * @param autoStart Automatically start trailing mesh. Default true.
  62600. */
  62601. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62602. /**
  62603. * "TrailMesh"
  62604. * @returns "TrailMesh"
  62605. */
  62606. getClassName(): string;
  62607. private _createMesh;
  62608. /**
  62609. * Start trailing mesh.
  62610. */
  62611. start(): void;
  62612. /**
  62613. * Stop trailing mesh.
  62614. */
  62615. stop(): void;
  62616. /**
  62617. * Update trailing mesh geometry.
  62618. */
  62619. update(): void;
  62620. /**
  62621. * Returns a new TrailMesh object.
  62622. * @param name is a string, the name given to the new mesh
  62623. * @param newGenerator use new generator object for cloned trail mesh
  62624. * @returns a new mesh
  62625. */
  62626. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  62627. /**
  62628. * Serializes this trail mesh
  62629. * @param serializationObject object to write serialization to
  62630. */
  62631. serialize(serializationObject: any): void;
  62632. /**
  62633. * Parses a serialized trail mesh
  62634. * @param parsedMesh the serialized mesh
  62635. * @param scene the scene to create the trail mesh in
  62636. * @returns the created trail mesh
  62637. */
  62638. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62639. }
  62640. }
  62641. declare module BABYLON {
  62642. /**
  62643. * Class containing static functions to help procedurally build meshes
  62644. */
  62645. export class TiledBoxBuilder {
  62646. /**
  62647. * Creates a box mesh
  62648. * 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)
  62649. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62651. * * 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
  62652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62653. * @param name defines the name of the mesh
  62654. * @param options defines the options used to create the mesh
  62655. * @param scene defines the hosting scene
  62656. * @returns the box mesh
  62657. */
  62658. static CreateTiledBox(name: string, options: {
  62659. pattern?: number;
  62660. width?: number;
  62661. height?: number;
  62662. depth?: number;
  62663. tileSize?: number;
  62664. tileWidth?: number;
  62665. tileHeight?: number;
  62666. alignHorizontal?: number;
  62667. alignVertical?: number;
  62668. faceUV?: Vector4[];
  62669. faceColors?: Color4[];
  62670. sideOrientation?: number;
  62671. updatable?: boolean;
  62672. }, scene?: Nullable<Scene>): Mesh;
  62673. }
  62674. }
  62675. declare module BABYLON {
  62676. /**
  62677. * Class containing static functions to help procedurally build meshes
  62678. */
  62679. export class TorusKnotBuilder {
  62680. /**
  62681. * Creates a torus knot mesh
  62682. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62683. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62684. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62685. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62687. * * 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
  62688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62689. * @param name defines the name of the mesh
  62690. * @param options defines the options used to create the mesh
  62691. * @param scene defines the hosting scene
  62692. * @returns the torus knot mesh
  62693. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62694. */
  62695. static CreateTorusKnot(name: string, options: {
  62696. radius?: number;
  62697. tube?: number;
  62698. radialSegments?: number;
  62699. tubularSegments?: number;
  62700. p?: number;
  62701. q?: number;
  62702. updatable?: boolean;
  62703. sideOrientation?: number;
  62704. frontUVs?: Vector4;
  62705. backUVs?: Vector4;
  62706. }, scene: any): Mesh;
  62707. }
  62708. }
  62709. declare module BABYLON {
  62710. /**
  62711. * Polygon
  62712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62713. */
  62714. export class Polygon {
  62715. /**
  62716. * Creates a rectangle
  62717. * @param xmin bottom X coord
  62718. * @param ymin bottom Y coord
  62719. * @param xmax top X coord
  62720. * @param ymax top Y coord
  62721. * @returns points that make the resulting rectation
  62722. */
  62723. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62724. /**
  62725. * Creates a circle
  62726. * @param radius radius of circle
  62727. * @param cx scale in x
  62728. * @param cy scale in y
  62729. * @param numberOfSides number of sides that make up the circle
  62730. * @returns points that make the resulting circle
  62731. */
  62732. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62733. /**
  62734. * Creates a polygon from input string
  62735. * @param input Input polygon data
  62736. * @returns the parsed points
  62737. */
  62738. static Parse(input: string): Vector2[];
  62739. /**
  62740. * Starts building a polygon from x and y coordinates
  62741. * @param x x coordinate
  62742. * @param y y coordinate
  62743. * @returns the started path2
  62744. */
  62745. static StartingAt(x: number, y: number): Path2;
  62746. }
  62747. /**
  62748. * Builds a polygon
  62749. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62750. */
  62751. export class PolygonMeshBuilder {
  62752. private _points;
  62753. private _outlinepoints;
  62754. private _holes;
  62755. private _name;
  62756. private _scene;
  62757. private _epoints;
  62758. private _eholes;
  62759. private _addToepoint;
  62760. /**
  62761. * Babylon reference to the earcut plugin.
  62762. */
  62763. bjsEarcut: any;
  62764. /**
  62765. * Creates a PolygonMeshBuilder
  62766. * @param name name of the builder
  62767. * @param contours Path of the polygon
  62768. * @param scene scene to add to when creating the mesh
  62769. * @param earcutInjection can be used to inject your own earcut reference
  62770. */
  62771. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62772. /**
  62773. * Adds a whole within the polygon
  62774. * @param hole Array of points defining the hole
  62775. * @returns this
  62776. */
  62777. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62778. /**
  62779. * Creates the polygon
  62780. * @param updatable If the mesh should be updatable
  62781. * @param depth The depth of the mesh created
  62782. * @returns the created mesh
  62783. */
  62784. build(updatable?: boolean, depth?: number): Mesh;
  62785. /**
  62786. * Creates the polygon
  62787. * @param depth The depth of the mesh created
  62788. * @returns the created VertexData
  62789. */
  62790. buildVertexData(depth?: number): VertexData;
  62791. /**
  62792. * Adds a side to the polygon
  62793. * @param positions points that make the polygon
  62794. * @param normals normals of the polygon
  62795. * @param uvs uvs of the polygon
  62796. * @param indices indices of the polygon
  62797. * @param bounds bounds of the polygon
  62798. * @param points points of the polygon
  62799. * @param depth depth of the polygon
  62800. * @param flip flip of the polygon
  62801. */
  62802. private addSide;
  62803. }
  62804. }
  62805. declare module BABYLON {
  62806. /**
  62807. * Class containing static functions to help procedurally build meshes
  62808. */
  62809. export class PolygonBuilder {
  62810. /**
  62811. * Creates a polygon mesh
  62812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62813. * * 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
  62814. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62816. * * 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)
  62817. * * Remember you can only change the shape positions, not their number when updating a polygon
  62818. * @param name defines the name of the mesh
  62819. * @param options defines the options used to create the mesh
  62820. * @param scene defines the hosting scene
  62821. * @param earcutInjection can be used to inject your own earcut reference
  62822. * @returns the polygon mesh
  62823. */
  62824. static CreatePolygon(name: string, options: {
  62825. shape: Vector3[];
  62826. holes?: Vector3[][];
  62827. depth?: number;
  62828. faceUV?: Vector4[];
  62829. faceColors?: Color4[];
  62830. updatable?: boolean;
  62831. sideOrientation?: number;
  62832. frontUVs?: Vector4;
  62833. backUVs?: Vector4;
  62834. wrap?: boolean;
  62835. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62836. /**
  62837. * Creates an extruded polygon mesh, with depth in the Y direction.
  62838. * * 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)
  62839. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62840. * @param name defines the name of the mesh
  62841. * @param options defines the options used to create the mesh
  62842. * @param scene defines the hosting scene
  62843. * @param earcutInjection can be used to inject your own earcut reference
  62844. * @returns the polygon mesh
  62845. */
  62846. static ExtrudePolygon(name: string, options: {
  62847. shape: Vector3[];
  62848. holes?: Vector3[][];
  62849. depth?: number;
  62850. faceUV?: Vector4[];
  62851. faceColors?: Color4[];
  62852. updatable?: boolean;
  62853. sideOrientation?: number;
  62854. frontUVs?: Vector4;
  62855. backUVs?: Vector4;
  62856. wrap?: boolean;
  62857. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62858. }
  62859. }
  62860. declare module BABYLON {
  62861. /**
  62862. * Class containing static functions to help procedurally build meshes
  62863. */
  62864. export class LatheBuilder {
  62865. /**
  62866. * Creates lathe mesh.
  62867. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62868. * * 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
  62869. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62870. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62871. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62872. * * 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
  62873. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62874. * * 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
  62875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62876. * * 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
  62877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62879. * @param name defines the name of the mesh
  62880. * @param options defines the options used to create the mesh
  62881. * @param scene defines the hosting scene
  62882. * @returns the lathe mesh
  62883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62884. */
  62885. static CreateLathe(name: string, options: {
  62886. shape: Vector3[];
  62887. radius?: number;
  62888. tessellation?: number;
  62889. clip?: number;
  62890. arc?: number;
  62891. closed?: boolean;
  62892. updatable?: boolean;
  62893. sideOrientation?: number;
  62894. frontUVs?: Vector4;
  62895. backUVs?: Vector4;
  62896. cap?: number;
  62897. invertUV?: boolean;
  62898. }, scene?: Nullable<Scene>): Mesh;
  62899. }
  62900. }
  62901. declare module BABYLON {
  62902. /**
  62903. * Class containing static functions to help procedurally build meshes
  62904. */
  62905. export class TiledPlaneBuilder {
  62906. /**
  62907. * Creates a tiled plane mesh
  62908. * * The parameter `pattern` will, depending on value, do nothing or
  62909. * * * flip (reflect about central vertical) alternate tiles across and up
  62910. * * * flip every tile on alternate rows
  62911. * * * rotate (180 degs) alternate tiles across and up
  62912. * * * rotate every tile on alternate rows
  62913. * * * flip and rotate alternate tiles across and up
  62914. * * * flip and rotate every tile on alternate rows
  62915. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62916. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62917. * * 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
  62918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62919. * * 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)
  62920. * * 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)
  62921. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62922. * @param name defines the name of the mesh
  62923. * @param options defines the options used to create the mesh
  62924. * @param scene defines the hosting scene
  62925. * @returns the box mesh
  62926. */
  62927. static CreateTiledPlane(name: string, options: {
  62928. pattern?: number;
  62929. tileSize?: number;
  62930. tileWidth?: number;
  62931. tileHeight?: number;
  62932. size?: number;
  62933. width?: number;
  62934. height?: number;
  62935. alignHorizontal?: number;
  62936. alignVertical?: number;
  62937. sideOrientation?: number;
  62938. frontUVs?: Vector4;
  62939. backUVs?: Vector4;
  62940. updatable?: boolean;
  62941. }, scene?: Nullable<Scene>): Mesh;
  62942. }
  62943. }
  62944. declare module BABYLON {
  62945. /**
  62946. * Class containing static functions to help procedurally build meshes
  62947. */
  62948. export class TubeBuilder {
  62949. /**
  62950. * Creates a tube mesh.
  62951. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62952. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62953. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62954. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62955. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62956. * * 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)
  62957. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62958. * * 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
  62959. * * 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
  62960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62961. * * 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
  62962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62964. * @param name defines the name of the mesh
  62965. * @param options defines the options used to create the mesh
  62966. * @param scene defines the hosting scene
  62967. * @returns the tube mesh
  62968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62969. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62970. */
  62971. static CreateTube(name: string, options: {
  62972. path: Vector3[];
  62973. radius?: number;
  62974. tessellation?: number;
  62975. radiusFunction?: {
  62976. (i: number, distance: number): number;
  62977. };
  62978. cap?: number;
  62979. arc?: number;
  62980. updatable?: boolean;
  62981. sideOrientation?: number;
  62982. frontUVs?: Vector4;
  62983. backUVs?: Vector4;
  62984. instance?: Mesh;
  62985. invertUV?: boolean;
  62986. }, scene?: Nullable<Scene>): Mesh;
  62987. }
  62988. }
  62989. declare module BABYLON {
  62990. /**
  62991. * Class containing static functions to help procedurally build meshes
  62992. */
  62993. export class IcoSphereBuilder {
  62994. /**
  62995. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62996. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62997. * * 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`)
  62998. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62999. * * 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
  63000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63001. * * 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
  63002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63003. * @param name defines the name of the mesh
  63004. * @param options defines the options used to create the mesh
  63005. * @param scene defines the hosting scene
  63006. * @returns the icosahedron mesh
  63007. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63008. */
  63009. static CreateIcoSphere(name: string, options: {
  63010. radius?: number;
  63011. radiusX?: number;
  63012. radiusY?: number;
  63013. radiusZ?: number;
  63014. flat?: boolean;
  63015. subdivisions?: number;
  63016. sideOrientation?: number;
  63017. frontUVs?: Vector4;
  63018. backUVs?: Vector4;
  63019. updatable?: boolean;
  63020. }, scene?: Nullable<Scene>): Mesh;
  63021. }
  63022. }
  63023. declare module BABYLON {
  63024. /**
  63025. * Class containing static functions to help procedurally build meshes
  63026. */
  63027. export class DecalBuilder {
  63028. /**
  63029. * Creates a decal mesh.
  63030. * 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
  63031. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63032. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63033. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63034. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63035. * @param name defines the name of the mesh
  63036. * @param sourceMesh defines the mesh where the decal must be applied
  63037. * @param options defines the options used to create the mesh
  63038. * @param scene defines the hosting scene
  63039. * @returns the decal mesh
  63040. * @see https://doc.babylonjs.com/how_to/decals
  63041. */
  63042. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63043. position?: Vector3;
  63044. normal?: Vector3;
  63045. size?: Vector3;
  63046. angle?: number;
  63047. }): Mesh;
  63048. }
  63049. }
  63050. declare module BABYLON {
  63051. /**
  63052. * Class containing static functions to help procedurally build meshes
  63053. */
  63054. export class MeshBuilder {
  63055. /**
  63056. * Creates a box mesh
  63057. * * The parameter `size` sets the size (float) of each box side (default 1)
  63058. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63059. * * 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)
  63060. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63062. * * 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
  63063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63064. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63065. * @param name defines the name of the mesh
  63066. * @param options defines the options used to create the mesh
  63067. * @param scene defines the hosting scene
  63068. * @returns the box mesh
  63069. */
  63070. static CreateBox(name: string, options: {
  63071. size?: number;
  63072. width?: number;
  63073. height?: number;
  63074. depth?: number;
  63075. faceUV?: Vector4[];
  63076. faceColors?: Color4[];
  63077. sideOrientation?: number;
  63078. frontUVs?: Vector4;
  63079. backUVs?: Vector4;
  63080. wrap?: boolean;
  63081. topBaseAt?: number;
  63082. bottomBaseAt?: number;
  63083. updatable?: boolean;
  63084. }, scene?: Nullable<Scene>): Mesh;
  63085. /**
  63086. * Creates a tiled box mesh
  63087. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63089. * @param name defines the name of the mesh
  63090. * @param options defines the options used to create the mesh
  63091. * @param scene defines the hosting scene
  63092. * @returns the tiled box mesh
  63093. */
  63094. static CreateTiledBox(name: string, options: {
  63095. pattern?: number;
  63096. size?: number;
  63097. width?: number;
  63098. height?: number;
  63099. depth: number;
  63100. tileSize?: number;
  63101. tileWidth?: number;
  63102. tileHeight?: number;
  63103. faceUV?: Vector4[];
  63104. faceColors?: Color4[];
  63105. alignHorizontal?: number;
  63106. alignVertical?: number;
  63107. sideOrientation?: number;
  63108. updatable?: boolean;
  63109. }, scene?: Nullable<Scene>): Mesh;
  63110. /**
  63111. * Creates a sphere mesh
  63112. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63113. * * 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`)
  63114. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63115. * * 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
  63116. * * 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)
  63117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63118. * * 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
  63119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63120. * @param name defines the name of the mesh
  63121. * @param options defines the options used to create the mesh
  63122. * @param scene defines the hosting scene
  63123. * @returns the sphere mesh
  63124. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63125. */
  63126. static CreateSphere(name: string, options: {
  63127. segments?: number;
  63128. diameter?: number;
  63129. diameterX?: number;
  63130. diameterY?: number;
  63131. diameterZ?: number;
  63132. arc?: number;
  63133. slice?: number;
  63134. sideOrientation?: number;
  63135. frontUVs?: Vector4;
  63136. backUVs?: Vector4;
  63137. updatable?: boolean;
  63138. }, scene?: Nullable<Scene>): Mesh;
  63139. /**
  63140. * Creates a plane polygonal mesh. By default, this is a disc
  63141. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63142. * * 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
  63143. * * 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
  63144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63145. * * 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
  63146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63147. * @param name defines the name of the mesh
  63148. * @param options defines the options used to create the mesh
  63149. * @param scene defines the hosting scene
  63150. * @returns the plane polygonal mesh
  63151. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63152. */
  63153. static CreateDisc(name: string, options: {
  63154. radius?: number;
  63155. tessellation?: number;
  63156. arc?: number;
  63157. updatable?: boolean;
  63158. sideOrientation?: number;
  63159. frontUVs?: Vector4;
  63160. backUVs?: Vector4;
  63161. }, scene?: Nullable<Scene>): Mesh;
  63162. /**
  63163. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63164. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63165. * * 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`)
  63166. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63167. * * 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
  63168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63169. * * 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
  63170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63171. * @param name defines the name of the mesh
  63172. * @param options defines the options used to create the mesh
  63173. * @param scene defines the hosting scene
  63174. * @returns the icosahedron mesh
  63175. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63176. */
  63177. static CreateIcoSphere(name: string, options: {
  63178. radius?: number;
  63179. radiusX?: number;
  63180. radiusY?: number;
  63181. radiusZ?: number;
  63182. flat?: boolean;
  63183. subdivisions?: number;
  63184. sideOrientation?: number;
  63185. frontUVs?: Vector4;
  63186. backUVs?: Vector4;
  63187. updatable?: boolean;
  63188. }, scene?: Nullable<Scene>): Mesh;
  63189. /**
  63190. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63191. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63192. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63193. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63194. * * 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
  63195. * * 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
  63196. * * 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
  63197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63198. * * 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
  63199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63200. * * 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
  63201. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63202. * * 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
  63203. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63205. * @param name defines the name of the mesh
  63206. * @param options defines the options used to create the mesh
  63207. * @param scene defines the hosting scene
  63208. * @returns the ribbon mesh
  63209. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63211. */
  63212. static CreateRibbon(name: string, options: {
  63213. pathArray: Vector3[][];
  63214. closeArray?: boolean;
  63215. closePath?: boolean;
  63216. offset?: number;
  63217. updatable?: boolean;
  63218. sideOrientation?: number;
  63219. frontUVs?: Vector4;
  63220. backUVs?: Vector4;
  63221. instance?: Mesh;
  63222. invertUV?: boolean;
  63223. uvs?: Vector2[];
  63224. colors?: Color4[];
  63225. }, scene?: Nullable<Scene>): Mesh;
  63226. /**
  63227. * Creates a cylinder or a cone mesh
  63228. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63229. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63230. * * 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.
  63231. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63232. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63233. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63234. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63235. * * 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).
  63236. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63237. * * 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).
  63238. * * 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
  63239. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63240. * * 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
  63241. * * 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.
  63242. * * If `enclose` is false, a ring surface is one element.
  63243. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63244. * * 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
  63245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63246. * * 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
  63247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63248. * @param name defines the name of the mesh
  63249. * @param options defines the options used to create the mesh
  63250. * @param scene defines the hosting scene
  63251. * @returns the cylinder mesh
  63252. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63253. */
  63254. static CreateCylinder(name: string, options: {
  63255. height?: number;
  63256. diameterTop?: number;
  63257. diameterBottom?: number;
  63258. diameter?: number;
  63259. tessellation?: number;
  63260. subdivisions?: number;
  63261. arc?: number;
  63262. faceColors?: Color4[];
  63263. faceUV?: Vector4[];
  63264. updatable?: boolean;
  63265. hasRings?: boolean;
  63266. enclose?: boolean;
  63267. cap?: number;
  63268. sideOrientation?: number;
  63269. frontUVs?: Vector4;
  63270. backUVs?: Vector4;
  63271. }, scene?: Nullable<Scene>): Mesh;
  63272. /**
  63273. * Creates a torus mesh
  63274. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63275. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63276. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63278. * * 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
  63279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63280. * @param name defines the name of the mesh
  63281. * @param options defines the options used to create the mesh
  63282. * @param scene defines the hosting scene
  63283. * @returns the torus mesh
  63284. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63285. */
  63286. static CreateTorus(name: string, options: {
  63287. diameter?: number;
  63288. thickness?: number;
  63289. tessellation?: number;
  63290. updatable?: boolean;
  63291. sideOrientation?: number;
  63292. frontUVs?: Vector4;
  63293. backUVs?: Vector4;
  63294. }, scene?: Nullable<Scene>): Mesh;
  63295. /**
  63296. * Creates a torus knot mesh
  63297. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63298. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63299. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63300. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63302. * * 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
  63303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63304. * @param name defines the name of the mesh
  63305. * @param options defines the options used to create the mesh
  63306. * @param scene defines the hosting scene
  63307. * @returns the torus knot mesh
  63308. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63309. */
  63310. static CreateTorusKnot(name: string, options: {
  63311. radius?: number;
  63312. tube?: number;
  63313. radialSegments?: number;
  63314. tubularSegments?: number;
  63315. p?: number;
  63316. q?: number;
  63317. updatable?: boolean;
  63318. sideOrientation?: number;
  63319. frontUVs?: Vector4;
  63320. backUVs?: Vector4;
  63321. }, scene?: Nullable<Scene>): Mesh;
  63322. /**
  63323. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63324. * * 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
  63325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63326. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63327. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63328. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63329. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63330. * * 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
  63331. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63334. * @param name defines the name of the new line system
  63335. * @param options defines the options used to create the line system
  63336. * @param scene defines the hosting scene
  63337. * @returns a new line system mesh
  63338. */
  63339. static CreateLineSystem(name: string, options: {
  63340. lines: Vector3[][];
  63341. updatable?: boolean;
  63342. instance?: Nullable<LinesMesh>;
  63343. colors?: Nullable<Color4[][]>;
  63344. useVertexAlpha?: boolean;
  63345. }, scene: Nullable<Scene>): LinesMesh;
  63346. /**
  63347. * Creates a line mesh
  63348. * 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
  63349. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63350. * * The parameter `points` is an array successive Vector3
  63351. * * 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
  63352. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63353. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63354. * * When updating an instance, remember that only point positions can change, not the number of points
  63355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63357. * @param name defines the name of the new line system
  63358. * @param options defines the options used to create the line system
  63359. * @param scene defines the hosting scene
  63360. * @returns a new line mesh
  63361. */
  63362. static CreateLines(name: string, options: {
  63363. points: Vector3[];
  63364. updatable?: boolean;
  63365. instance?: Nullable<LinesMesh>;
  63366. colors?: Color4[];
  63367. useVertexAlpha?: boolean;
  63368. }, scene?: Nullable<Scene>): LinesMesh;
  63369. /**
  63370. * Creates a dashed line mesh
  63371. * * 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
  63372. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63373. * * The parameter `points` is an array successive Vector3
  63374. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63375. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63376. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63377. * * 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
  63378. * * When updating an instance, remember that only point positions can change, not the number of points
  63379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63380. * @param name defines the name of the mesh
  63381. * @param options defines the options used to create the mesh
  63382. * @param scene defines the hosting scene
  63383. * @returns the dashed line mesh
  63384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63385. */
  63386. static CreateDashedLines(name: string, options: {
  63387. points: Vector3[];
  63388. dashSize?: number;
  63389. gapSize?: number;
  63390. dashNb?: number;
  63391. updatable?: boolean;
  63392. instance?: LinesMesh;
  63393. }, scene?: Nullable<Scene>): LinesMesh;
  63394. /**
  63395. * 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.
  63396. * * 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.
  63397. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63398. * * 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.
  63399. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63400. * * 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
  63401. * * 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
  63402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63404. * * 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
  63405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63407. * @param name defines the name of the mesh
  63408. * @param options defines the options used to create the mesh
  63409. * @param scene defines the hosting scene
  63410. * @returns the extruded shape mesh
  63411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63413. */
  63414. static ExtrudeShape(name: string, options: {
  63415. shape: Vector3[];
  63416. path: Vector3[];
  63417. scale?: number;
  63418. rotation?: number;
  63419. cap?: number;
  63420. updatable?: boolean;
  63421. sideOrientation?: number;
  63422. frontUVs?: Vector4;
  63423. backUVs?: Vector4;
  63424. instance?: Mesh;
  63425. invertUV?: boolean;
  63426. }, scene?: Nullable<Scene>): Mesh;
  63427. /**
  63428. * Creates an custom extruded shape mesh.
  63429. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63430. * * 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.
  63431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63432. * * 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
  63433. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63434. * * 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
  63435. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63436. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63437. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63438. * * 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
  63439. * * 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
  63440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63442. * * 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
  63443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63445. * @param name defines the name of the mesh
  63446. * @param options defines the options used to create the mesh
  63447. * @param scene defines the hosting scene
  63448. * @returns the custom extruded shape mesh
  63449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63452. */
  63453. static ExtrudeShapeCustom(name: string, options: {
  63454. shape: Vector3[];
  63455. path: Vector3[];
  63456. scaleFunction?: any;
  63457. rotationFunction?: any;
  63458. ribbonCloseArray?: boolean;
  63459. ribbonClosePath?: boolean;
  63460. cap?: number;
  63461. updatable?: boolean;
  63462. sideOrientation?: number;
  63463. frontUVs?: Vector4;
  63464. backUVs?: Vector4;
  63465. instance?: Mesh;
  63466. invertUV?: boolean;
  63467. }, scene?: Nullable<Scene>): Mesh;
  63468. /**
  63469. * Creates lathe mesh.
  63470. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63471. * * 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
  63472. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63473. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63474. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63475. * * 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
  63476. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63477. * * 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
  63478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63479. * * 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
  63480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63482. * @param name defines the name of the mesh
  63483. * @param options defines the options used to create the mesh
  63484. * @param scene defines the hosting scene
  63485. * @returns the lathe mesh
  63486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63487. */
  63488. static CreateLathe(name: string, options: {
  63489. shape: Vector3[];
  63490. radius?: number;
  63491. tessellation?: number;
  63492. clip?: number;
  63493. arc?: number;
  63494. closed?: boolean;
  63495. updatable?: boolean;
  63496. sideOrientation?: number;
  63497. frontUVs?: Vector4;
  63498. backUVs?: Vector4;
  63499. cap?: number;
  63500. invertUV?: boolean;
  63501. }, scene?: Nullable<Scene>): Mesh;
  63502. /**
  63503. * Creates a tiled plane mesh
  63504. * * You can set a limited pattern arrangement with the tiles
  63505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63506. * * 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
  63507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63508. * @param name defines the name of the mesh
  63509. * @param options defines the options used to create the mesh
  63510. * @param scene defines the hosting scene
  63511. * @returns the plane mesh
  63512. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63513. */
  63514. static CreateTiledPlane(name: string, options: {
  63515. pattern?: number;
  63516. tileSize?: number;
  63517. tileWidth?: number;
  63518. tileHeight?: number;
  63519. size?: number;
  63520. width?: number;
  63521. height?: number;
  63522. alignHorizontal?: number;
  63523. alignVertical?: number;
  63524. sideOrientation?: number;
  63525. frontUVs?: Vector4;
  63526. backUVs?: Vector4;
  63527. updatable?: boolean;
  63528. }, scene?: Nullable<Scene>): Mesh;
  63529. /**
  63530. * Creates a plane mesh
  63531. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63532. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63533. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63535. * * 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
  63536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63537. * @param name defines the name of the mesh
  63538. * @param options defines the options used to create the mesh
  63539. * @param scene defines the hosting scene
  63540. * @returns the plane mesh
  63541. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63542. */
  63543. static CreatePlane(name: string, options: {
  63544. size?: number;
  63545. width?: number;
  63546. height?: number;
  63547. sideOrientation?: number;
  63548. frontUVs?: Vector4;
  63549. backUVs?: Vector4;
  63550. updatable?: boolean;
  63551. sourcePlane?: Plane;
  63552. }, scene?: Nullable<Scene>): Mesh;
  63553. /**
  63554. * Creates a ground mesh
  63555. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63556. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63558. * @param name defines the name of the mesh
  63559. * @param options defines the options used to create the mesh
  63560. * @param scene defines the hosting scene
  63561. * @returns the ground mesh
  63562. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63563. */
  63564. static CreateGround(name: string, options: {
  63565. width?: number;
  63566. height?: number;
  63567. subdivisions?: number;
  63568. subdivisionsX?: number;
  63569. subdivisionsY?: number;
  63570. updatable?: boolean;
  63571. }, scene?: Nullable<Scene>): Mesh;
  63572. /**
  63573. * Creates a tiled ground mesh
  63574. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63575. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63576. * * 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
  63577. * * 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
  63578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63579. * @param name defines the name of the mesh
  63580. * @param options defines the options used to create the mesh
  63581. * @param scene defines the hosting scene
  63582. * @returns the tiled ground mesh
  63583. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63584. */
  63585. static CreateTiledGround(name: string, options: {
  63586. xmin: number;
  63587. zmin: number;
  63588. xmax: number;
  63589. zmax: number;
  63590. subdivisions?: {
  63591. w: number;
  63592. h: number;
  63593. };
  63594. precision?: {
  63595. w: number;
  63596. h: number;
  63597. };
  63598. updatable?: boolean;
  63599. }, scene?: Nullable<Scene>): Mesh;
  63600. /**
  63601. * Creates a ground mesh from a height map
  63602. * * The parameter `url` sets the URL of the height map image resource.
  63603. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63604. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63605. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63606. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63607. * * 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.
  63608. * * 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).
  63609. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63611. * @param name defines the name of the mesh
  63612. * @param url defines the url to the height map
  63613. * @param options defines the options used to create the mesh
  63614. * @param scene defines the hosting scene
  63615. * @returns the ground mesh
  63616. * @see https://doc.babylonjs.com/babylon101/height_map
  63617. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63618. */
  63619. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63620. width?: number;
  63621. height?: number;
  63622. subdivisions?: number;
  63623. minHeight?: number;
  63624. maxHeight?: number;
  63625. colorFilter?: Color3;
  63626. alphaFilter?: number;
  63627. updatable?: boolean;
  63628. onReady?: (mesh: GroundMesh) => void;
  63629. }, scene?: Nullable<Scene>): GroundMesh;
  63630. /**
  63631. * Creates a polygon mesh
  63632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63633. * * 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
  63634. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63636. * * 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)
  63637. * * Remember you can only change the shape positions, not their number when updating a polygon
  63638. * @param name defines the name of the mesh
  63639. * @param options defines the options used to create the mesh
  63640. * @param scene defines the hosting scene
  63641. * @param earcutInjection can be used to inject your own earcut reference
  63642. * @returns the polygon mesh
  63643. */
  63644. static CreatePolygon(name: string, options: {
  63645. shape: Vector3[];
  63646. holes?: Vector3[][];
  63647. depth?: number;
  63648. faceUV?: Vector4[];
  63649. faceColors?: Color4[];
  63650. updatable?: boolean;
  63651. sideOrientation?: number;
  63652. frontUVs?: Vector4;
  63653. backUVs?: Vector4;
  63654. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63655. /**
  63656. * Creates an extruded polygon mesh, with depth in the Y direction.
  63657. * * 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)
  63658. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63659. * @param name defines the name of the mesh
  63660. * @param options defines the options used to create the mesh
  63661. * @param scene defines the hosting scene
  63662. * @param earcutInjection can be used to inject your own earcut reference
  63663. * @returns the polygon mesh
  63664. */
  63665. static ExtrudePolygon(name: string, options: {
  63666. shape: Vector3[];
  63667. holes?: Vector3[][];
  63668. depth?: number;
  63669. faceUV?: Vector4[];
  63670. faceColors?: Color4[];
  63671. updatable?: boolean;
  63672. sideOrientation?: number;
  63673. frontUVs?: Vector4;
  63674. backUVs?: Vector4;
  63675. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63676. /**
  63677. * Creates a tube mesh.
  63678. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63679. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63680. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63681. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63682. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63683. * * 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)
  63684. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63685. * * 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
  63686. * * 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
  63687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63688. * * 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
  63689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63691. * @param name defines the name of the mesh
  63692. * @param options defines the options used to create the mesh
  63693. * @param scene defines the hosting scene
  63694. * @returns the tube mesh
  63695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63696. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63697. */
  63698. static CreateTube(name: string, options: {
  63699. path: Vector3[];
  63700. radius?: number;
  63701. tessellation?: number;
  63702. radiusFunction?: {
  63703. (i: number, distance: number): number;
  63704. };
  63705. cap?: number;
  63706. arc?: number;
  63707. updatable?: boolean;
  63708. sideOrientation?: number;
  63709. frontUVs?: Vector4;
  63710. backUVs?: Vector4;
  63711. instance?: Mesh;
  63712. invertUV?: boolean;
  63713. }, scene?: Nullable<Scene>): Mesh;
  63714. /**
  63715. * Creates a polyhedron mesh
  63716. * * 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
  63717. * * The parameter `size` (positive float, default 1) sets the polygon size
  63718. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63719. * * 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`
  63720. * * 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
  63721. * * 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)`)
  63722. * * 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
  63723. * * 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
  63724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63725. * * 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
  63726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63727. * @param name defines the name of the mesh
  63728. * @param options defines the options used to create the mesh
  63729. * @param scene defines the hosting scene
  63730. * @returns the polyhedron mesh
  63731. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63732. */
  63733. static CreatePolyhedron(name: string, options: {
  63734. type?: number;
  63735. size?: number;
  63736. sizeX?: number;
  63737. sizeY?: number;
  63738. sizeZ?: number;
  63739. custom?: any;
  63740. faceUV?: Vector4[];
  63741. faceColors?: Color4[];
  63742. flat?: boolean;
  63743. updatable?: boolean;
  63744. sideOrientation?: number;
  63745. frontUVs?: Vector4;
  63746. backUVs?: Vector4;
  63747. }, scene?: Nullable<Scene>): Mesh;
  63748. /**
  63749. * Creates a decal mesh.
  63750. * 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
  63751. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63752. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63753. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63754. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63755. * @param name defines the name of the mesh
  63756. * @param sourceMesh defines the mesh where the decal must be applied
  63757. * @param options defines the options used to create the mesh
  63758. * @param scene defines the hosting scene
  63759. * @returns the decal mesh
  63760. * @see https://doc.babylonjs.com/how_to/decals
  63761. */
  63762. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63763. position?: Vector3;
  63764. normal?: Vector3;
  63765. size?: Vector3;
  63766. angle?: number;
  63767. }): Mesh;
  63768. }
  63769. }
  63770. declare module BABYLON {
  63771. /**
  63772. * A simplifier interface for future simplification implementations
  63773. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63774. */
  63775. export interface ISimplifier {
  63776. /**
  63777. * Simplification of a given mesh according to the given settings.
  63778. * Since this requires computation, it is assumed that the function runs async.
  63779. * @param settings The settings of the simplification, including quality and distance
  63780. * @param successCallback A callback that will be called after the mesh was simplified.
  63781. * @param errorCallback in case of an error, this callback will be called. optional.
  63782. */
  63783. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63784. }
  63785. /**
  63786. * Expected simplification settings.
  63787. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63788. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63789. */
  63790. export interface ISimplificationSettings {
  63791. /**
  63792. * Gets or sets the expected quality
  63793. */
  63794. quality: number;
  63795. /**
  63796. * Gets or sets the distance when this optimized version should be used
  63797. */
  63798. distance: number;
  63799. /**
  63800. * Gets an already optimized mesh
  63801. */
  63802. optimizeMesh?: boolean;
  63803. }
  63804. /**
  63805. * Class used to specify simplification options
  63806. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63807. */
  63808. export class SimplificationSettings implements ISimplificationSettings {
  63809. /** expected quality */
  63810. quality: number;
  63811. /** distance when this optimized version should be used */
  63812. distance: number;
  63813. /** already optimized mesh */
  63814. optimizeMesh?: boolean | undefined;
  63815. /**
  63816. * Creates a SimplificationSettings
  63817. * @param quality expected quality
  63818. * @param distance distance when this optimized version should be used
  63819. * @param optimizeMesh already optimized mesh
  63820. */
  63821. constructor(
  63822. /** expected quality */
  63823. quality: number,
  63824. /** distance when this optimized version should be used */
  63825. distance: number,
  63826. /** already optimized mesh */
  63827. optimizeMesh?: boolean | undefined);
  63828. }
  63829. /**
  63830. * Interface used to define a simplification task
  63831. */
  63832. export interface ISimplificationTask {
  63833. /**
  63834. * Array of settings
  63835. */
  63836. settings: Array<ISimplificationSettings>;
  63837. /**
  63838. * Simplification type
  63839. */
  63840. simplificationType: SimplificationType;
  63841. /**
  63842. * Mesh to simplify
  63843. */
  63844. mesh: Mesh;
  63845. /**
  63846. * Callback called on success
  63847. */
  63848. successCallback?: () => void;
  63849. /**
  63850. * Defines if parallel processing can be used
  63851. */
  63852. parallelProcessing: boolean;
  63853. }
  63854. /**
  63855. * Queue used to order the simplification tasks
  63856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63857. */
  63858. export class SimplificationQueue {
  63859. private _simplificationArray;
  63860. /**
  63861. * Gets a boolean indicating that the process is still running
  63862. */
  63863. running: boolean;
  63864. /**
  63865. * Creates a new queue
  63866. */
  63867. constructor();
  63868. /**
  63869. * Adds a new simplification task
  63870. * @param task defines a task to add
  63871. */
  63872. addTask(task: ISimplificationTask): void;
  63873. /**
  63874. * Execute next task
  63875. */
  63876. executeNext(): void;
  63877. /**
  63878. * Execute a simplification task
  63879. * @param task defines the task to run
  63880. */
  63881. runSimplification(task: ISimplificationTask): void;
  63882. private getSimplifier;
  63883. }
  63884. /**
  63885. * The implemented types of simplification
  63886. * At the moment only Quadratic Error Decimation is implemented
  63887. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63888. */
  63889. export enum SimplificationType {
  63890. /** Quadratic error decimation */
  63891. QUADRATIC = 0
  63892. }
  63893. /**
  63894. * An implementation of the Quadratic Error simplification algorithm.
  63895. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  63896. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  63897. * @author RaananW
  63898. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63899. */
  63900. export class QuadraticErrorSimplification implements ISimplifier {
  63901. private _mesh;
  63902. private triangles;
  63903. private vertices;
  63904. private references;
  63905. private _reconstructedMesh;
  63906. /** Gets or sets the number pf sync interations */
  63907. syncIterations: number;
  63908. /** Gets or sets the aggressiveness of the simplifier */
  63909. aggressiveness: number;
  63910. /** Gets or sets the number of allowed iterations for decimation */
  63911. decimationIterations: number;
  63912. /** Gets or sets the espilon to use for bounding box computation */
  63913. boundingBoxEpsilon: number;
  63914. /**
  63915. * Creates a new QuadraticErrorSimplification
  63916. * @param _mesh defines the target mesh
  63917. */
  63918. constructor(_mesh: Mesh);
  63919. /**
  63920. * Simplification of a given mesh according to the given settings.
  63921. * Since this requires computation, it is assumed that the function runs async.
  63922. * @param settings The settings of the simplification, including quality and distance
  63923. * @param successCallback A callback that will be called after the mesh was simplified.
  63924. */
  63925. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  63926. private runDecimation;
  63927. private initWithMesh;
  63928. private init;
  63929. private reconstructMesh;
  63930. private initDecimatedMesh;
  63931. private isFlipped;
  63932. private updateTriangles;
  63933. private identifyBorder;
  63934. private updateMesh;
  63935. private vertexError;
  63936. private calculateError;
  63937. }
  63938. }
  63939. declare module BABYLON {
  63940. interface Scene {
  63941. /** @hidden (Backing field) */
  63942. _simplificationQueue: SimplificationQueue;
  63943. /**
  63944. * Gets or sets the simplification queue attached to the scene
  63945. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63946. */
  63947. simplificationQueue: SimplificationQueue;
  63948. }
  63949. interface Mesh {
  63950. /**
  63951. * Simplify the mesh according to the given array of settings.
  63952. * Function will return immediately and will simplify async
  63953. * @param settings a collection of simplification settings
  63954. * @param parallelProcessing should all levels calculate parallel or one after the other
  63955. * @param simplificationType the type of simplification to run
  63956. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63957. * @returns the current mesh
  63958. */
  63959. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63960. }
  63961. /**
  63962. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63963. * created in a scene
  63964. */
  63965. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63966. /**
  63967. * The component name helpfull to identify the component in the list of scene components.
  63968. */
  63969. readonly name: string;
  63970. /**
  63971. * The scene the component belongs to.
  63972. */
  63973. scene: Scene;
  63974. /**
  63975. * Creates a new instance of the component for the given scene
  63976. * @param scene Defines the scene to register the component in
  63977. */
  63978. constructor(scene: Scene);
  63979. /**
  63980. * Registers the component in a given scene
  63981. */
  63982. register(): void;
  63983. /**
  63984. * Rebuilds the elements related to this component in case of
  63985. * context lost for instance.
  63986. */
  63987. rebuild(): void;
  63988. /**
  63989. * Disposes the component and the associated ressources
  63990. */
  63991. dispose(): void;
  63992. private _beforeCameraUpdate;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63998. */
  63999. export interface INavigationEnginePlugin {
  64000. /**
  64001. * plugin name
  64002. */
  64003. name: string;
  64004. /**
  64005. * Creates a navigation mesh
  64006. * @param meshes array of all the geometry used to compute the navigatio mesh
  64007. * @param parameters bunch of parameters used to filter geometry
  64008. */
  64009. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64010. /**
  64011. * Create a navigation mesh debug mesh
  64012. * @param scene is where the mesh will be added
  64013. * @returns debug display mesh
  64014. */
  64015. createDebugNavMesh(scene: Scene): Mesh;
  64016. /**
  64017. * Get a navigation mesh constrained position, closest to the parameter position
  64018. * @param position world position
  64019. * @returns the closest point to position constrained by the navigation mesh
  64020. */
  64021. getClosestPoint(position: Vector3): Vector3;
  64022. /**
  64023. * Get a navigation mesh constrained position, closest to the parameter position
  64024. * @param position world position
  64025. * @param result output the closest point to position constrained by the navigation mesh
  64026. */
  64027. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64028. /**
  64029. * Get a navigation mesh constrained position, within a particular radius
  64030. * @param position world position
  64031. * @param maxRadius the maximum distance to the constrained world position
  64032. * @returns the closest point to position constrained by the navigation mesh
  64033. */
  64034. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64035. /**
  64036. * Get a navigation mesh constrained position, within a particular radius
  64037. * @param position world position
  64038. * @param maxRadius the maximum distance to the constrained world position
  64039. * @param result output the closest point to position constrained by the navigation mesh
  64040. */
  64041. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64042. /**
  64043. * Compute the final position from a segment made of destination-position
  64044. * @param position world position
  64045. * @param destination world position
  64046. * @returns the resulting point along the navmesh
  64047. */
  64048. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64049. /**
  64050. * Compute the final position from a segment made of destination-position
  64051. * @param position world position
  64052. * @param destination world position
  64053. * @param result output the resulting point along the navmesh
  64054. */
  64055. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64056. /**
  64057. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64058. * @param start world position
  64059. * @param end world position
  64060. * @returns array containing world position composing the path
  64061. */
  64062. computePath(start: Vector3, end: Vector3): Vector3[];
  64063. /**
  64064. * If this plugin is supported
  64065. * @returns true if plugin is supported
  64066. */
  64067. isSupported(): boolean;
  64068. /**
  64069. * Create a new Crowd so you can add agents
  64070. * @param maxAgents the maximum agent count in the crowd
  64071. * @param maxAgentRadius the maximum radius an agent can have
  64072. * @param scene to attach the crowd to
  64073. * @returns the crowd you can add agents to
  64074. */
  64075. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64076. /**
  64077. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64078. * The queries will try to find a solution within those bounds
  64079. * default is (1,1,1)
  64080. * @param extent x,y,z value that define the extent around the queries point of reference
  64081. */
  64082. setDefaultQueryExtent(extent: Vector3): void;
  64083. /**
  64084. * Get the Bounding box extent specified by setDefaultQueryExtent
  64085. * @returns the box extent values
  64086. */
  64087. getDefaultQueryExtent(): Vector3;
  64088. /**
  64089. * build the navmesh from a previously saved state using getNavmeshData
  64090. * @param data the Uint8Array returned by getNavmeshData
  64091. */
  64092. buildFromNavmeshData(data: Uint8Array): void;
  64093. /**
  64094. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64095. * @returns data the Uint8Array that can be saved and reused
  64096. */
  64097. getNavmeshData(): Uint8Array;
  64098. /**
  64099. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64100. * @param result output the box extent values
  64101. */
  64102. getDefaultQueryExtentToRef(result: Vector3): void;
  64103. /**
  64104. * Release all resources
  64105. */
  64106. dispose(): void;
  64107. }
  64108. /**
  64109. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64110. */
  64111. export interface ICrowd {
  64112. /**
  64113. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64114. * You can attach anything to that node. The node position is updated in the scene update tick.
  64115. * @param pos world position that will be constrained by the navigation mesh
  64116. * @param parameters agent parameters
  64117. * @param transform hooked to the agent that will be update by the scene
  64118. * @returns agent index
  64119. */
  64120. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64121. /**
  64122. * Returns the agent position in world space
  64123. * @param index agent index returned by addAgent
  64124. * @returns world space position
  64125. */
  64126. getAgentPosition(index: number): Vector3;
  64127. /**
  64128. * Gets the agent position result in world space
  64129. * @param index agent index returned by addAgent
  64130. * @param result output world space position
  64131. */
  64132. getAgentPositionToRef(index: number, result: Vector3): void;
  64133. /**
  64134. * Gets the agent velocity in world space
  64135. * @param index agent index returned by addAgent
  64136. * @returns world space velocity
  64137. */
  64138. getAgentVelocity(index: number): Vector3;
  64139. /**
  64140. * Gets the agent velocity result in world space
  64141. * @param index agent index returned by addAgent
  64142. * @param result output world space velocity
  64143. */
  64144. getAgentVelocityToRef(index: number, result: Vector3): void;
  64145. /**
  64146. * remove a particular agent previously created
  64147. * @param index agent index returned by addAgent
  64148. */
  64149. removeAgent(index: number): void;
  64150. /**
  64151. * get the list of all agents attached to this crowd
  64152. * @returns list of agent indices
  64153. */
  64154. getAgents(): number[];
  64155. /**
  64156. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64157. * @param deltaTime in seconds
  64158. */
  64159. update(deltaTime: number): void;
  64160. /**
  64161. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64162. * @param index agent index returned by addAgent
  64163. * @param destination targeted world position
  64164. */
  64165. agentGoto(index: number, destination: Vector3): void;
  64166. /**
  64167. * Teleport the agent to a new position
  64168. * @param index agent index returned by addAgent
  64169. * @param destination targeted world position
  64170. */
  64171. agentTeleport(index: number, destination: Vector3): void;
  64172. /**
  64173. * Update agent parameters
  64174. * @param index agent index returned by addAgent
  64175. * @param parameters agent parameters
  64176. */
  64177. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64178. /**
  64179. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64180. * The queries will try to find a solution within those bounds
  64181. * default is (1,1,1)
  64182. * @param extent x,y,z value that define the extent around the queries point of reference
  64183. */
  64184. setDefaultQueryExtent(extent: Vector3): void;
  64185. /**
  64186. * Get the Bounding box extent specified by setDefaultQueryExtent
  64187. * @returns the box extent values
  64188. */
  64189. getDefaultQueryExtent(): Vector3;
  64190. /**
  64191. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64192. * @param result output the box extent values
  64193. */
  64194. getDefaultQueryExtentToRef(result: Vector3): void;
  64195. /**
  64196. * Release all resources
  64197. */
  64198. dispose(): void;
  64199. }
  64200. /**
  64201. * Configures an agent
  64202. */
  64203. export interface IAgentParameters {
  64204. /**
  64205. * Agent radius. [Limit: >= 0]
  64206. */
  64207. radius: number;
  64208. /**
  64209. * Agent height. [Limit: > 0]
  64210. */
  64211. height: number;
  64212. /**
  64213. * Maximum allowed acceleration. [Limit: >= 0]
  64214. */
  64215. maxAcceleration: number;
  64216. /**
  64217. * Maximum allowed speed. [Limit: >= 0]
  64218. */
  64219. maxSpeed: number;
  64220. /**
  64221. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64222. */
  64223. collisionQueryRange: number;
  64224. /**
  64225. * The path visibility optimization range. [Limit: > 0]
  64226. */
  64227. pathOptimizationRange: number;
  64228. /**
  64229. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64230. */
  64231. separationWeight: number;
  64232. }
  64233. /**
  64234. * Configures the navigation mesh creation
  64235. */
  64236. export interface INavMeshParameters {
  64237. /**
  64238. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64239. */
  64240. cs: number;
  64241. /**
  64242. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64243. */
  64244. ch: number;
  64245. /**
  64246. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64247. */
  64248. walkableSlopeAngle: number;
  64249. /**
  64250. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64251. * be considered walkable. [Limit: >= 3] [Units: vx]
  64252. */
  64253. walkableHeight: number;
  64254. /**
  64255. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64256. */
  64257. walkableClimb: number;
  64258. /**
  64259. * The distance to erode/shrink the walkable area of the heightfield away from
  64260. * obstructions. [Limit: >=0] [Units: vx]
  64261. */
  64262. walkableRadius: number;
  64263. /**
  64264. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64265. */
  64266. maxEdgeLen: number;
  64267. /**
  64268. * The maximum distance a simplfied contour's border edges should deviate
  64269. * the original raw contour. [Limit: >=0] [Units: vx]
  64270. */
  64271. maxSimplificationError: number;
  64272. /**
  64273. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64274. */
  64275. minRegionArea: number;
  64276. /**
  64277. * Any regions with a span count smaller than this value will, if possible,
  64278. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64279. */
  64280. mergeRegionArea: number;
  64281. /**
  64282. * The maximum number of vertices allowed for polygons generated during the
  64283. * contour to polygon conversion process. [Limit: >= 3]
  64284. */
  64285. maxVertsPerPoly: number;
  64286. /**
  64287. * Sets the sampling distance to use when generating the detail mesh.
  64288. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64289. */
  64290. detailSampleDist: number;
  64291. /**
  64292. * The maximum distance the detail mesh surface should deviate from heightfield
  64293. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64294. */
  64295. detailSampleMaxError: number;
  64296. }
  64297. }
  64298. declare module BABYLON {
  64299. /**
  64300. * RecastJS navigation plugin
  64301. */
  64302. export class RecastJSPlugin implements INavigationEnginePlugin {
  64303. /**
  64304. * Reference to the Recast library
  64305. */
  64306. bjsRECAST: any;
  64307. /**
  64308. * plugin name
  64309. */
  64310. name: string;
  64311. /**
  64312. * the first navmesh created. We might extend this to support multiple navmeshes
  64313. */
  64314. navMesh: any;
  64315. /**
  64316. * Initializes the recastJS plugin
  64317. * @param recastInjection can be used to inject your own recast reference
  64318. */
  64319. constructor(recastInjection?: any);
  64320. /**
  64321. * Creates a navigation mesh
  64322. * @param meshes array of all the geometry used to compute the navigatio mesh
  64323. * @param parameters bunch of parameters used to filter geometry
  64324. */
  64325. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64326. /**
  64327. * Create a navigation mesh debug mesh
  64328. * @param scene is where the mesh will be added
  64329. * @returns debug display mesh
  64330. */
  64331. createDebugNavMesh(scene: Scene): Mesh;
  64332. /**
  64333. * Get a navigation mesh constrained position, closest to the parameter position
  64334. * @param position world position
  64335. * @returns the closest point to position constrained by the navigation mesh
  64336. */
  64337. getClosestPoint(position: Vector3): Vector3;
  64338. /**
  64339. * Get a navigation mesh constrained position, closest to the parameter position
  64340. * @param position world position
  64341. * @param result output the closest point to position constrained by the navigation mesh
  64342. */
  64343. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64344. /**
  64345. * Get a navigation mesh constrained position, within a particular radius
  64346. * @param position world position
  64347. * @param maxRadius the maximum distance to the constrained world position
  64348. * @returns the closest point to position constrained by the navigation mesh
  64349. */
  64350. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64351. /**
  64352. * Get a navigation mesh constrained position, within a particular radius
  64353. * @param position world position
  64354. * @param maxRadius the maximum distance to the constrained world position
  64355. * @param result output the closest point to position constrained by the navigation mesh
  64356. */
  64357. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64358. /**
  64359. * Compute the final position from a segment made of destination-position
  64360. * @param position world position
  64361. * @param destination world position
  64362. * @returns the resulting point along the navmesh
  64363. */
  64364. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64365. /**
  64366. * Compute the final position from a segment made of destination-position
  64367. * @param position world position
  64368. * @param destination world position
  64369. * @param result output the resulting point along the navmesh
  64370. */
  64371. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64372. /**
  64373. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64374. * @param start world position
  64375. * @param end world position
  64376. * @returns array containing world position composing the path
  64377. */
  64378. computePath(start: Vector3, end: Vector3): Vector3[];
  64379. /**
  64380. * Create a new Crowd so you can add agents
  64381. * @param maxAgents the maximum agent count in the crowd
  64382. * @param maxAgentRadius the maximum radius an agent can have
  64383. * @param scene to attach the crowd to
  64384. * @returns the crowd you can add agents to
  64385. */
  64386. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64387. /**
  64388. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64389. * The queries will try to find a solution within those bounds
  64390. * default is (1,1,1)
  64391. * @param extent x,y,z value that define the extent around the queries point of reference
  64392. */
  64393. setDefaultQueryExtent(extent: Vector3): void;
  64394. /**
  64395. * Get the Bounding box extent specified by setDefaultQueryExtent
  64396. * @returns the box extent values
  64397. */
  64398. getDefaultQueryExtent(): Vector3;
  64399. /**
  64400. * build the navmesh from a previously saved state using getNavmeshData
  64401. * @param data the Uint8Array returned by getNavmeshData
  64402. */
  64403. buildFromNavmeshData(data: Uint8Array): void;
  64404. /**
  64405. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64406. * @returns data the Uint8Array that can be saved and reused
  64407. */
  64408. getNavmeshData(): Uint8Array;
  64409. /**
  64410. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64411. * @param result output the box extent values
  64412. */
  64413. getDefaultQueryExtentToRef(result: Vector3): void;
  64414. /**
  64415. * Disposes
  64416. */
  64417. dispose(): void;
  64418. /**
  64419. * If this plugin is supported
  64420. * @returns true if plugin is supported
  64421. */
  64422. isSupported(): boolean;
  64423. }
  64424. /**
  64425. * Recast detour crowd implementation
  64426. */
  64427. export class RecastJSCrowd implements ICrowd {
  64428. /**
  64429. * Recast/detour plugin
  64430. */
  64431. bjsRECASTPlugin: RecastJSPlugin;
  64432. /**
  64433. * Link to the detour crowd
  64434. */
  64435. recastCrowd: any;
  64436. /**
  64437. * One transform per agent
  64438. */
  64439. transforms: TransformNode[];
  64440. /**
  64441. * All agents created
  64442. */
  64443. agents: number[];
  64444. /**
  64445. * Link to the scene is kept to unregister the crowd from the scene
  64446. */
  64447. private _scene;
  64448. /**
  64449. * Observer for crowd updates
  64450. */
  64451. private _onBeforeAnimationsObserver;
  64452. /**
  64453. * Constructor
  64454. * @param plugin recastJS plugin
  64455. * @param maxAgents the maximum agent count in the crowd
  64456. * @param maxAgentRadius the maximum radius an agent can have
  64457. * @param scene to attach the crowd to
  64458. * @returns the crowd you can add agents to
  64459. */
  64460. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64461. /**
  64462. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64463. * You can attach anything to that node. The node position is updated in the scene update tick.
  64464. * @param pos world position that will be constrained by the navigation mesh
  64465. * @param parameters agent parameters
  64466. * @param transform hooked to the agent that will be update by the scene
  64467. * @returns agent index
  64468. */
  64469. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64470. /**
  64471. * Returns the agent position in world space
  64472. * @param index agent index returned by addAgent
  64473. * @returns world space position
  64474. */
  64475. getAgentPosition(index: number): Vector3;
  64476. /**
  64477. * Returns the agent position result in world space
  64478. * @param index agent index returned by addAgent
  64479. * @param result output world space position
  64480. */
  64481. getAgentPositionToRef(index: number, result: Vector3): void;
  64482. /**
  64483. * Returns the agent velocity in world space
  64484. * @param index agent index returned by addAgent
  64485. * @returns world space velocity
  64486. */
  64487. getAgentVelocity(index: number): Vector3;
  64488. /**
  64489. * Returns the agent velocity result in world space
  64490. * @param index agent index returned by addAgent
  64491. * @param result output world space velocity
  64492. */
  64493. getAgentVelocityToRef(index: number, result: Vector3): void;
  64494. /**
  64495. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64496. * @param index agent index returned by addAgent
  64497. * @param destination targeted world position
  64498. */
  64499. agentGoto(index: number, destination: Vector3): void;
  64500. /**
  64501. * Teleport the agent to a new position
  64502. * @param index agent index returned by addAgent
  64503. * @param destination targeted world position
  64504. */
  64505. agentTeleport(index: number, destination: Vector3): void;
  64506. /**
  64507. * Update agent parameters
  64508. * @param index agent index returned by addAgent
  64509. * @param parameters agent parameters
  64510. */
  64511. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64512. /**
  64513. * remove a particular agent previously created
  64514. * @param index agent index returned by addAgent
  64515. */
  64516. removeAgent(index: number): void;
  64517. /**
  64518. * get the list of all agents attached to this crowd
  64519. * @returns list of agent indices
  64520. */
  64521. getAgents(): number[];
  64522. /**
  64523. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64524. * @param deltaTime in seconds
  64525. */
  64526. update(deltaTime: number): void;
  64527. /**
  64528. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64529. * The queries will try to find a solution within those bounds
  64530. * default is (1,1,1)
  64531. * @param extent x,y,z value that define the extent around the queries point of reference
  64532. */
  64533. setDefaultQueryExtent(extent: Vector3): void;
  64534. /**
  64535. * Get the Bounding box extent specified by setDefaultQueryExtent
  64536. * @returns the box extent values
  64537. */
  64538. getDefaultQueryExtent(): Vector3;
  64539. /**
  64540. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64541. * @param result output the box extent values
  64542. */
  64543. getDefaultQueryExtentToRef(result: Vector3): void;
  64544. /**
  64545. * Release all resources
  64546. */
  64547. dispose(): void;
  64548. }
  64549. }
  64550. declare module BABYLON {
  64551. /**
  64552. * Class used to enable access to IndexedDB
  64553. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64554. */
  64555. export class Database implements IOfflineProvider {
  64556. private _callbackManifestChecked;
  64557. private _currentSceneUrl;
  64558. private _db;
  64559. private _enableSceneOffline;
  64560. private _enableTexturesOffline;
  64561. private _manifestVersionFound;
  64562. private _mustUpdateRessources;
  64563. private _hasReachedQuota;
  64564. private _isSupported;
  64565. private _idbFactory;
  64566. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64567. private static IsUASupportingBlobStorage;
  64568. /**
  64569. * Gets a boolean indicating if Database storate is enabled (off by default)
  64570. */
  64571. static IDBStorageEnabled: boolean;
  64572. /**
  64573. * Gets a boolean indicating if scene must be saved in the database
  64574. */
  64575. get enableSceneOffline(): boolean;
  64576. /**
  64577. * Gets a boolean indicating if textures must be saved in the database
  64578. */
  64579. get enableTexturesOffline(): boolean;
  64580. /**
  64581. * Creates a new Database
  64582. * @param urlToScene defines the url to load the scene
  64583. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64584. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64585. */
  64586. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64587. private static _ParseURL;
  64588. private static _ReturnFullUrlLocation;
  64589. private _checkManifestFile;
  64590. /**
  64591. * Open the database and make it available
  64592. * @param successCallback defines the callback to call on success
  64593. * @param errorCallback defines the callback to call on error
  64594. */
  64595. open(successCallback: () => void, errorCallback: () => void): void;
  64596. /**
  64597. * Loads an image from the database
  64598. * @param url defines the url to load from
  64599. * @param image defines the target DOM image
  64600. */
  64601. loadImage(url: string, image: HTMLImageElement): void;
  64602. private _loadImageFromDBAsync;
  64603. private _saveImageIntoDBAsync;
  64604. private _checkVersionFromDB;
  64605. private _loadVersionFromDBAsync;
  64606. private _saveVersionIntoDBAsync;
  64607. /**
  64608. * Loads a file from database
  64609. * @param url defines the URL to load from
  64610. * @param sceneLoaded defines a callback to call on success
  64611. * @param progressCallBack defines a callback to call when progress changed
  64612. * @param errorCallback defines a callback to call on error
  64613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64614. */
  64615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64616. private _loadFileAsync;
  64617. private _saveFileAsync;
  64618. /**
  64619. * Validates if xhr data is correct
  64620. * @param xhr defines the request to validate
  64621. * @param dataType defines the expected data type
  64622. * @returns true if data is correct
  64623. */
  64624. private static _ValidateXHRData;
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /** @hidden */
  64629. export var gpuUpdateParticlesPixelShader: {
  64630. name: string;
  64631. shader: string;
  64632. };
  64633. }
  64634. declare module BABYLON {
  64635. /** @hidden */
  64636. export var gpuUpdateParticlesVertexShader: {
  64637. name: string;
  64638. shader: string;
  64639. };
  64640. }
  64641. declare module BABYLON {
  64642. /** @hidden */
  64643. export var clipPlaneFragmentDeclaration2: {
  64644. name: string;
  64645. shader: string;
  64646. };
  64647. }
  64648. declare module BABYLON {
  64649. /** @hidden */
  64650. export var gpuRenderParticlesPixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module BABYLON {
  64656. /** @hidden */
  64657. export var clipPlaneVertexDeclaration2: {
  64658. name: string;
  64659. shader: string;
  64660. };
  64661. }
  64662. declare module BABYLON {
  64663. /** @hidden */
  64664. export var gpuRenderParticlesVertexShader: {
  64665. name: string;
  64666. shader: string;
  64667. };
  64668. }
  64669. declare module BABYLON {
  64670. /**
  64671. * This represents a GPU particle system in Babylon
  64672. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64673. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64674. */
  64675. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64676. /**
  64677. * The layer mask we are rendering the particles through.
  64678. */
  64679. layerMask: number;
  64680. private _capacity;
  64681. private _activeCount;
  64682. private _currentActiveCount;
  64683. private _accumulatedCount;
  64684. private _renderEffect;
  64685. private _updateEffect;
  64686. private _buffer0;
  64687. private _buffer1;
  64688. private _spriteBuffer;
  64689. private _updateVAO;
  64690. private _renderVAO;
  64691. private _targetIndex;
  64692. private _sourceBuffer;
  64693. private _targetBuffer;
  64694. private _engine;
  64695. private _currentRenderId;
  64696. private _started;
  64697. private _stopped;
  64698. private _timeDelta;
  64699. private _randomTexture;
  64700. private _randomTexture2;
  64701. private _attributesStrideSize;
  64702. private _updateEffectOptions;
  64703. private _randomTextureSize;
  64704. private _actualFrame;
  64705. private readonly _rawTextureWidth;
  64706. /**
  64707. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64708. */
  64709. static get IsSupported(): boolean;
  64710. /**
  64711. * An event triggered when the system is disposed.
  64712. */
  64713. onDisposeObservable: Observable<GPUParticleSystem>;
  64714. /**
  64715. * Gets the maximum number of particles active at the same time.
  64716. * @returns The max number of active particles.
  64717. */
  64718. getCapacity(): number;
  64719. /**
  64720. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64721. * to override the particles.
  64722. */
  64723. forceDepthWrite: boolean;
  64724. /**
  64725. * Gets or set the number of active particles
  64726. */
  64727. get activeParticleCount(): number;
  64728. set activeParticleCount(value: number);
  64729. private _preWarmDone;
  64730. /**
  64731. * Specifies if the particles are updated in emitter local space or world space.
  64732. */
  64733. isLocal: boolean;
  64734. /**
  64735. * Is this system ready to be used/rendered
  64736. * @return true if the system is ready
  64737. */
  64738. isReady(): boolean;
  64739. /**
  64740. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64741. * @returns True if it has been started, otherwise false.
  64742. */
  64743. isStarted(): boolean;
  64744. /**
  64745. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  64746. * @returns True if it has been stopped, otherwise false.
  64747. */
  64748. isStopped(): boolean;
  64749. /**
  64750. * Gets a boolean indicating that the system is stopping
  64751. * @returns true if the system is currently stopping
  64752. */
  64753. isStopping(): boolean;
  64754. /**
  64755. * Gets the number of particles active at the same time.
  64756. * @returns The number of active particles.
  64757. */
  64758. getActiveCount(): number;
  64759. /**
  64760. * Starts the particle system and begins to emit
  64761. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64762. */
  64763. start(delay?: number): void;
  64764. /**
  64765. * Stops the particle system.
  64766. */
  64767. stop(): void;
  64768. /**
  64769. * Remove all active particles
  64770. */
  64771. reset(): void;
  64772. /**
  64773. * Returns the string "GPUParticleSystem"
  64774. * @returns a string containing the class name
  64775. */
  64776. getClassName(): string;
  64777. private _colorGradientsTexture;
  64778. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64779. /**
  64780. * Adds a new color gradient
  64781. * @param gradient defines the gradient to use (between 0 and 1)
  64782. * @param color1 defines the color to affect to the specified gradient
  64783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64784. * @returns the current particle system
  64785. */
  64786. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64787. private _refreshColorGradient;
  64788. /** Force the system to rebuild all gradients that need to be resync */
  64789. forceRefreshGradients(): void;
  64790. /**
  64791. * Remove a specific color gradient
  64792. * @param gradient defines the gradient to remove
  64793. * @returns the current particle system
  64794. */
  64795. removeColorGradient(gradient: number): GPUParticleSystem;
  64796. private _angularSpeedGradientsTexture;
  64797. private _sizeGradientsTexture;
  64798. private _velocityGradientsTexture;
  64799. private _limitVelocityGradientsTexture;
  64800. private _dragGradientsTexture;
  64801. private _addFactorGradient;
  64802. /**
  64803. * Adds a new size gradient
  64804. * @param gradient defines the gradient to use (between 0 and 1)
  64805. * @param factor defines the size factor to affect to the specified gradient
  64806. * @returns the current particle system
  64807. */
  64808. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64809. /**
  64810. * Remove a specific size gradient
  64811. * @param gradient defines the gradient to remove
  64812. * @returns the current particle system
  64813. */
  64814. removeSizeGradient(gradient: number): GPUParticleSystem;
  64815. private _refreshFactorGradient;
  64816. /**
  64817. * Adds a new angular speed gradient
  64818. * @param gradient defines the gradient to use (between 0 and 1)
  64819. * @param factor defines the angular speed to affect to the specified gradient
  64820. * @returns the current particle system
  64821. */
  64822. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64823. /**
  64824. * Remove a specific angular speed gradient
  64825. * @param gradient defines the gradient to remove
  64826. * @returns the current particle system
  64827. */
  64828. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64829. /**
  64830. * Adds a new velocity gradient
  64831. * @param gradient defines the gradient to use (between 0 and 1)
  64832. * @param factor defines the velocity to affect to the specified gradient
  64833. * @returns the current particle system
  64834. */
  64835. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64836. /**
  64837. * Remove a specific velocity gradient
  64838. * @param gradient defines the gradient to remove
  64839. * @returns the current particle system
  64840. */
  64841. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64842. /**
  64843. * Adds a new limit velocity gradient
  64844. * @param gradient defines the gradient to use (between 0 and 1)
  64845. * @param factor defines the limit velocity value to affect to the specified gradient
  64846. * @returns the current particle system
  64847. */
  64848. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64849. /**
  64850. * Remove a specific limit velocity gradient
  64851. * @param gradient defines the gradient to remove
  64852. * @returns the current particle system
  64853. */
  64854. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64855. /**
  64856. * Adds a new drag gradient
  64857. * @param gradient defines the gradient to use (between 0 and 1)
  64858. * @param factor defines the drag value to affect to the specified gradient
  64859. * @returns the current particle system
  64860. */
  64861. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64862. /**
  64863. * Remove a specific drag gradient
  64864. * @param gradient defines the gradient to remove
  64865. * @returns the current particle system
  64866. */
  64867. removeDragGradient(gradient: number): GPUParticleSystem;
  64868. /**
  64869. * Not supported by GPUParticleSystem
  64870. * @param gradient defines the gradient to use (between 0 and 1)
  64871. * @param factor defines the emit rate value to affect to the specified gradient
  64872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64873. * @returns the current particle system
  64874. */
  64875. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64876. /**
  64877. * Not supported by GPUParticleSystem
  64878. * @param gradient defines the gradient to remove
  64879. * @returns the current particle system
  64880. */
  64881. removeEmitRateGradient(gradient: number): IParticleSystem;
  64882. /**
  64883. * Not supported by GPUParticleSystem
  64884. * @param gradient defines the gradient to use (between 0 and 1)
  64885. * @param factor defines the start size value to affect to the specified gradient
  64886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64887. * @returns the current particle system
  64888. */
  64889. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64890. /**
  64891. * Not supported by GPUParticleSystem
  64892. * @param gradient defines the gradient to remove
  64893. * @returns the current particle system
  64894. */
  64895. removeStartSizeGradient(gradient: number): IParticleSystem;
  64896. /**
  64897. * Not supported by GPUParticleSystem
  64898. * @param gradient defines the gradient to use (between 0 and 1)
  64899. * @param min defines the color remap minimal range
  64900. * @param max defines the color remap maximal range
  64901. * @returns the current particle system
  64902. */
  64903. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64904. /**
  64905. * Not supported by GPUParticleSystem
  64906. * @param gradient defines the gradient to remove
  64907. * @returns the current particle system
  64908. */
  64909. removeColorRemapGradient(): IParticleSystem;
  64910. /**
  64911. * Not supported by GPUParticleSystem
  64912. * @param gradient defines the gradient to use (between 0 and 1)
  64913. * @param min defines the alpha remap minimal range
  64914. * @param max defines the alpha remap maximal range
  64915. * @returns the current particle system
  64916. */
  64917. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64918. /**
  64919. * Not supported by GPUParticleSystem
  64920. * @param gradient defines the gradient to remove
  64921. * @returns the current particle system
  64922. */
  64923. removeAlphaRemapGradient(): IParticleSystem;
  64924. /**
  64925. * Not supported by GPUParticleSystem
  64926. * @param gradient defines the gradient to use (between 0 and 1)
  64927. * @param color defines the color to affect to the specified gradient
  64928. * @returns the current particle system
  64929. */
  64930. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64931. /**
  64932. * Not supported by GPUParticleSystem
  64933. * @param gradient defines the gradient to remove
  64934. * @returns the current particle system
  64935. */
  64936. removeRampGradient(): IParticleSystem;
  64937. /**
  64938. * Not supported by GPUParticleSystem
  64939. * @returns the list of ramp gradients
  64940. */
  64941. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64942. /**
  64943. * Not supported by GPUParticleSystem
  64944. * Gets or sets a boolean indicating that ramp gradients must be used
  64945. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64946. */
  64947. get useRampGradients(): boolean;
  64948. set useRampGradients(value: boolean);
  64949. /**
  64950. * Not supported by GPUParticleSystem
  64951. * @param gradient defines the gradient to use (between 0 and 1)
  64952. * @param factor defines the life time factor to affect to the specified gradient
  64953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64954. * @returns the current particle system
  64955. */
  64956. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64957. /**
  64958. * Not supported by GPUParticleSystem
  64959. * @param gradient defines the gradient to remove
  64960. * @returns the current particle system
  64961. */
  64962. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64963. /**
  64964. * Instantiates a GPU particle system.
  64965. * 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.
  64966. * @param name The name of the particle system
  64967. * @param options The options used to create the system
  64968. * @param scene The scene the particle system belongs to
  64969. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64970. */
  64971. constructor(name: string, options: Partial<{
  64972. capacity: number;
  64973. randomTextureSize: number;
  64974. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64975. protected _reset(): void;
  64976. private _createUpdateVAO;
  64977. private _createRenderVAO;
  64978. private _initialize;
  64979. /** @hidden */
  64980. _recreateUpdateEffect(): void;
  64981. /** @hidden */
  64982. _recreateRenderEffect(): void;
  64983. /**
  64984. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64985. * @param preWarm defines if we are in the pre-warmimg phase
  64986. */
  64987. animate(preWarm?: boolean): void;
  64988. private _createFactorGradientTexture;
  64989. private _createSizeGradientTexture;
  64990. private _createAngularSpeedGradientTexture;
  64991. private _createVelocityGradientTexture;
  64992. private _createLimitVelocityGradientTexture;
  64993. private _createDragGradientTexture;
  64994. private _createColorGradientTexture;
  64995. /**
  64996. * Renders the particle system in its current state
  64997. * @param preWarm defines if the system should only update the particles but not render them
  64998. * @returns the current number of particles
  64999. */
  65000. render(preWarm?: boolean): number;
  65001. /**
  65002. * Rebuilds the particle system
  65003. */
  65004. rebuild(): void;
  65005. private _releaseBuffers;
  65006. private _releaseVAOs;
  65007. /**
  65008. * Disposes the particle system and free the associated resources
  65009. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65010. */
  65011. dispose(disposeTexture?: boolean): void;
  65012. /**
  65013. * Clones the particle system.
  65014. * @param name The name of the cloned object
  65015. * @param newEmitter The new emitter to use
  65016. * @returns the cloned particle system
  65017. */
  65018. clone(name: string, newEmitter: any): GPUParticleSystem;
  65019. /**
  65020. * Serializes the particle system to a JSON object
  65021. * @param serializeTexture defines if the texture must be serialized as well
  65022. * @returns the JSON object
  65023. */
  65024. serialize(serializeTexture?: boolean): any;
  65025. /**
  65026. * Parses a JSON object to create a GPU particle system.
  65027. * @param parsedParticleSystem The JSON object to parse
  65028. * @param scene The scene to create the particle system in
  65029. * @param rootUrl The root url to use to load external dependencies like texture
  65030. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65031. * @returns the parsed GPU particle system
  65032. */
  65033. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65034. }
  65035. }
  65036. declare module BABYLON {
  65037. /**
  65038. * Represents a set of particle systems working together to create a specific effect
  65039. */
  65040. export class ParticleSystemSet implements IDisposable {
  65041. /**
  65042. * Gets or sets base Assets URL
  65043. */
  65044. static BaseAssetsUrl: string;
  65045. private _emitterCreationOptions;
  65046. private _emitterNode;
  65047. /**
  65048. * Gets the particle system list
  65049. */
  65050. systems: IParticleSystem[];
  65051. /**
  65052. * Gets the emitter node used with this set
  65053. */
  65054. get emitterNode(): Nullable<TransformNode>;
  65055. /**
  65056. * Creates a new emitter mesh as a sphere
  65057. * @param options defines the options used to create the sphere
  65058. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65059. * @param scene defines the hosting scene
  65060. */
  65061. setEmitterAsSphere(options: {
  65062. diameter: number;
  65063. segments: number;
  65064. color: Color3;
  65065. }, renderingGroupId: number, scene: Scene): void;
  65066. /**
  65067. * Starts all particle systems of the set
  65068. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65069. */
  65070. start(emitter?: AbstractMesh): void;
  65071. /**
  65072. * Release all associated resources
  65073. */
  65074. dispose(): void;
  65075. /**
  65076. * Serialize the set into a JSON compatible object
  65077. * @param serializeTexture defines if the texture must be serialized as well
  65078. * @returns a JSON compatible representation of the set
  65079. */
  65080. serialize(serializeTexture?: boolean): any;
  65081. /**
  65082. * Parse a new ParticleSystemSet from a serialized source
  65083. * @param data defines a JSON compatible representation of the set
  65084. * @param scene defines the hosting scene
  65085. * @param gpu defines if we want GPU particles or CPU particles
  65086. * @returns a new ParticleSystemSet
  65087. */
  65088. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65089. }
  65090. }
  65091. declare module BABYLON {
  65092. /**
  65093. * This class is made for on one-liner static method to help creating particle system set.
  65094. */
  65095. export class ParticleHelper {
  65096. /**
  65097. * Gets or sets base Assets URL
  65098. */
  65099. static BaseAssetsUrl: string;
  65100. /** Define the Url to load snippets */
  65101. static SnippetUrl: string;
  65102. /**
  65103. * Create a default particle system that you can tweak
  65104. * @param emitter defines the emitter to use
  65105. * @param capacity defines the system capacity (default is 500 particles)
  65106. * @param scene defines the hosting scene
  65107. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65108. * @returns the new Particle system
  65109. */
  65110. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65111. /**
  65112. * This is the main static method (one-liner) of this helper to create different particle systems
  65113. * @param type This string represents the type to the particle system to create
  65114. * @param scene The scene where the particle system should live
  65115. * @param gpu If the system will use gpu
  65116. * @returns the ParticleSystemSet created
  65117. */
  65118. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65119. /**
  65120. * Static function used to export a particle system to a ParticleSystemSet variable.
  65121. * Please note that the emitter shape is not exported
  65122. * @param systems defines the particle systems to export
  65123. * @returns the created particle system set
  65124. */
  65125. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65126. /**
  65127. * Creates a particle system from a snippet saved in a remote file
  65128. * @param name defines the name of the particle system to create
  65129. * @param url defines the url to load from
  65130. * @param scene defines the hosting scene
  65131. * @param gpu If the system will use gpu
  65132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65133. * @returns a promise that will resolve to the new particle system
  65134. */
  65135. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65136. /**
  65137. * Creates a particle system from a snippet saved by the particle system editor
  65138. * @param snippetId defines the snippet to load
  65139. * @param scene defines the hosting scene
  65140. * @param gpu If the system will use gpu
  65141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65142. * @returns a promise that will resolve to the new particle system
  65143. */
  65144. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65145. }
  65146. }
  65147. declare module BABYLON {
  65148. interface Engine {
  65149. /**
  65150. * Create an effect to use with particle systems.
  65151. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65152. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65153. * @param uniformsNames defines a list of attribute names
  65154. * @param samplers defines an array of string used to represent textures
  65155. * @param defines defines the string containing the defines to use to compile the shaders
  65156. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65157. * @param onCompiled defines a function to call when the effect creation is successful
  65158. * @param onError defines a function to call when the effect creation has failed
  65159. * @returns the new Effect
  65160. */
  65161. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65162. }
  65163. interface Mesh {
  65164. /**
  65165. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65166. * @returns an array of IParticleSystem
  65167. */
  65168. getEmittedParticleSystems(): IParticleSystem[];
  65169. /**
  65170. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65171. * @returns an array of IParticleSystem
  65172. */
  65173. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65174. }
  65175. /**
  65176. * @hidden
  65177. */
  65178. export var _IDoNeedToBeInTheBuild: number;
  65179. }
  65180. declare module BABYLON {
  65181. /** Defines the 4 color options */
  65182. export enum PointColor {
  65183. /** color value */
  65184. Color = 2,
  65185. /** uv value */
  65186. UV = 1,
  65187. /** random value */
  65188. Random = 0,
  65189. /** stated value */
  65190. Stated = 3
  65191. }
  65192. /**
  65193. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65194. * 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.
  65195. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65196. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65197. *
  65198. * Full documentation here : TO BE ENTERED
  65199. */
  65200. export class PointsCloudSystem implements IDisposable {
  65201. /**
  65202. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65203. * Example : var p = SPS.particles[i];
  65204. */
  65205. particles: CloudPoint[];
  65206. /**
  65207. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65208. */
  65209. nbParticles: number;
  65210. /**
  65211. * This a counter for your own usage. It's not set by any SPS functions.
  65212. */
  65213. counter: number;
  65214. /**
  65215. * The PCS name. This name is also given to the underlying mesh.
  65216. */
  65217. name: string;
  65218. /**
  65219. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65220. */
  65221. mesh: Mesh;
  65222. /**
  65223. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65224. * Please read :
  65225. */
  65226. vars: any;
  65227. /**
  65228. * @hidden
  65229. */
  65230. _size: number;
  65231. private _scene;
  65232. private _promises;
  65233. private _positions;
  65234. private _indices;
  65235. private _normals;
  65236. private _colors;
  65237. private _uvs;
  65238. private _indices32;
  65239. private _positions32;
  65240. private _colors32;
  65241. private _uvs32;
  65242. private _updatable;
  65243. private _isVisibilityBoxLocked;
  65244. private _alwaysVisible;
  65245. private _groups;
  65246. private _groupCounter;
  65247. private _computeParticleColor;
  65248. private _computeParticleTexture;
  65249. private _computeParticleRotation;
  65250. private _computeBoundingBox;
  65251. private _isReady;
  65252. /**
  65253. * Creates a PCS (Points Cloud System) object
  65254. * @param name (String) is the PCS name, this will be the underlying mesh name
  65255. * @param pointSize (number) is the size for each point
  65256. * @param scene (Scene) is the scene in which the PCS is added
  65257. * @param options defines the options of the PCS e.g.
  65258. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65259. */
  65260. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65261. updatable?: boolean;
  65262. });
  65263. /**
  65264. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65265. * If no points were added to the PCS, the returned mesh is just a single point.
  65266. * @returns a promise for the created mesh
  65267. */
  65268. buildMeshAsync(): Promise<Mesh>;
  65269. /**
  65270. * @hidden
  65271. */
  65272. private _buildMesh;
  65273. private _addParticle;
  65274. private _randomUnitVector;
  65275. private _getColorIndicesForCoord;
  65276. private _setPointsColorOrUV;
  65277. private _colorFromTexture;
  65278. private _calculateDensity;
  65279. /**
  65280. * Adds points to the PCS in random positions within a unit sphere
  65281. * @param nb (positive integer) the number of particles to be created from this model
  65282. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65283. * @returns the number of groups in the system
  65284. */
  65285. addPoints(nb: number, pointFunction?: any): number;
  65286. /**
  65287. * Adds points to the PCS from the surface of the model shape
  65288. * @param mesh is any Mesh object that will be used as a surface model for the points
  65289. * @param nb (positive integer) the number of particles to be created from this model
  65290. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65291. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65292. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65293. * @returns the number of groups in the system
  65294. */
  65295. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65296. /**
  65297. * Adds points to the PCS inside the model shape
  65298. * @param mesh is any Mesh object that will be used as a surface model for the points
  65299. * @param nb (positive integer) the number of particles to be created from this model
  65300. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65301. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65302. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65303. * @returns the number of groups in the system
  65304. */
  65305. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65306. /**
  65307. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65308. * This method calls `updateParticle()` for each particle of the SPS.
  65309. * For an animated SPS, it is usually called within the render loop.
  65310. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65311. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65312. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65313. * @returns the PCS.
  65314. */
  65315. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65316. /**
  65317. * Disposes the PCS.
  65318. */
  65319. dispose(): void;
  65320. /**
  65321. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65322. * doc :
  65323. * @returns the PCS.
  65324. */
  65325. refreshVisibleSize(): PointsCloudSystem;
  65326. /**
  65327. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65328. * @param size the size (float) of the visibility box
  65329. * note : this doesn't lock the PCS mesh bounding box.
  65330. * doc :
  65331. */
  65332. setVisibilityBox(size: number): void;
  65333. /**
  65334. * Gets whether the PCS is always visible or not
  65335. * doc :
  65336. */
  65337. get isAlwaysVisible(): boolean;
  65338. /**
  65339. * Sets the PCS as always visible or not
  65340. * doc :
  65341. */
  65342. set isAlwaysVisible(val: boolean);
  65343. /**
  65344. * Tells to `setParticles()` to compute the particle rotations or not
  65345. * Default value : false. The PCS is faster when it's set to false
  65346. * Note : particle rotations are only applied to parent particles
  65347. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65348. */
  65349. set computeParticleRotation(val: boolean);
  65350. /**
  65351. * Tells to `setParticles()` to compute the particle colors or not.
  65352. * Default value : true. The PCS is faster when it's set to false.
  65353. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65354. */
  65355. set computeParticleColor(val: boolean);
  65356. set computeParticleTexture(val: boolean);
  65357. /**
  65358. * Gets if `setParticles()` computes the particle colors or not.
  65359. * Default value : false. The PCS is faster when it's set to false.
  65360. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65361. */
  65362. get computeParticleColor(): boolean;
  65363. /**
  65364. * Gets if `setParticles()` computes the particle textures or not.
  65365. * Default value : false. The PCS is faster when it's set to false.
  65366. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65367. */
  65368. get computeParticleTexture(): boolean;
  65369. /**
  65370. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65371. */
  65372. set computeBoundingBox(val: boolean);
  65373. /**
  65374. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65375. */
  65376. get computeBoundingBox(): boolean;
  65377. /**
  65378. * This function does nothing. It may be overwritten to set all the particle first values.
  65379. * The PCS doesn't call this function, you may have to call it by your own.
  65380. * doc :
  65381. */
  65382. initParticles(): void;
  65383. /**
  65384. * This function does nothing. It may be overwritten to recycle a particle
  65385. * The PCS doesn't call this function, you can to call it
  65386. * doc :
  65387. * @param particle The particle to recycle
  65388. * @returns the recycled particle
  65389. */
  65390. recycleParticle(particle: CloudPoint): CloudPoint;
  65391. /**
  65392. * Updates a particle : this function should be overwritten by the user.
  65393. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65394. * doc :
  65395. * @example : just set a particle position or velocity and recycle conditions
  65396. * @param particle The particle to update
  65397. * @returns the updated particle
  65398. */
  65399. updateParticle(particle: CloudPoint): CloudPoint;
  65400. /**
  65401. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65402. * This does nothing and may be overwritten by the user.
  65403. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65404. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65405. * @param update the boolean update value actually passed to setParticles()
  65406. */
  65407. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65408. /**
  65409. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65410. * This will be passed three parameters.
  65411. * This does nothing and may be overwritten by the user.
  65412. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65413. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65414. * @param update the boolean update value actually passed to setParticles()
  65415. */
  65416. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65417. }
  65418. }
  65419. declare module BABYLON {
  65420. /**
  65421. * Represents one particle of a points cloud system.
  65422. */
  65423. export class CloudPoint {
  65424. /**
  65425. * particle global index
  65426. */
  65427. idx: number;
  65428. /**
  65429. * The color of the particle
  65430. */
  65431. color: Nullable<Color4>;
  65432. /**
  65433. * The world space position of the particle.
  65434. */
  65435. position: Vector3;
  65436. /**
  65437. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65438. */
  65439. rotation: Vector3;
  65440. /**
  65441. * The world space rotation quaternion of the particle.
  65442. */
  65443. rotationQuaternion: Nullable<Quaternion>;
  65444. /**
  65445. * The uv of the particle.
  65446. */
  65447. uv: Nullable<Vector2>;
  65448. /**
  65449. * The current speed of the particle.
  65450. */
  65451. velocity: Vector3;
  65452. /**
  65453. * The pivot point in the particle local space.
  65454. */
  65455. pivot: Vector3;
  65456. /**
  65457. * Must the particle be translated from its pivot point in its local space ?
  65458. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65459. * Default : false
  65460. */
  65461. translateFromPivot: boolean;
  65462. /**
  65463. * Index of this particle in the global "positions" array (Internal use)
  65464. * @hidden
  65465. */
  65466. _pos: number;
  65467. /**
  65468. * @hidden Index of this particle in the global "indices" array (Internal use)
  65469. */
  65470. _ind: number;
  65471. /**
  65472. * Group this particle belongs to
  65473. */
  65474. _group: PointsGroup;
  65475. /**
  65476. * Group id of this particle
  65477. */
  65478. groupId: number;
  65479. /**
  65480. * Index of the particle in its group id (Internal use)
  65481. */
  65482. idxInGroup: number;
  65483. /**
  65484. * @hidden Particle BoundingInfo object (Internal use)
  65485. */
  65486. _boundingInfo: BoundingInfo;
  65487. /**
  65488. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65489. */
  65490. _pcs: PointsCloudSystem;
  65491. /**
  65492. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65493. */
  65494. _stillInvisible: boolean;
  65495. /**
  65496. * @hidden Last computed particle rotation matrix
  65497. */
  65498. _rotationMatrix: number[];
  65499. /**
  65500. * Parent particle Id, if any.
  65501. * Default null.
  65502. */
  65503. parentId: Nullable<number>;
  65504. /**
  65505. * @hidden Internal global position in the PCS.
  65506. */
  65507. _globalPosition: Vector3;
  65508. /**
  65509. * Creates a Point Cloud object.
  65510. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65511. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65512. * @param group (PointsGroup) is the group the particle belongs to
  65513. * @param groupId (integer) is the group identifier in the PCS.
  65514. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65515. * @param pcs defines the PCS it is associated to
  65516. */
  65517. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65518. /**
  65519. * get point size
  65520. */
  65521. get size(): Vector3;
  65522. /**
  65523. * Set point size
  65524. */
  65525. set size(scale: Vector3);
  65526. /**
  65527. * Legacy support, changed quaternion to rotationQuaternion
  65528. */
  65529. get quaternion(): Nullable<Quaternion>;
  65530. /**
  65531. * Legacy support, changed quaternion to rotationQuaternion
  65532. */
  65533. set quaternion(q: Nullable<Quaternion>);
  65534. /**
  65535. * Returns a boolean. True if the particle intersects a mesh, else false
  65536. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65537. * @param target is the object (point or mesh) what the intersection is computed against
  65538. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65539. * @returns true if it intersects
  65540. */
  65541. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65542. /**
  65543. * get the rotation matrix of the particle
  65544. * @hidden
  65545. */
  65546. getRotationMatrix(m: Matrix): void;
  65547. }
  65548. /**
  65549. * Represents a group of points in a points cloud system
  65550. * * PCS internal tool, don't use it manually.
  65551. */
  65552. export class PointsGroup {
  65553. /**
  65554. * The group id
  65555. * @hidden
  65556. */
  65557. groupID: number;
  65558. /**
  65559. * image data for group (internal use)
  65560. * @hidden
  65561. */
  65562. _groupImageData: Nullable<ArrayBufferView>;
  65563. /**
  65564. * Image Width (internal use)
  65565. * @hidden
  65566. */
  65567. _groupImgWidth: number;
  65568. /**
  65569. * Image Height (internal use)
  65570. * @hidden
  65571. */
  65572. _groupImgHeight: number;
  65573. /**
  65574. * Custom position function (internal use)
  65575. * @hidden
  65576. */
  65577. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65578. /**
  65579. * density per facet for surface points
  65580. * @hidden
  65581. */
  65582. _groupDensity: number[];
  65583. /**
  65584. * Only when points are colored by texture carries pointer to texture list array
  65585. * @hidden
  65586. */
  65587. _textureNb: number;
  65588. /**
  65589. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65590. * PCS internal tool, don't use it manually.
  65591. * @hidden
  65592. */
  65593. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65594. }
  65595. }
  65596. declare module BABYLON {
  65597. interface Scene {
  65598. /** @hidden (Backing field) */
  65599. _physicsEngine: Nullable<IPhysicsEngine>;
  65600. /** @hidden */
  65601. _physicsTimeAccumulator: number;
  65602. /**
  65603. * Gets the current physics engine
  65604. * @returns a IPhysicsEngine or null if none attached
  65605. */
  65606. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65607. /**
  65608. * Enables physics to the current scene
  65609. * @param gravity defines the scene's gravity for the physics engine
  65610. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65611. * @return a boolean indicating if the physics engine was initialized
  65612. */
  65613. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65614. /**
  65615. * Disables and disposes the physics engine associated with the scene
  65616. */
  65617. disablePhysicsEngine(): void;
  65618. /**
  65619. * Gets a boolean indicating if there is an active physics engine
  65620. * @returns a boolean indicating if there is an active physics engine
  65621. */
  65622. isPhysicsEnabled(): boolean;
  65623. /**
  65624. * Deletes a physics compound impostor
  65625. * @param compound defines the compound to delete
  65626. */
  65627. deleteCompoundImpostor(compound: any): void;
  65628. /**
  65629. * An event triggered when physic simulation is about to be run
  65630. */
  65631. onBeforePhysicsObservable: Observable<Scene>;
  65632. /**
  65633. * An event triggered when physic simulation has been done
  65634. */
  65635. onAfterPhysicsObservable: Observable<Scene>;
  65636. }
  65637. interface AbstractMesh {
  65638. /** @hidden */
  65639. _physicsImpostor: Nullable<PhysicsImpostor>;
  65640. /**
  65641. * Gets or sets impostor used for physic simulation
  65642. * @see http://doc.babylonjs.com/features/physics_engine
  65643. */
  65644. physicsImpostor: Nullable<PhysicsImpostor>;
  65645. /**
  65646. * Gets the current physics impostor
  65647. * @see http://doc.babylonjs.com/features/physics_engine
  65648. * @returns a physics impostor or null
  65649. */
  65650. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65651. /** Apply a physic impulse to the mesh
  65652. * @param force defines the force to apply
  65653. * @param contactPoint defines where to apply the force
  65654. * @returns the current mesh
  65655. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65656. */
  65657. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65658. /**
  65659. * Creates a physic joint between two meshes
  65660. * @param otherMesh defines the other mesh to use
  65661. * @param pivot1 defines the pivot to use on this mesh
  65662. * @param pivot2 defines the pivot to use on the other mesh
  65663. * @param options defines additional options (can be plugin dependent)
  65664. * @returns the current mesh
  65665. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65666. */
  65667. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65668. /** @hidden */
  65669. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65670. }
  65671. /**
  65672. * Defines the physics engine scene component responsible to manage a physics engine
  65673. */
  65674. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65675. /**
  65676. * The component name helpful to identify the component in the list of scene components.
  65677. */
  65678. readonly name: string;
  65679. /**
  65680. * The scene the component belongs to.
  65681. */
  65682. scene: Scene;
  65683. /**
  65684. * Creates a new instance of the component for the given scene
  65685. * @param scene Defines the scene to register the component in
  65686. */
  65687. constructor(scene: Scene);
  65688. /**
  65689. * Registers the component in a given scene
  65690. */
  65691. register(): void;
  65692. /**
  65693. * Rebuilds the elements related to this component in case of
  65694. * context lost for instance.
  65695. */
  65696. rebuild(): void;
  65697. /**
  65698. * Disposes the component and the associated ressources
  65699. */
  65700. dispose(): void;
  65701. }
  65702. }
  65703. declare module BABYLON {
  65704. /**
  65705. * A helper for physics simulations
  65706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65707. */
  65708. export class PhysicsHelper {
  65709. private _scene;
  65710. private _physicsEngine;
  65711. /**
  65712. * Initializes the Physics helper
  65713. * @param scene Babylon.js scene
  65714. */
  65715. constructor(scene: Scene);
  65716. /**
  65717. * Applies a radial explosion impulse
  65718. * @param origin the origin of the explosion
  65719. * @param radiusOrEventOptions the radius or the options of radial explosion
  65720. * @param strength the explosion strength
  65721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65722. * @returns A physics radial explosion event, or null
  65723. */
  65724. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65725. /**
  65726. * Applies a radial explosion force
  65727. * @param origin the origin of the explosion
  65728. * @param radiusOrEventOptions the radius or the options of radial explosion
  65729. * @param strength the explosion strength
  65730. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65731. * @returns A physics radial explosion event, or null
  65732. */
  65733. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65734. /**
  65735. * Creates a gravitational field
  65736. * @param origin the origin of the explosion
  65737. * @param radiusOrEventOptions the radius or the options of radial explosion
  65738. * @param strength the explosion strength
  65739. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65740. * @returns A physics gravitational field event, or null
  65741. */
  65742. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65743. /**
  65744. * Creates a physics updraft event
  65745. * @param origin the origin of the updraft
  65746. * @param radiusOrEventOptions the radius or the options of the updraft
  65747. * @param strength the strength of the updraft
  65748. * @param height the height of the updraft
  65749. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65750. * @returns A physics updraft event, or null
  65751. */
  65752. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65753. /**
  65754. * Creates a physics vortex event
  65755. * @param origin the of the vortex
  65756. * @param radiusOrEventOptions the radius or the options of the vortex
  65757. * @param strength the strength of the vortex
  65758. * @param height the height of the vortex
  65759. * @returns a Physics vortex event, or null
  65760. * A physics vortex event or null
  65761. */
  65762. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65763. }
  65764. /**
  65765. * Represents a physics radial explosion event
  65766. */
  65767. class PhysicsRadialExplosionEvent {
  65768. private _scene;
  65769. private _options;
  65770. private _sphere;
  65771. private _dataFetched;
  65772. /**
  65773. * Initializes a radial explosioin event
  65774. * @param _scene BabylonJS scene
  65775. * @param _options The options for the vortex event
  65776. */
  65777. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65778. /**
  65779. * Returns the data related to the radial explosion event (sphere).
  65780. * @returns The radial explosion event data
  65781. */
  65782. getData(): PhysicsRadialExplosionEventData;
  65783. /**
  65784. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65785. * @param impostor A physics imposter
  65786. * @param origin the origin of the explosion
  65787. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65788. */
  65789. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65790. /**
  65791. * Triggers affecterd impostors callbacks
  65792. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65793. */
  65794. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65795. /**
  65796. * Disposes the sphere.
  65797. * @param force Specifies if the sphere should be disposed by force
  65798. */
  65799. dispose(force?: boolean): void;
  65800. /*** Helpers ***/
  65801. private _prepareSphere;
  65802. private _intersectsWithSphere;
  65803. }
  65804. /**
  65805. * Represents a gravitational field event
  65806. */
  65807. class PhysicsGravitationalFieldEvent {
  65808. private _physicsHelper;
  65809. private _scene;
  65810. private _origin;
  65811. private _options;
  65812. private _tickCallback;
  65813. private _sphere;
  65814. private _dataFetched;
  65815. /**
  65816. * Initializes the physics gravitational field event
  65817. * @param _physicsHelper A physics helper
  65818. * @param _scene BabylonJS scene
  65819. * @param _origin The origin position of the gravitational field event
  65820. * @param _options The options for the vortex event
  65821. */
  65822. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65823. /**
  65824. * Returns the data related to the gravitational field event (sphere).
  65825. * @returns A gravitational field event
  65826. */
  65827. getData(): PhysicsGravitationalFieldEventData;
  65828. /**
  65829. * Enables the gravitational field.
  65830. */
  65831. enable(): void;
  65832. /**
  65833. * Disables the gravitational field.
  65834. */
  65835. disable(): void;
  65836. /**
  65837. * Disposes the sphere.
  65838. * @param force The force to dispose from the gravitational field event
  65839. */
  65840. dispose(force?: boolean): void;
  65841. private _tick;
  65842. }
  65843. /**
  65844. * Represents a physics updraft event
  65845. */
  65846. class PhysicsUpdraftEvent {
  65847. private _scene;
  65848. private _origin;
  65849. private _options;
  65850. private _physicsEngine;
  65851. private _originTop;
  65852. private _originDirection;
  65853. private _tickCallback;
  65854. private _cylinder;
  65855. private _cylinderPosition;
  65856. private _dataFetched;
  65857. /**
  65858. * Initializes the physics updraft event
  65859. * @param _scene BabylonJS scene
  65860. * @param _origin The origin position of the updraft
  65861. * @param _options The options for the updraft event
  65862. */
  65863. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65864. /**
  65865. * Returns the data related to the updraft event (cylinder).
  65866. * @returns A physics updraft event
  65867. */
  65868. getData(): PhysicsUpdraftEventData;
  65869. /**
  65870. * Enables the updraft.
  65871. */
  65872. enable(): void;
  65873. /**
  65874. * Disables the updraft.
  65875. */
  65876. disable(): void;
  65877. /**
  65878. * Disposes the cylinder.
  65879. * @param force Specifies if the updraft should be disposed by force
  65880. */
  65881. dispose(force?: boolean): void;
  65882. private getImpostorHitData;
  65883. private _tick;
  65884. /*** Helpers ***/
  65885. private _prepareCylinder;
  65886. private _intersectsWithCylinder;
  65887. }
  65888. /**
  65889. * Represents a physics vortex event
  65890. */
  65891. class PhysicsVortexEvent {
  65892. private _scene;
  65893. private _origin;
  65894. private _options;
  65895. private _physicsEngine;
  65896. private _originTop;
  65897. private _tickCallback;
  65898. private _cylinder;
  65899. private _cylinderPosition;
  65900. private _dataFetched;
  65901. /**
  65902. * Initializes the physics vortex event
  65903. * @param _scene The BabylonJS scene
  65904. * @param _origin The origin position of the vortex
  65905. * @param _options The options for the vortex event
  65906. */
  65907. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65908. /**
  65909. * Returns the data related to the vortex event (cylinder).
  65910. * @returns The physics vortex event data
  65911. */
  65912. getData(): PhysicsVortexEventData;
  65913. /**
  65914. * Enables the vortex.
  65915. */
  65916. enable(): void;
  65917. /**
  65918. * Disables the cortex.
  65919. */
  65920. disable(): void;
  65921. /**
  65922. * Disposes the sphere.
  65923. * @param force
  65924. */
  65925. dispose(force?: boolean): void;
  65926. private getImpostorHitData;
  65927. private _tick;
  65928. /*** Helpers ***/
  65929. private _prepareCylinder;
  65930. private _intersectsWithCylinder;
  65931. }
  65932. /**
  65933. * Options fot the radial explosion event
  65934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65935. */
  65936. export class PhysicsRadialExplosionEventOptions {
  65937. /**
  65938. * The radius of the sphere for the radial explosion.
  65939. */
  65940. radius: number;
  65941. /**
  65942. * The strenth of the explosion.
  65943. */
  65944. strength: number;
  65945. /**
  65946. * The strenght of the force in correspondence to the distance of the affected object
  65947. */
  65948. falloff: PhysicsRadialImpulseFalloff;
  65949. /**
  65950. * Sphere options for the radial explosion.
  65951. */
  65952. sphere: {
  65953. segments: number;
  65954. diameter: number;
  65955. };
  65956. /**
  65957. * Sphere options for the radial explosion.
  65958. */
  65959. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65960. }
  65961. /**
  65962. * Options fot the updraft event
  65963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65964. */
  65965. export class PhysicsUpdraftEventOptions {
  65966. /**
  65967. * The radius of the cylinder for the vortex
  65968. */
  65969. radius: number;
  65970. /**
  65971. * The strenth of the updraft.
  65972. */
  65973. strength: number;
  65974. /**
  65975. * The height of the cylinder for the updraft.
  65976. */
  65977. height: number;
  65978. /**
  65979. * The mode for the the updraft.
  65980. */
  65981. updraftMode: PhysicsUpdraftMode;
  65982. }
  65983. /**
  65984. * Options fot the vortex event
  65985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65986. */
  65987. export class PhysicsVortexEventOptions {
  65988. /**
  65989. * The radius of the cylinder for the vortex
  65990. */
  65991. radius: number;
  65992. /**
  65993. * The strenth of the vortex.
  65994. */
  65995. strength: number;
  65996. /**
  65997. * The height of the cylinder for the vortex.
  65998. */
  65999. height: number;
  66000. /**
  66001. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66002. */
  66003. centripetalForceThreshold: number;
  66004. /**
  66005. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66006. */
  66007. centripetalForceMultiplier: number;
  66008. /**
  66009. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66010. */
  66011. centrifugalForceMultiplier: number;
  66012. /**
  66013. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66014. */
  66015. updraftForceMultiplier: number;
  66016. }
  66017. /**
  66018. * The strenght of the force in correspondence to the distance of the affected object
  66019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66020. */
  66021. export enum PhysicsRadialImpulseFalloff {
  66022. /** Defines that impulse is constant in strength across it's whole radius */
  66023. Constant = 0,
  66024. /** Defines that impulse gets weaker if it's further from the origin */
  66025. Linear = 1
  66026. }
  66027. /**
  66028. * The strength of the force in correspondence to the distance of the affected object
  66029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66030. */
  66031. export enum PhysicsUpdraftMode {
  66032. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66033. Center = 0,
  66034. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66035. Perpendicular = 1
  66036. }
  66037. /**
  66038. * Interface for a physics hit data
  66039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66040. */
  66041. export interface PhysicsHitData {
  66042. /**
  66043. * The force applied at the contact point
  66044. */
  66045. force: Vector3;
  66046. /**
  66047. * The contact point
  66048. */
  66049. contactPoint: Vector3;
  66050. /**
  66051. * The distance from the origin to the contact point
  66052. */
  66053. distanceFromOrigin: number;
  66054. }
  66055. /**
  66056. * Interface for radial explosion event data
  66057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66058. */
  66059. export interface PhysicsRadialExplosionEventData {
  66060. /**
  66061. * A sphere used for the radial explosion event
  66062. */
  66063. sphere: Mesh;
  66064. }
  66065. /**
  66066. * Interface for gravitational field event data
  66067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66068. */
  66069. export interface PhysicsGravitationalFieldEventData {
  66070. /**
  66071. * A sphere mesh used for the gravitational field event
  66072. */
  66073. sphere: Mesh;
  66074. }
  66075. /**
  66076. * Interface for updraft event data
  66077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66078. */
  66079. export interface PhysicsUpdraftEventData {
  66080. /**
  66081. * A cylinder used for the updraft event
  66082. */
  66083. cylinder: Mesh;
  66084. }
  66085. /**
  66086. * Interface for vortex event data
  66087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66088. */
  66089. export interface PhysicsVortexEventData {
  66090. /**
  66091. * A cylinder used for the vortex event
  66092. */
  66093. cylinder: Mesh;
  66094. }
  66095. /**
  66096. * Interface for an affected physics impostor
  66097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66098. */
  66099. export interface PhysicsAffectedImpostorWithData {
  66100. /**
  66101. * The impostor affected by the effect
  66102. */
  66103. impostor: PhysicsImpostor;
  66104. /**
  66105. * The data about the hit/horce from the explosion
  66106. */
  66107. hitData: PhysicsHitData;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /** @hidden */
  66112. export var blackAndWhitePixelShader: {
  66113. name: string;
  66114. shader: string;
  66115. };
  66116. }
  66117. declare module BABYLON {
  66118. /**
  66119. * Post process used to render in black and white
  66120. */
  66121. export class BlackAndWhitePostProcess extends PostProcess {
  66122. /**
  66123. * Linear about to convert he result to black and white (default: 1)
  66124. */
  66125. degree: number;
  66126. /**
  66127. * Creates a black and white post process
  66128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66129. * @param name The name of the effect.
  66130. * @param options The required width/height ratio to downsize to before computing the render pass.
  66131. * @param camera The camera to apply the render pass to.
  66132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66133. * @param engine The engine which the post process will be applied. (default: current engine)
  66134. * @param reusable If the post process can be reused on the same frame. (default: false)
  66135. */
  66136. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66137. }
  66138. }
  66139. declare module BABYLON {
  66140. /**
  66141. * This represents a set of one or more post processes in Babylon.
  66142. * A post process can be used to apply a shader to a texture after it is rendered.
  66143. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66144. */
  66145. export class PostProcessRenderEffect {
  66146. private _postProcesses;
  66147. private _getPostProcesses;
  66148. private _singleInstance;
  66149. private _cameras;
  66150. private _indicesForCamera;
  66151. /**
  66152. * Name of the effect
  66153. * @hidden
  66154. */
  66155. _name: string;
  66156. /**
  66157. * Instantiates a post process render effect.
  66158. * A post process can be used to apply a shader to a texture after it is rendered.
  66159. * @param engine The engine the effect is tied to
  66160. * @param name The name of the effect
  66161. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66162. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66163. */
  66164. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66165. /**
  66166. * Checks if all the post processes in the effect are supported.
  66167. */
  66168. get isSupported(): boolean;
  66169. /**
  66170. * Updates the current state of the effect
  66171. * @hidden
  66172. */
  66173. _update(): void;
  66174. /**
  66175. * Attaches the effect on cameras
  66176. * @param cameras The camera to attach to.
  66177. * @hidden
  66178. */
  66179. _attachCameras(cameras: Camera): void;
  66180. /**
  66181. * Attaches the effect on cameras
  66182. * @param cameras The camera to attach to.
  66183. * @hidden
  66184. */
  66185. _attachCameras(cameras: Camera[]): void;
  66186. /**
  66187. * Detaches the effect on cameras
  66188. * @param cameras The camera to detatch from.
  66189. * @hidden
  66190. */
  66191. _detachCameras(cameras: Camera): void;
  66192. /**
  66193. * Detatches the effect on cameras
  66194. * @param cameras The camera to detatch from.
  66195. * @hidden
  66196. */
  66197. _detachCameras(cameras: Camera[]): void;
  66198. /**
  66199. * Enables the effect on given cameras
  66200. * @param cameras The camera to enable.
  66201. * @hidden
  66202. */
  66203. _enable(cameras: Camera): void;
  66204. /**
  66205. * Enables the effect on given cameras
  66206. * @param cameras The camera to enable.
  66207. * @hidden
  66208. */
  66209. _enable(cameras: Nullable<Camera[]>): void;
  66210. /**
  66211. * Disables the effect on the given cameras
  66212. * @param cameras The camera to disable.
  66213. * @hidden
  66214. */
  66215. _disable(cameras: Camera): void;
  66216. /**
  66217. * Disables the effect on the given cameras
  66218. * @param cameras The camera to disable.
  66219. * @hidden
  66220. */
  66221. _disable(cameras: Nullable<Camera[]>): void;
  66222. /**
  66223. * Gets a list of the post processes contained in the effect.
  66224. * @param camera The camera to get the post processes on.
  66225. * @returns The list of the post processes in the effect.
  66226. */
  66227. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66228. }
  66229. }
  66230. declare module BABYLON {
  66231. /** @hidden */
  66232. export var extractHighlightsPixelShader: {
  66233. name: string;
  66234. shader: string;
  66235. };
  66236. }
  66237. declare module BABYLON {
  66238. /**
  66239. * 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.
  66240. */
  66241. export class ExtractHighlightsPostProcess extends PostProcess {
  66242. /**
  66243. * The luminance threshold, pixels below this value will be set to black.
  66244. */
  66245. threshold: number;
  66246. /** @hidden */
  66247. _exposure: number;
  66248. /**
  66249. * Post process which has the input texture to be used when performing highlight extraction
  66250. * @hidden
  66251. */
  66252. _inputPostProcess: Nullable<PostProcess>;
  66253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /** @hidden */
  66258. export var bloomMergePixelShader: {
  66259. name: string;
  66260. shader: string;
  66261. };
  66262. }
  66263. declare module BABYLON {
  66264. /**
  66265. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66266. */
  66267. export class BloomMergePostProcess extends PostProcess {
  66268. /** Weight of the bloom to be added to the original input. */
  66269. weight: number;
  66270. /**
  66271. * Creates a new instance of @see BloomMergePostProcess
  66272. * @param name The name of the effect.
  66273. * @param originalFromInput Post process which's input will be used for the merge.
  66274. * @param blurred Blurred highlights post process which's output will be used.
  66275. * @param weight Weight of the bloom to be added to the original input.
  66276. * @param options The required width/height ratio to downsize to before computing the render pass.
  66277. * @param camera The camera to apply the render pass to.
  66278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66279. * @param engine The engine which the post process will be applied. (default: current engine)
  66280. * @param reusable If the post process can be reused on the same frame. (default: false)
  66281. * @param textureType Type of textures used when performing the post process. (default: 0)
  66282. * @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)
  66283. */
  66284. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66285. /** Weight of the bloom to be added to the original input. */
  66286. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66287. }
  66288. }
  66289. declare module BABYLON {
  66290. /**
  66291. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66292. */
  66293. export class BloomEffect extends PostProcessRenderEffect {
  66294. private bloomScale;
  66295. /**
  66296. * @hidden Internal
  66297. */
  66298. _effects: Array<PostProcess>;
  66299. /**
  66300. * @hidden Internal
  66301. */
  66302. _downscale: ExtractHighlightsPostProcess;
  66303. private _blurX;
  66304. private _blurY;
  66305. private _merge;
  66306. /**
  66307. * The luminance threshold to find bright areas of the image to bloom.
  66308. */
  66309. get threshold(): number;
  66310. set threshold(value: number);
  66311. /**
  66312. * The strength of the bloom.
  66313. */
  66314. get weight(): number;
  66315. set weight(value: number);
  66316. /**
  66317. * Specifies the size of the bloom blur kernel, relative to the final output size
  66318. */
  66319. get kernel(): number;
  66320. set kernel(value: number);
  66321. /**
  66322. * Creates a new instance of @see BloomEffect
  66323. * @param scene The scene the effect belongs to.
  66324. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66325. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66326. * @param bloomWeight The the strength of bloom.
  66327. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66328. * @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)
  66329. */
  66330. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66331. /**
  66332. * Disposes each of the internal effects for a given camera.
  66333. * @param camera The camera to dispose the effect on.
  66334. */
  66335. disposeEffects(camera: Camera): void;
  66336. /**
  66337. * @hidden Internal
  66338. */
  66339. _updateEffects(): void;
  66340. /**
  66341. * Internal
  66342. * @returns if all the contained post processes are ready.
  66343. * @hidden
  66344. */
  66345. _isReady(): boolean;
  66346. }
  66347. }
  66348. declare module BABYLON {
  66349. /** @hidden */
  66350. export var chromaticAberrationPixelShader: {
  66351. name: string;
  66352. shader: string;
  66353. };
  66354. }
  66355. declare module BABYLON {
  66356. /**
  66357. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66358. */
  66359. export class ChromaticAberrationPostProcess extends PostProcess {
  66360. /**
  66361. * The amount of seperation of rgb channels (default: 30)
  66362. */
  66363. aberrationAmount: number;
  66364. /**
  66365. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66366. */
  66367. radialIntensity: number;
  66368. /**
  66369. * 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))
  66370. */
  66371. direction: Vector2;
  66372. /**
  66373. * 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))
  66374. */
  66375. centerPosition: Vector2;
  66376. /**
  66377. * Creates a new instance ChromaticAberrationPostProcess
  66378. * @param name The name of the effect.
  66379. * @param screenWidth The width of the screen to apply the effect on.
  66380. * @param screenHeight The height of the screen to apply the effect on.
  66381. * @param options The required width/height ratio to downsize to before computing the render pass.
  66382. * @param camera The camera to apply the render pass to.
  66383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66384. * @param engine The engine which the post process will be applied. (default: current engine)
  66385. * @param reusable If the post process can be reused on the same frame. (default: false)
  66386. * @param textureType Type of textures used when performing the post process. (default: 0)
  66387. * @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)
  66388. */
  66389. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66390. }
  66391. }
  66392. declare module BABYLON {
  66393. /** @hidden */
  66394. export var circleOfConfusionPixelShader: {
  66395. name: string;
  66396. shader: string;
  66397. };
  66398. }
  66399. declare module BABYLON {
  66400. /**
  66401. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66402. */
  66403. export class CircleOfConfusionPostProcess extends PostProcess {
  66404. /**
  66405. * 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.
  66406. */
  66407. lensSize: number;
  66408. /**
  66409. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66410. */
  66411. fStop: number;
  66412. /**
  66413. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66414. */
  66415. focusDistance: number;
  66416. /**
  66417. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66418. */
  66419. focalLength: number;
  66420. private _depthTexture;
  66421. /**
  66422. * Creates a new instance CircleOfConfusionPostProcess
  66423. * @param name The name of the effect.
  66424. * @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.
  66425. * @param options The required width/height ratio to downsize to before computing the render pass.
  66426. * @param camera The camera to apply the render pass to.
  66427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66428. * @param engine The engine which the post process will be applied. (default: current engine)
  66429. * @param reusable If the post process can be reused on the same frame. (default: false)
  66430. * @param textureType Type of textures used when performing the post process. (default: 0)
  66431. * @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)
  66432. */
  66433. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66434. /**
  66435. * 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.
  66436. */
  66437. set depthTexture(value: RenderTargetTexture);
  66438. }
  66439. }
  66440. declare module BABYLON {
  66441. /** @hidden */
  66442. export var colorCorrectionPixelShader: {
  66443. name: string;
  66444. shader: string;
  66445. };
  66446. }
  66447. declare module BABYLON {
  66448. /**
  66449. *
  66450. * This post-process allows the modification of rendered colors by using
  66451. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66452. *
  66453. * The object needs to be provided an url to a texture containing the color
  66454. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66455. * Use an image editing software to tweak the LUT to match your needs.
  66456. *
  66457. * For an example of a color LUT, see here:
  66458. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66459. * For explanations on color grading, see here:
  66460. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66461. *
  66462. */
  66463. export class ColorCorrectionPostProcess extends PostProcess {
  66464. private _colorTableTexture;
  66465. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66466. }
  66467. }
  66468. declare module BABYLON {
  66469. /** @hidden */
  66470. export var convolutionPixelShader: {
  66471. name: string;
  66472. shader: string;
  66473. };
  66474. }
  66475. declare module BABYLON {
  66476. /**
  66477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66478. * input texture to perform effects such as edge detection or sharpening
  66479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66480. */
  66481. export class ConvolutionPostProcess extends PostProcess {
  66482. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66483. kernel: number[];
  66484. /**
  66485. * Creates a new instance ConvolutionPostProcess
  66486. * @param name The name of the effect.
  66487. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66488. * @param options The required width/height ratio to downsize to before computing the render pass.
  66489. * @param camera The camera to apply the render pass to.
  66490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66491. * @param engine The engine which the post process will be applied. (default: current engine)
  66492. * @param reusable If the post process can be reused on the same frame. (default: false)
  66493. * @param textureType Type of textures used when performing the post process. (default: 0)
  66494. */
  66495. constructor(name: string,
  66496. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66497. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66498. /**
  66499. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66500. */
  66501. static EdgeDetect0Kernel: number[];
  66502. /**
  66503. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66504. */
  66505. static EdgeDetect1Kernel: number[];
  66506. /**
  66507. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66508. */
  66509. static EdgeDetect2Kernel: number[];
  66510. /**
  66511. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66512. */
  66513. static SharpenKernel: number[];
  66514. /**
  66515. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66516. */
  66517. static EmbossKernel: number[];
  66518. /**
  66519. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66520. */
  66521. static GaussianKernel: number[];
  66522. }
  66523. }
  66524. declare module BABYLON {
  66525. /**
  66526. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66527. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66528. * based on samples that have a large difference in distance than the center pixel.
  66529. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66530. */
  66531. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66532. direction: Vector2;
  66533. /**
  66534. * Creates a new instance CircleOfConfusionPostProcess
  66535. * @param name The name of the effect.
  66536. * @param scene The scene the effect belongs to.
  66537. * @param direction The direction the blur should be applied.
  66538. * @param kernel The size of the kernel used to blur.
  66539. * @param options The required width/height ratio to downsize to before computing the render pass.
  66540. * @param camera The camera to apply the render pass to.
  66541. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66542. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66544. * @param engine The engine which the post process will be applied. (default: current engine)
  66545. * @param reusable If the post process can be reused on the same frame. (default: false)
  66546. * @param textureType Type of textures used when performing the post process. (default: 0)
  66547. * @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)
  66548. */
  66549. 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);
  66550. }
  66551. }
  66552. declare module BABYLON {
  66553. /** @hidden */
  66554. export var depthOfFieldMergePixelShader: {
  66555. name: string;
  66556. shader: string;
  66557. };
  66558. }
  66559. declare module BABYLON {
  66560. /**
  66561. * Options to be set when merging outputs from the default pipeline.
  66562. */
  66563. export class DepthOfFieldMergePostProcessOptions {
  66564. /**
  66565. * The original image to merge on top of
  66566. */
  66567. originalFromInput: PostProcess;
  66568. /**
  66569. * Parameters to perform the merge of the depth of field effect
  66570. */
  66571. depthOfField?: {
  66572. circleOfConfusion: PostProcess;
  66573. blurSteps: Array<PostProcess>;
  66574. };
  66575. /**
  66576. * Parameters to perform the merge of bloom effect
  66577. */
  66578. bloom?: {
  66579. blurred: PostProcess;
  66580. weight: number;
  66581. };
  66582. }
  66583. /**
  66584. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66585. */
  66586. export class DepthOfFieldMergePostProcess extends PostProcess {
  66587. private blurSteps;
  66588. /**
  66589. * Creates a new instance of DepthOfFieldMergePostProcess
  66590. * @param name The name of the effect.
  66591. * @param originalFromInput Post process which's input will be used for the merge.
  66592. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66593. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66594. * @param options The required width/height ratio to downsize to before computing the render pass.
  66595. * @param camera The camera to apply the render pass to.
  66596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66597. * @param engine The engine which the post process will be applied. (default: current engine)
  66598. * @param reusable If the post process can be reused on the same frame. (default: false)
  66599. * @param textureType Type of textures used when performing the post process. (default: 0)
  66600. * @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)
  66601. */
  66602. 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);
  66603. /**
  66604. * Updates the effect with the current post process compile time values and recompiles the shader.
  66605. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66606. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66607. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66608. * @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
  66609. * @param onCompiled Called when the shader has been compiled.
  66610. * @param onError Called if there is an error when compiling a shader.
  66611. */
  66612. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66613. }
  66614. }
  66615. declare module BABYLON {
  66616. /**
  66617. * Specifies the level of max blur that should be applied when using the depth of field effect
  66618. */
  66619. export enum DepthOfFieldEffectBlurLevel {
  66620. /**
  66621. * Subtle blur
  66622. */
  66623. Low = 0,
  66624. /**
  66625. * Medium blur
  66626. */
  66627. Medium = 1,
  66628. /**
  66629. * Large blur
  66630. */
  66631. High = 2
  66632. }
  66633. /**
  66634. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66635. */
  66636. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66637. private _circleOfConfusion;
  66638. /**
  66639. * @hidden Internal, blurs from high to low
  66640. */
  66641. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66642. private _depthOfFieldBlurY;
  66643. private _dofMerge;
  66644. /**
  66645. * @hidden Internal post processes in depth of field effect
  66646. */
  66647. _effects: Array<PostProcess>;
  66648. /**
  66649. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66650. */
  66651. set focalLength(value: number);
  66652. get focalLength(): number;
  66653. /**
  66654. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66655. */
  66656. set fStop(value: number);
  66657. get fStop(): number;
  66658. /**
  66659. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66660. */
  66661. set focusDistance(value: number);
  66662. get focusDistance(): number;
  66663. /**
  66664. * 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.
  66665. */
  66666. set lensSize(value: number);
  66667. get lensSize(): number;
  66668. /**
  66669. * Creates a new instance DepthOfFieldEffect
  66670. * @param scene The scene the effect belongs to.
  66671. * @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.
  66672. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66673. * @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)
  66674. */
  66675. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66676. /**
  66677. * Get the current class name of the current effet
  66678. * @returns "DepthOfFieldEffect"
  66679. */
  66680. getClassName(): string;
  66681. /**
  66682. * 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.
  66683. */
  66684. set depthTexture(value: RenderTargetTexture);
  66685. /**
  66686. * Disposes each of the internal effects for a given camera.
  66687. * @param camera The camera to dispose the effect on.
  66688. */
  66689. disposeEffects(camera: Camera): void;
  66690. /**
  66691. * @hidden Internal
  66692. */
  66693. _updateEffects(): void;
  66694. /**
  66695. * Internal
  66696. * @returns if all the contained post processes are ready.
  66697. * @hidden
  66698. */
  66699. _isReady(): boolean;
  66700. }
  66701. }
  66702. declare module BABYLON {
  66703. /** @hidden */
  66704. export var displayPassPixelShader: {
  66705. name: string;
  66706. shader: string;
  66707. };
  66708. }
  66709. declare module BABYLON {
  66710. /**
  66711. * DisplayPassPostProcess which produces an output the same as it's input
  66712. */
  66713. export class DisplayPassPostProcess extends PostProcess {
  66714. /**
  66715. * Creates the DisplayPassPostProcess
  66716. * @param name The name of the effect.
  66717. * @param options The required width/height ratio to downsize to before computing the render pass.
  66718. * @param camera The camera to apply the render pass to.
  66719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66720. * @param engine The engine which the post process will be applied. (default: current engine)
  66721. * @param reusable If the post process can be reused on the same frame. (default: false)
  66722. */
  66723. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66724. }
  66725. }
  66726. declare module BABYLON {
  66727. /** @hidden */
  66728. export var filterPixelShader: {
  66729. name: string;
  66730. shader: string;
  66731. };
  66732. }
  66733. declare module BABYLON {
  66734. /**
  66735. * Applies a kernel filter to the image
  66736. */
  66737. export class FilterPostProcess extends PostProcess {
  66738. /** The matrix to be applied to the image */
  66739. kernelMatrix: Matrix;
  66740. /**
  66741. *
  66742. * @param name The name of the effect.
  66743. * @param kernelMatrix The matrix to be applied to the image
  66744. * @param options The required width/height ratio to downsize to before computing the render pass.
  66745. * @param camera The camera to apply the render pass to.
  66746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66747. * @param engine The engine which the post process will be applied. (default: current engine)
  66748. * @param reusable If the post process can be reused on the same frame. (default: false)
  66749. */
  66750. constructor(name: string,
  66751. /** The matrix to be applied to the image */
  66752. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66753. }
  66754. }
  66755. declare module BABYLON {
  66756. /** @hidden */
  66757. export var fxaaPixelShader: {
  66758. name: string;
  66759. shader: string;
  66760. };
  66761. }
  66762. declare module BABYLON {
  66763. /** @hidden */
  66764. export var fxaaVertexShader: {
  66765. name: string;
  66766. shader: string;
  66767. };
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * Fxaa post process
  66772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66773. */
  66774. export class FxaaPostProcess extends PostProcess {
  66775. /** @hidden */
  66776. texelWidth: number;
  66777. /** @hidden */
  66778. texelHeight: number;
  66779. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66780. private _getDefines;
  66781. }
  66782. }
  66783. declare module BABYLON {
  66784. /** @hidden */
  66785. export var grainPixelShader: {
  66786. name: string;
  66787. shader: string;
  66788. };
  66789. }
  66790. declare module BABYLON {
  66791. /**
  66792. * The GrainPostProcess adds noise to the image at mid luminance levels
  66793. */
  66794. export class GrainPostProcess extends PostProcess {
  66795. /**
  66796. * The intensity of the grain added (default: 30)
  66797. */
  66798. intensity: number;
  66799. /**
  66800. * If the grain should be randomized on every frame
  66801. */
  66802. animated: boolean;
  66803. /**
  66804. * Creates a new instance of @see GrainPostProcess
  66805. * @param name The name of the effect.
  66806. * @param options The required width/height ratio to downsize to before computing the render pass.
  66807. * @param camera The camera to apply the render pass to.
  66808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66809. * @param engine The engine which the post process will be applied. (default: current engine)
  66810. * @param reusable If the post process can be reused on the same frame. (default: false)
  66811. * @param textureType Type of textures used when performing the post process. (default: 0)
  66812. * @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)
  66813. */
  66814. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66815. }
  66816. }
  66817. declare module BABYLON {
  66818. /** @hidden */
  66819. export var highlightsPixelShader: {
  66820. name: string;
  66821. shader: string;
  66822. };
  66823. }
  66824. declare module BABYLON {
  66825. /**
  66826. * Extracts highlights from the image
  66827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66828. */
  66829. export class HighlightsPostProcess extends PostProcess {
  66830. /**
  66831. * Extracts highlights from the image
  66832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66833. * @param name The name of the effect.
  66834. * @param options The required width/height ratio to downsize to before computing the render pass.
  66835. * @param camera The camera to apply the render pass to.
  66836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66837. * @param engine The engine which the post process will be applied. (default: current engine)
  66838. * @param reusable If the post process can be reused on the same frame. (default: false)
  66839. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66840. */
  66841. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66842. }
  66843. }
  66844. declare module BABYLON {
  66845. /** @hidden */
  66846. export var mrtFragmentDeclaration: {
  66847. name: string;
  66848. shader: string;
  66849. };
  66850. }
  66851. declare module BABYLON {
  66852. /** @hidden */
  66853. export var geometryPixelShader: {
  66854. name: string;
  66855. shader: string;
  66856. };
  66857. }
  66858. declare module BABYLON {
  66859. /** @hidden */
  66860. export var geometryVertexShader: {
  66861. name: string;
  66862. shader: string;
  66863. };
  66864. }
  66865. declare module BABYLON {
  66866. /** @hidden */
  66867. interface ISavedTransformationMatrix {
  66868. world: Matrix;
  66869. viewProjection: Matrix;
  66870. }
  66871. /**
  66872. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66873. */
  66874. export class GeometryBufferRenderer {
  66875. /**
  66876. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66877. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66878. */
  66879. static readonly POSITION_TEXTURE_TYPE: number;
  66880. /**
  66881. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66882. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66883. */
  66884. static readonly VELOCITY_TEXTURE_TYPE: number;
  66885. /**
  66886. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  66887. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  66888. */
  66889. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  66890. /**
  66891. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66892. * in order to compute objects velocities when enableVelocity is set to "true"
  66893. * @hidden
  66894. */
  66895. _previousTransformationMatrices: {
  66896. [index: number]: ISavedTransformationMatrix;
  66897. };
  66898. /**
  66899. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66900. * in order to compute objects velocities when enableVelocity is set to "true"
  66901. * @hidden
  66902. */
  66903. _previousBonesTransformationMatrices: {
  66904. [index: number]: Float32Array;
  66905. };
  66906. /**
  66907. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66908. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66909. */
  66910. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66911. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  66912. renderTransparentMeshes: boolean;
  66913. private _scene;
  66914. private _multiRenderTarget;
  66915. private _ratio;
  66916. private _enablePosition;
  66917. private _enableVelocity;
  66918. private _enableReflectivity;
  66919. private _positionIndex;
  66920. private _velocityIndex;
  66921. private _reflectivityIndex;
  66922. protected _effect: Effect;
  66923. protected _cachedDefines: string;
  66924. /**
  66925. * Set the render list (meshes to be rendered) used in the G buffer.
  66926. */
  66927. set renderList(meshes: Mesh[]);
  66928. /**
  66929. * Gets wether or not G buffer are supported by the running hardware.
  66930. * This requires draw buffer supports
  66931. */
  66932. get isSupported(): boolean;
  66933. /**
  66934. * Returns the index of the given texture type in the G-Buffer textures array
  66935. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66936. * @returns the index of the given texture type in the G-Buffer textures array
  66937. */
  66938. getTextureIndex(textureType: number): number;
  66939. /**
  66940. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66941. */
  66942. get enablePosition(): boolean;
  66943. /**
  66944. * Sets whether or not objects positions are enabled for the G buffer.
  66945. */
  66946. set enablePosition(enable: boolean);
  66947. /**
  66948. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66949. */
  66950. get enableVelocity(): boolean;
  66951. /**
  66952. * Sets wether or not objects velocities are enabled for the G buffer.
  66953. */
  66954. set enableVelocity(enable: boolean);
  66955. /**
  66956. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  66957. */
  66958. get enableReflectivity(): boolean;
  66959. /**
  66960. * Sets wether or not objects roughness are enabled for the G buffer.
  66961. */
  66962. set enableReflectivity(enable: boolean);
  66963. /**
  66964. * Gets the scene associated with the buffer.
  66965. */
  66966. get scene(): Scene;
  66967. /**
  66968. * Gets the ratio used by the buffer during its creation.
  66969. * How big is the buffer related to the main canvas.
  66970. */
  66971. get ratio(): number;
  66972. /** @hidden */
  66973. static _SceneComponentInitialization: (scene: Scene) => void;
  66974. /**
  66975. * Creates a new G Buffer for the scene
  66976. * @param scene The scene the buffer belongs to
  66977. * @param ratio How big is the buffer related to the main canvas.
  66978. */
  66979. constructor(scene: Scene, ratio?: number);
  66980. /**
  66981. * Checks wether everything is ready to render a submesh to the G buffer.
  66982. * @param subMesh the submesh to check readiness for
  66983. * @param useInstances is the mesh drawn using instance or not
  66984. * @returns true if ready otherwise false
  66985. */
  66986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66987. /**
  66988. * Gets the current underlying G Buffer.
  66989. * @returns the buffer
  66990. */
  66991. getGBuffer(): MultiRenderTarget;
  66992. /**
  66993. * Gets the number of samples used to render the buffer (anti aliasing).
  66994. */
  66995. get samples(): number;
  66996. /**
  66997. * Sets the number of samples used to render the buffer (anti aliasing).
  66998. */
  66999. set samples(value: number);
  67000. /**
  67001. * Disposes the renderer and frees up associated resources.
  67002. */
  67003. dispose(): void;
  67004. protected _createRenderTargets(): void;
  67005. private _copyBonesTransformationMatrices;
  67006. }
  67007. }
  67008. declare module BABYLON {
  67009. interface Scene {
  67010. /** @hidden (Backing field) */
  67011. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67012. /**
  67013. * Gets or Sets the current geometry buffer associated to the scene.
  67014. */
  67015. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67016. /**
  67017. * Enables a GeometryBufferRender and associates it with the scene
  67018. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67019. * @returns the GeometryBufferRenderer
  67020. */
  67021. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67022. /**
  67023. * Disables the GeometryBufferRender associated with the scene
  67024. */
  67025. disableGeometryBufferRenderer(): void;
  67026. }
  67027. /**
  67028. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67029. * in several rendering techniques.
  67030. */
  67031. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67032. /**
  67033. * The component name helpful to identify the component in the list of scene components.
  67034. */
  67035. readonly name: string;
  67036. /**
  67037. * The scene the component belongs to.
  67038. */
  67039. scene: Scene;
  67040. /**
  67041. * Creates a new instance of the component for the given scene
  67042. * @param scene Defines the scene to register the component in
  67043. */
  67044. constructor(scene: Scene);
  67045. /**
  67046. * Registers the component in a given scene
  67047. */
  67048. register(): void;
  67049. /**
  67050. * Rebuilds the elements related to this component in case of
  67051. * context lost for instance.
  67052. */
  67053. rebuild(): void;
  67054. /**
  67055. * Disposes the component and the associated ressources
  67056. */
  67057. dispose(): void;
  67058. private _gatherRenderTargets;
  67059. }
  67060. }
  67061. declare module BABYLON {
  67062. /** @hidden */
  67063. export var motionBlurPixelShader: {
  67064. name: string;
  67065. shader: string;
  67066. };
  67067. }
  67068. declare module BABYLON {
  67069. /**
  67070. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67071. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67072. * As an example, all you have to do is to create the post-process:
  67073. * var mb = new BABYLON.MotionBlurPostProcess(
  67074. * 'mb', // The name of the effect.
  67075. * scene, // The scene containing the objects to blur according to their velocity.
  67076. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67077. * camera // The camera to apply the render pass to.
  67078. * );
  67079. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67080. */
  67081. export class MotionBlurPostProcess extends PostProcess {
  67082. /**
  67083. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67084. */
  67085. motionStrength: number;
  67086. /**
  67087. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67088. */
  67089. get motionBlurSamples(): number;
  67090. /**
  67091. * Sets the number of iterations to be used for motion blur quality
  67092. */
  67093. set motionBlurSamples(samples: number);
  67094. private _motionBlurSamples;
  67095. private _geometryBufferRenderer;
  67096. /**
  67097. * Creates a new instance MotionBlurPostProcess
  67098. * @param name The name of the effect.
  67099. * @param scene The scene containing the objects to blur according to their velocity.
  67100. * @param options The required width/height ratio to downsize to before computing the render pass.
  67101. * @param camera The camera to apply the render pass to.
  67102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67103. * @param engine The engine which the post process will be applied. (default: current engine)
  67104. * @param reusable If the post process can be reused on the same frame. (default: false)
  67105. * @param textureType Type of textures used when performing the post process. (default: 0)
  67106. * @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)
  67107. */
  67108. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67109. /**
  67110. * Excludes the given skinned mesh from computing bones velocities.
  67111. * 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.
  67112. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67113. */
  67114. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67115. /**
  67116. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67117. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67118. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67119. */
  67120. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67121. /**
  67122. * Disposes the post process.
  67123. * @param camera The camera to dispose the post process on.
  67124. */
  67125. dispose(camera?: Camera): void;
  67126. }
  67127. }
  67128. declare module BABYLON {
  67129. /** @hidden */
  67130. export var refractionPixelShader: {
  67131. name: string;
  67132. shader: string;
  67133. };
  67134. }
  67135. declare module BABYLON {
  67136. /**
  67137. * Post process which applies a refractin texture
  67138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67139. */
  67140. export class RefractionPostProcess extends PostProcess {
  67141. /** the base color of the refraction (used to taint the rendering) */
  67142. color: Color3;
  67143. /** simulated refraction depth */
  67144. depth: number;
  67145. /** the coefficient of the base color (0 to remove base color tainting) */
  67146. colorLevel: number;
  67147. private _refTexture;
  67148. private _ownRefractionTexture;
  67149. /**
  67150. * Gets or sets the refraction texture
  67151. * Please note that you are responsible for disposing the texture if you set it manually
  67152. */
  67153. get refractionTexture(): Texture;
  67154. set refractionTexture(value: Texture);
  67155. /**
  67156. * Initializes the RefractionPostProcess
  67157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67158. * @param name The name of the effect.
  67159. * @param refractionTextureUrl Url of the refraction texture to use
  67160. * @param color the base color of the refraction (used to taint the rendering)
  67161. * @param depth simulated refraction depth
  67162. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67163. * @param camera The camera to apply the render pass to.
  67164. * @param options The required width/height ratio to downsize to before computing the render pass.
  67165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67166. * @param engine The engine which the post process will be applied. (default: current engine)
  67167. * @param reusable If the post process can be reused on the same frame. (default: false)
  67168. */
  67169. constructor(name: string, refractionTextureUrl: string,
  67170. /** the base color of the refraction (used to taint the rendering) */
  67171. color: Color3,
  67172. /** simulated refraction depth */
  67173. depth: number,
  67174. /** the coefficient of the base color (0 to remove base color tainting) */
  67175. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67176. /**
  67177. * Disposes of the post process
  67178. * @param camera Camera to dispose post process on
  67179. */
  67180. dispose(camera: Camera): void;
  67181. }
  67182. }
  67183. declare module BABYLON {
  67184. /** @hidden */
  67185. export var sharpenPixelShader: {
  67186. name: string;
  67187. shader: string;
  67188. };
  67189. }
  67190. declare module BABYLON {
  67191. /**
  67192. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67193. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67194. */
  67195. export class SharpenPostProcess extends PostProcess {
  67196. /**
  67197. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67198. */
  67199. colorAmount: number;
  67200. /**
  67201. * How much sharpness should be applied (default: 0.3)
  67202. */
  67203. edgeAmount: number;
  67204. /**
  67205. * Creates a new instance ConvolutionPostProcess
  67206. * @param name The name of the effect.
  67207. * @param options The required width/height ratio to downsize to before computing the render pass.
  67208. * @param camera The camera to apply the render pass to.
  67209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67210. * @param engine The engine which the post process will be applied. (default: current engine)
  67211. * @param reusable If the post process can be reused on the same frame. (default: false)
  67212. * @param textureType Type of textures used when performing the post process. (default: 0)
  67213. * @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)
  67214. */
  67215. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67216. }
  67217. }
  67218. declare module BABYLON {
  67219. /**
  67220. * PostProcessRenderPipeline
  67221. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67222. */
  67223. export class PostProcessRenderPipeline {
  67224. private engine;
  67225. private _renderEffects;
  67226. private _renderEffectsForIsolatedPass;
  67227. /**
  67228. * List of inspectable custom properties (used by the Inspector)
  67229. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67230. */
  67231. inspectableCustomProperties: IInspectable[];
  67232. /**
  67233. * @hidden
  67234. */
  67235. protected _cameras: Camera[];
  67236. /** @hidden */
  67237. _name: string;
  67238. /**
  67239. * Gets pipeline name
  67240. */
  67241. get name(): string;
  67242. /** Gets the list of attached cameras */
  67243. get cameras(): Camera[];
  67244. /**
  67245. * Initializes a PostProcessRenderPipeline
  67246. * @param engine engine to add the pipeline to
  67247. * @param name name of the pipeline
  67248. */
  67249. constructor(engine: Engine, name: string);
  67250. /**
  67251. * Gets the class name
  67252. * @returns "PostProcessRenderPipeline"
  67253. */
  67254. getClassName(): string;
  67255. /**
  67256. * If all the render effects in the pipeline are supported
  67257. */
  67258. get isSupported(): boolean;
  67259. /**
  67260. * Adds an effect to the pipeline
  67261. * @param renderEffect the effect to add
  67262. */
  67263. addEffect(renderEffect: PostProcessRenderEffect): void;
  67264. /** @hidden */
  67265. _rebuild(): void;
  67266. /** @hidden */
  67267. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67268. /** @hidden */
  67269. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67270. /** @hidden */
  67271. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67272. /** @hidden */
  67273. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67274. /** @hidden */
  67275. _attachCameras(cameras: Camera, unique: boolean): void;
  67276. /** @hidden */
  67277. _attachCameras(cameras: Camera[], unique: boolean): void;
  67278. /** @hidden */
  67279. _detachCameras(cameras: Camera): void;
  67280. /** @hidden */
  67281. _detachCameras(cameras: Nullable<Camera[]>): void;
  67282. /** @hidden */
  67283. _update(): void;
  67284. /** @hidden */
  67285. _reset(): void;
  67286. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67287. /**
  67288. * Disposes of the pipeline
  67289. */
  67290. dispose(): void;
  67291. }
  67292. }
  67293. declare module BABYLON {
  67294. /**
  67295. * PostProcessRenderPipelineManager class
  67296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67297. */
  67298. export class PostProcessRenderPipelineManager {
  67299. private _renderPipelines;
  67300. /**
  67301. * Initializes a PostProcessRenderPipelineManager
  67302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67303. */
  67304. constructor();
  67305. /**
  67306. * Gets the list of supported render pipelines
  67307. */
  67308. get supportedPipelines(): PostProcessRenderPipeline[];
  67309. /**
  67310. * Adds a pipeline to the manager
  67311. * @param renderPipeline The pipeline to add
  67312. */
  67313. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67314. /**
  67315. * Attaches a camera to the pipeline
  67316. * @param renderPipelineName The name of the pipeline to attach to
  67317. * @param cameras the camera to attach
  67318. * @param unique if the camera can be attached multiple times to the pipeline
  67319. */
  67320. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67321. /**
  67322. * Detaches a camera from the pipeline
  67323. * @param renderPipelineName The name of the pipeline to detach from
  67324. * @param cameras the camera to detach
  67325. */
  67326. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67327. /**
  67328. * Enables an effect by name on a pipeline
  67329. * @param renderPipelineName the name of the pipeline to enable the effect in
  67330. * @param renderEffectName the name of the effect to enable
  67331. * @param cameras the cameras that the effect should be enabled on
  67332. */
  67333. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67334. /**
  67335. * Disables an effect by name on a pipeline
  67336. * @param renderPipelineName the name of the pipeline to disable the effect in
  67337. * @param renderEffectName the name of the effect to disable
  67338. * @param cameras the cameras that the effect should be disabled on
  67339. */
  67340. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67341. /**
  67342. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67343. */
  67344. update(): void;
  67345. /** @hidden */
  67346. _rebuild(): void;
  67347. /**
  67348. * Disposes of the manager and pipelines
  67349. */
  67350. dispose(): void;
  67351. }
  67352. }
  67353. declare module BABYLON {
  67354. interface Scene {
  67355. /** @hidden (Backing field) */
  67356. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67357. /**
  67358. * Gets the postprocess render pipeline manager
  67359. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67360. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67361. */
  67362. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67363. }
  67364. /**
  67365. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67366. */
  67367. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67368. /**
  67369. * The component name helpfull to identify the component in the list of scene components.
  67370. */
  67371. readonly name: string;
  67372. /**
  67373. * The scene the component belongs to.
  67374. */
  67375. scene: Scene;
  67376. /**
  67377. * Creates a new instance of the component for the given scene
  67378. * @param scene Defines the scene to register the component in
  67379. */
  67380. constructor(scene: Scene);
  67381. /**
  67382. * Registers the component in a given scene
  67383. */
  67384. register(): void;
  67385. /**
  67386. * Rebuilds the elements related to this component in case of
  67387. * context lost for instance.
  67388. */
  67389. rebuild(): void;
  67390. /**
  67391. * Disposes the component and the associated ressources
  67392. */
  67393. dispose(): void;
  67394. private _gatherRenderTargets;
  67395. }
  67396. }
  67397. declare module BABYLON {
  67398. /**
  67399. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67400. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67401. */
  67402. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67403. private _scene;
  67404. private _camerasToBeAttached;
  67405. /**
  67406. * ID of the sharpen post process,
  67407. */
  67408. private readonly SharpenPostProcessId;
  67409. /**
  67410. * @ignore
  67411. * ID of the image processing post process;
  67412. */
  67413. readonly ImageProcessingPostProcessId: string;
  67414. /**
  67415. * @ignore
  67416. * ID of the Fast Approximate Anti-Aliasing post process;
  67417. */
  67418. readonly FxaaPostProcessId: string;
  67419. /**
  67420. * ID of the chromatic aberration post process,
  67421. */
  67422. private readonly ChromaticAberrationPostProcessId;
  67423. /**
  67424. * ID of the grain post process
  67425. */
  67426. private readonly GrainPostProcessId;
  67427. /**
  67428. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67429. */
  67430. sharpen: SharpenPostProcess;
  67431. private _sharpenEffect;
  67432. private bloom;
  67433. /**
  67434. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67435. */
  67436. depthOfField: DepthOfFieldEffect;
  67437. /**
  67438. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67439. */
  67440. fxaa: FxaaPostProcess;
  67441. /**
  67442. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67443. */
  67444. imageProcessing: ImageProcessingPostProcess;
  67445. /**
  67446. * Chromatic aberration post process which will shift rgb colors in the image
  67447. */
  67448. chromaticAberration: ChromaticAberrationPostProcess;
  67449. private _chromaticAberrationEffect;
  67450. /**
  67451. * Grain post process which add noise to the image
  67452. */
  67453. grain: GrainPostProcess;
  67454. private _grainEffect;
  67455. /**
  67456. * Glow post process which adds a glow to emissive areas of the image
  67457. */
  67458. private _glowLayer;
  67459. /**
  67460. * Animations which can be used to tweak settings over a period of time
  67461. */
  67462. animations: Animation[];
  67463. private _imageProcessingConfigurationObserver;
  67464. private _sharpenEnabled;
  67465. private _bloomEnabled;
  67466. private _depthOfFieldEnabled;
  67467. private _depthOfFieldBlurLevel;
  67468. private _fxaaEnabled;
  67469. private _imageProcessingEnabled;
  67470. private _defaultPipelineTextureType;
  67471. private _bloomScale;
  67472. private _chromaticAberrationEnabled;
  67473. private _grainEnabled;
  67474. private _buildAllowed;
  67475. /**
  67476. * Gets active scene
  67477. */
  67478. get scene(): Scene;
  67479. /**
  67480. * Enable or disable the sharpen process from the pipeline
  67481. */
  67482. set sharpenEnabled(enabled: boolean);
  67483. get sharpenEnabled(): boolean;
  67484. private _resizeObserver;
  67485. private _hardwareScaleLevel;
  67486. private _bloomKernel;
  67487. /**
  67488. * Specifies the size of the bloom blur kernel, relative to the final output size
  67489. */
  67490. get bloomKernel(): number;
  67491. set bloomKernel(value: number);
  67492. /**
  67493. * Specifies the weight of the bloom in the final rendering
  67494. */
  67495. private _bloomWeight;
  67496. /**
  67497. * Specifies the luma threshold for the area that will be blurred by the bloom
  67498. */
  67499. private _bloomThreshold;
  67500. private _hdr;
  67501. /**
  67502. * The strength of the bloom.
  67503. */
  67504. set bloomWeight(value: number);
  67505. get bloomWeight(): number;
  67506. /**
  67507. * The strength of the bloom.
  67508. */
  67509. set bloomThreshold(value: number);
  67510. get bloomThreshold(): number;
  67511. /**
  67512. * The scale of the bloom, lower value will provide better performance.
  67513. */
  67514. set bloomScale(value: number);
  67515. get bloomScale(): number;
  67516. /**
  67517. * Enable or disable the bloom from the pipeline
  67518. */
  67519. set bloomEnabled(enabled: boolean);
  67520. get bloomEnabled(): boolean;
  67521. private _rebuildBloom;
  67522. /**
  67523. * If the depth of field is enabled.
  67524. */
  67525. get depthOfFieldEnabled(): boolean;
  67526. set depthOfFieldEnabled(enabled: boolean);
  67527. /**
  67528. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67529. */
  67530. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67531. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67532. /**
  67533. * If the anti aliasing is enabled.
  67534. */
  67535. set fxaaEnabled(enabled: boolean);
  67536. get fxaaEnabled(): boolean;
  67537. private _samples;
  67538. /**
  67539. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67540. */
  67541. set samples(sampleCount: number);
  67542. get samples(): number;
  67543. /**
  67544. * If image processing is enabled.
  67545. */
  67546. set imageProcessingEnabled(enabled: boolean);
  67547. get imageProcessingEnabled(): boolean;
  67548. /**
  67549. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67550. */
  67551. set glowLayerEnabled(enabled: boolean);
  67552. get glowLayerEnabled(): boolean;
  67553. /**
  67554. * Gets the glow layer (or null if not defined)
  67555. */
  67556. get glowLayer(): Nullable<GlowLayer>;
  67557. /**
  67558. * Enable or disable the chromaticAberration process from the pipeline
  67559. */
  67560. set chromaticAberrationEnabled(enabled: boolean);
  67561. get chromaticAberrationEnabled(): boolean;
  67562. /**
  67563. * Enable or disable the grain process from the pipeline
  67564. */
  67565. set grainEnabled(enabled: boolean);
  67566. get grainEnabled(): boolean;
  67567. /**
  67568. * @constructor
  67569. * @param name - The rendering pipeline name (default: "")
  67570. * @param hdr - If high dynamic range textures should be used (default: true)
  67571. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67572. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67573. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67574. */
  67575. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67576. /**
  67577. * Get the class name
  67578. * @returns "DefaultRenderingPipeline"
  67579. */
  67580. getClassName(): string;
  67581. /**
  67582. * Force the compilation of the entire pipeline.
  67583. */
  67584. prepare(): void;
  67585. private _hasCleared;
  67586. private _prevPostProcess;
  67587. private _prevPrevPostProcess;
  67588. private _setAutoClearAndTextureSharing;
  67589. private _depthOfFieldSceneObserver;
  67590. private _buildPipeline;
  67591. private _disposePostProcesses;
  67592. /**
  67593. * Adds a camera to the pipeline
  67594. * @param camera the camera to be added
  67595. */
  67596. addCamera(camera: Camera): void;
  67597. /**
  67598. * Removes a camera from the pipeline
  67599. * @param camera the camera to remove
  67600. */
  67601. removeCamera(camera: Camera): void;
  67602. /**
  67603. * Dispose of the pipeline and stop all post processes
  67604. */
  67605. dispose(): void;
  67606. /**
  67607. * Serialize the rendering pipeline (Used when exporting)
  67608. * @returns the serialized object
  67609. */
  67610. serialize(): any;
  67611. /**
  67612. * Parse the serialized pipeline
  67613. * @param source Source pipeline.
  67614. * @param scene The scene to load the pipeline to.
  67615. * @param rootUrl The URL of the serialized pipeline.
  67616. * @returns An instantiated pipeline from the serialized object.
  67617. */
  67618. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67619. }
  67620. }
  67621. declare module BABYLON {
  67622. /** @hidden */
  67623. export var lensHighlightsPixelShader: {
  67624. name: string;
  67625. shader: string;
  67626. };
  67627. }
  67628. declare module BABYLON {
  67629. /** @hidden */
  67630. export var depthOfFieldPixelShader: {
  67631. name: string;
  67632. shader: string;
  67633. };
  67634. }
  67635. declare module BABYLON {
  67636. /**
  67637. * BABYLON.JS Chromatic Aberration GLSL Shader
  67638. * Author: Olivier Guyot
  67639. * Separates very slightly R, G and B colors on the edges of the screen
  67640. * Inspired by Francois Tarlier & Martins Upitis
  67641. */
  67642. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67643. /**
  67644. * @ignore
  67645. * The chromatic aberration PostProcess id in the pipeline
  67646. */
  67647. LensChromaticAberrationEffect: string;
  67648. /**
  67649. * @ignore
  67650. * The highlights enhancing PostProcess id in the pipeline
  67651. */
  67652. HighlightsEnhancingEffect: string;
  67653. /**
  67654. * @ignore
  67655. * The depth-of-field PostProcess id in the pipeline
  67656. */
  67657. LensDepthOfFieldEffect: string;
  67658. private _scene;
  67659. private _depthTexture;
  67660. private _grainTexture;
  67661. private _chromaticAberrationPostProcess;
  67662. private _highlightsPostProcess;
  67663. private _depthOfFieldPostProcess;
  67664. private _edgeBlur;
  67665. private _grainAmount;
  67666. private _chromaticAberration;
  67667. private _distortion;
  67668. private _highlightsGain;
  67669. private _highlightsThreshold;
  67670. private _dofDistance;
  67671. private _dofAperture;
  67672. private _dofDarken;
  67673. private _dofPentagon;
  67674. private _blurNoise;
  67675. /**
  67676. * @constructor
  67677. *
  67678. * Effect parameters are as follow:
  67679. * {
  67680. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67681. * edge_blur: number; // from 0 to x (1 for realism)
  67682. * distortion: number; // from 0 to x (1 for realism)
  67683. * grain_amount: number; // from 0 to 1
  67684. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67685. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67686. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67687. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67688. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67689. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67690. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67691. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67692. * }
  67693. * Note: if an effect parameter is unset, effect is disabled
  67694. *
  67695. * @param name The rendering pipeline name
  67696. * @param parameters - An object containing all parameters (see above)
  67697. * @param scene The scene linked to this pipeline
  67698. * @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)
  67699. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67700. */
  67701. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67702. /**
  67703. * Get the class name
  67704. * @returns "LensRenderingPipeline"
  67705. */
  67706. getClassName(): string;
  67707. /**
  67708. * Gets associated scene
  67709. */
  67710. get scene(): Scene;
  67711. /**
  67712. * Gets or sets the edge blur
  67713. */
  67714. get edgeBlur(): number;
  67715. set edgeBlur(value: number);
  67716. /**
  67717. * Gets or sets the grain amount
  67718. */
  67719. get grainAmount(): number;
  67720. set grainAmount(value: number);
  67721. /**
  67722. * Gets or sets the chromatic aberration amount
  67723. */
  67724. get chromaticAberration(): number;
  67725. set chromaticAberration(value: number);
  67726. /**
  67727. * Gets or sets the depth of field aperture
  67728. */
  67729. get dofAperture(): number;
  67730. set dofAperture(value: number);
  67731. /**
  67732. * Gets or sets the edge distortion
  67733. */
  67734. get edgeDistortion(): number;
  67735. set edgeDistortion(value: number);
  67736. /**
  67737. * Gets or sets the depth of field distortion
  67738. */
  67739. get dofDistortion(): number;
  67740. set dofDistortion(value: number);
  67741. /**
  67742. * Gets or sets the darken out of focus amount
  67743. */
  67744. get darkenOutOfFocus(): number;
  67745. set darkenOutOfFocus(value: number);
  67746. /**
  67747. * Gets or sets a boolean indicating if blur noise is enabled
  67748. */
  67749. get blurNoise(): boolean;
  67750. set blurNoise(value: boolean);
  67751. /**
  67752. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67753. */
  67754. get pentagonBokeh(): boolean;
  67755. set pentagonBokeh(value: boolean);
  67756. /**
  67757. * Gets or sets the highlight grain amount
  67758. */
  67759. get highlightsGain(): number;
  67760. set highlightsGain(value: number);
  67761. /**
  67762. * Gets or sets the highlight threshold
  67763. */
  67764. get highlightsThreshold(): number;
  67765. set highlightsThreshold(value: number);
  67766. /**
  67767. * Sets the amount of blur at the edges
  67768. * @param amount blur amount
  67769. */
  67770. setEdgeBlur(amount: number): void;
  67771. /**
  67772. * Sets edge blur to 0
  67773. */
  67774. disableEdgeBlur(): void;
  67775. /**
  67776. * Sets the amout of grain
  67777. * @param amount Amount of grain
  67778. */
  67779. setGrainAmount(amount: number): void;
  67780. /**
  67781. * Set grain amount to 0
  67782. */
  67783. disableGrain(): void;
  67784. /**
  67785. * Sets the chromatic aberration amount
  67786. * @param amount amount of chromatic aberration
  67787. */
  67788. setChromaticAberration(amount: number): void;
  67789. /**
  67790. * Sets chromatic aberration amount to 0
  67791. */
  67792. disableChromaticAberration(): void;
  67793. /**
  67794. * Sets the EdgeDistortion amount
  67795. * @param amount amount of EdgeDistortion
  67796. */
  67797. setEdgeDistortion(amount: number): void;
  67798. /**
  67799. * Sets edge distortion to 0
  67800. */
  67801. disableEdgeDistortion(): void;
  67802. /**
  67803. * Sets the FocusDistance amount
  67804. * @param amount amount of FocusDistance
  67805. */
  67806. setFocusDistance(amount: number): void;
  67807. /**
  67808. * Disables depth of field
  67809. */
  67810. disableDepthOfField(): void;
  67811. /**
  67812. * Sets the Aperture amount
  67813. * @param amount amount of Aperture
  67814. */
  67815. setAperture(amount: number): void;
  67816. /**
  67817. * Sets the DarkenOutOfFocus amount
  67818. * @param amount amount of DarkenOutOfFocus
  67819. */
  67820. setDarkenOutOfFocus(amount: number): void;
  67821. private _pentagonBokehIsEnabled;
  67822. /**
  67823. * Creates a pentagon bokeh effect
  67824. */
  67825. enablePentagonBokeh(): void;
  67826. /**
  67827. * Disables the pentagon bokeh effect
  67828. */
  67829. disablePentagonBokeh(): void;
  67830. /**
  67831. * Enables noise blur
  67832. */
  67833. enableNoiseBlur(): void;
  67834. /**
  67835. * Disables noise blur
  67836. */
  67837. disableNoiseBlur(): void;
  67838. /**
  67839. * Sets the HighlightsGain amount
  67840. * @param amount amount of HighlightsGain
  67841. */
  67842. setHighlightsGain(amount: number): void;
  67843. /**
  67844. * Sets the HighlightsThreshold amount
  67845. * @param amount amount of HighlightsThreshold
  67846. */
  67847. setHighlightsThreshold(amount: number): void;
  67848. /**
  67849. * Disables highlights
  67850. */
  67851. disableHighlights(): void;
  67852. /**
  67853. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67854. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67855. */
  67856. dispose(disableDepthRender?: boolean): void;
  67857. private _createChromaticAberrationPostProcess;
  67858. private _createHighlightsPostProcess;
  67859. private _createDepthOfFieldPostProcess;
  67860. private _createGrainTexture;
  67861. }
  67862. }
  67863. declare module BABYLON {
  67864. /** @hidden */
  67865. export var ssao2PixelShader: {
  67866. name: string;
  67867. shader: string;
  67868. };
  67869. }
  67870. declare module BABYLON {
  67871. /** @hidden */
  67872. export var ssaoCombinePixelShader: {
  67873. name: string;
  67874. shader: string;
  67875. };
  67876. }
  67877. declare module BABYLON {
  67878. /**
  67879. * Render pipeline to produce ssao effect
  67880. */
  67881. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67882. /**
  67883. * @ignore
  67884. * The PassPostProcess id in the pipeline that contains the original scene color
  67885. */
  67886. SSAOOriginalSceneColorEffect: string;
  67887. /**
  67888. * @ignore
  67889. * The SSAO PostProcess id in the pipeline
  67890. */
  67891. SSAORenderEffect: string;
  67892. /**
  67893. * @ignore
  67894. * The horizontal blur PostProcess id in the pipeline
  67895. */
  67896. SSAOBlurHRenderEffect: string;
  67897. /**
  67898. * @ignore
  67899. * The vertical blur PostProcess id in the pipeline
  67900. */
  67901. SSAOBlurVRenderEffect: string;
  67902. /**
  67903. * @ignore
  67904. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67905. */
  67906. SSAOCombineRenderEffect: string;
  67907. /**
  67908. * The output strength of the SSAO post-process. Default value is 1.0.
  67909. */
  67910. totalStrength: number;
  67911. /**
  67912. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67913. */
  67914. maxZ: number;
  67915. /**
  67916. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67917. */
  67918. minZAspect: number;
  67919. private _samples;
  67920. /**
  67921. * Number of samples used for the SSAO calculations. Default value is 8
  67922. */
  67923. set samples(n: number);
  67924. get samples(): number;
  67925. private _textureSamples;
  67926. /**
  67927. * Number of samples to use for antialiasing
  67928. */
  67929. set textureSamples(n: number);
  67930. get textureSamples(): number;
  67931. /**
  67932. * Ratio object used for SSAO ratio and blur ratio
  67933. */
  67934. private _ratio;
  67935. /**
  67936. * Dynamically generated sphere sampler.
  67937. */
  67938. private _sampleSphere;
  67939. /**
  67940. * Blur filter offsets
  67941. */
  67942. private _samplerOffsets;
  67943. private _expensiveBlur;
  67944. /**
  67945. * If bilateral blur should be used
  67946. */
  67947. set expensiveBlur(b: boolean);
  67948. get expensiveBlur(): boolean;
  67949. /**
  67950. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67951. */
  67952. radius: number;
  67953. /**
  67954. * The base color of the SSAO post-process
  67955. * The final result is "base + ssao" between [0, 1]
  67956. */
  67957. base: number;
  67958. /**
  67959. * Support test.
  67960. */
  67961. static get IsSupported(): boolean;
  67962. private _scene;
  67963. private _depthTexture;
  67964. private _normalTexture;
  67965. private _randomTexture;
  67966. private _originalColorPostProcess;
  67967. private _ssaoPostProcess;
  67968. private _blurHPostProcess;
  67969. private _blurVPostProcess;
  67970. private _ssaoCombinePostProcess;
  67971. /**
  67972. * Gets active scene
  67973. */
  67974. get scene(): Scene;
  67975. /**
  67976. * @constructor
  67977. * @param name The rendering pipeline name
  67978. * @param scene The scene linked to this pipeline
  67979. * @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 }
  67980. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67981. */
  67982. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67983. /**
  67984. * Get the class name
  67985. * @returns "SSAO2RenderingPipeline"
  67986. */
  67987. getClassName(): string;
  67988. /**
  67989. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67990. */
  67991. dispose(disableGeometryBufferRenderer?: boolean): void;
  67992. private _createBlurPostProcess;
  67993. /** @hidden */
  67994. _rebuild(): void;
  67995. private _bits;
  67996. private _radicalInverse_VdC;
  67997. private _hammersley;
  67998. private _hemisphereSample_uniform;
  67999. private _generateHemisphere;
  68000. private _createSSAOPostProcess;
  68001. private _createSSAOCombinePostProcess;
  68002. private _createRandomTexture;
  68003. /**
  68004. * Serialize the rendering pipeline (Used when exporting)
  68005. * @returns the serialized object
  68006. */
  68007. serialize(): any;
  68008. /**
  68009. * Parse the serialized pipeline
  68010. * @param source Source pipeline.
  68011. * @param scene The scene to load the pipeline to.
  68012. * @param rootUrl The URL of the serialized pipeline.
  68013. * @returns An instantiated pipeline from the serialized object.
  68014. */
  68015. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export var ssaoPixelShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module BABYLON {
  68026. /**
  68027. * Render pipeline to produce ssao effect
  68028. */
  68029. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68030. /**
  68031. * @ignore
  68032. * The PassPostProcess id in the pipeline that contains the original scene color
  68033. */
  68034. SSAOOriginalSceneColorEffect: string;
  68035. /**
  68036. * @ignore
  68037. * The SSAO PostProcess id in the pipeline
  68038. */
  68039. SSAORenderEffect: string;
  68040. /**
  68041. * @ignore
  68042. * The horizontal blur PostProcess id in the pipeline
  68043. */
  68044. SSAOBlurHRenderEffect: string;
  68045. /**
  68046. * @ignore
  68047. * The vertical blur PostProcess id in the pipeline
  68048. */
  68049. SSAOBlurVRenderEffect: string;
  68050. /**
  68051. * @ignore
  68052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68053. */
  68054. SSAOCombineRenderEffect: string;
  68055. /**
  68056. * The output strength of the SSAO post-process. Default value is 1.0.
  68057. */
  68058. totalStrength: number;
  68059. /**
  68060. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68061. */
  68062. radius: number;
  68063. /**
  68064. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68065. * Must not be equal to fallOff and superior to fallOff.
  68066. * Default value is 0.0075
  68067. */
  68068. area: number;
  68069. /**
  68070. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68071. * Must not be equal to area and inferior to area.
  68072. * Default value is 0.000001
  68073. */
  68074. fallOff: number;
  68075. /**
  68076. * The base color of the SSAO post-process
  68077. * The final result is "base + ssao" between [0, 1]
  68078. */
  68079. base: number;
  68080. private _scene;
  68081. private _depthTexture;
  68082. private _randomTexture;
  68083. private _originalColorPostProcess;
  68084. private _ssaoPostProcess;
  68085. private _blurHPostProcess;
  68086. private _blurVPostProcess;
  68087. private _ssaoCombinePostProcess;
  68088. private _firstUpdate;
  68089. /**
  68090. * Gets active scene
  68091. */
  68092. get scene(): Scene;
  68093. /**
  68094. * @constructor
  68095. * @param name - The rendering pipeline name
  68096. * @param scene - The scene linked to this pipeline
  68097. * @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 }
  68098. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68099. */
  68100. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68101. /**
  68102. * Get the class name
  68103. * @returns "SSAORenderingPipeline"
  68104. */
  68105. getClassName(): string;
  68106. /**
  68107. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68108. */
  68109. dispose(disableDepthRender?: boolean): void;
  68110. private _createBlurPostProcess;
  68111. /** @hidden */
  68112. _rebuild(): void;
  68113. private _createSSAOPostProcess;
  68114. private _createSSAOCombinePostProcess;
  68115. private _createRandomTexture;
  68116. }
  68117. }
  68118. declare module BABYLON {
  68119. /** @hidden */
  68120. export var screenSpaceReflectionPixelShader: {
  68121. name: string;
  68122. shader: string;
  68123. };
  68124. }
  68125. declare module BABYLON {
  68126. /**
  68127. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68128. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68129. */
  68130. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68131. /**
  68132. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68133. */
  68134. threshold: number;
  68135. /**
  68136. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68137. */
  68138. strength: number;
  68139. /**
  68140. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68141. */
  68142. reflectionSpecularFalloffExponent: number;
  68143. /**
  68144. * 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]
  68145. */
  68146. step: number;
  68147. /**
  68148. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68149. */
  68150. roughnessFactor: number;
  68151. private _geometryBufferRenderer;
  68152. private _enableSmoothReflections;
  68153. private _reflectionSamples;
  68154. private _smoothSteps;
  68155. /**
  68156. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68157. * @param name The name of the effect.
  68158. * @param scene The scene containing the objects to calculate reflections.
  68159. * @param options The required width/height ratio to downsize to before computing the render pass.
  68160. * @param camera The camera to apply the render pass to.
  68161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68162. * @param engine The engine which the post process will be applied. (default: current engine)
  68163. * @param reusable If the post process can be reused on the same frame. (default: false)
  68164. * @param textureType Type of textures used when performing the post process. (default: 0)
  68165. * @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)
  68166. */
  68167. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68168. /**
  68169. * Gets wether or not smoothing reflections is enabled.
  68170. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68171. */
  68172. get enableSmoothReflections(): boolean;
  68173. /**
  68174. * Sets wether or not smoothing reflections is enabled.
  68175. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68176. */
  68177. set enableSmoothReflections(enabled: boolean);
  68178. /**
  68179. * Gets the number of samples taken while computing reflections. More samples count is high,
  68180. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68181. */
  68182. get reflectionSamples(): number;
  68183. /**
  68184. * Sets the number of samples taken while computing reflections. More samples count is high,
  68185. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68186. */
  68187. set reflectionSamples(samples: number);
  68188. /**
  68189. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68190. * more the post-process will require GPU power and can generate a drop in FPS.
  68191. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68192. */
  68193. get smoothSteps(): number;
  68194. set smoothSteps(steps: number);
  68195. private _updateEffectDefines;
  68196. }
  68197. }
  68198. declare module BABYLON {
  68199. /** @hidden */
  68200. export var standardPixelShader: {
  68201. name: string;
  68202. shader: string;
  68203. };
  68204. }
  68205. declare module BABYLON {
  68206. /**
  68207. * Standard rendering pipeline
  68208. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68209. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68210. */
  68211. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68212. /**
  68213. * Public members
  68214. */
  68215. /**
  68216. * Post-process which contains the original scene color before the pipeline applies all the effects
  68217. */
  68218. originalPostProcess: Nullable<PostProcess>;
  68219. /**
  68220. * Post-process used to down scale an image x4
  68221. */
  68222. downSampleX4PostProcess: Nullable<PostProcess>;
  68223. /**
  68224. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68225. */
  68226. brightPassPostProcess: Nullable<PostProcess>;
  68227. /**
  68228. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68229. */
  68230. blurHPostProcesses: PostProcess[];
  68231. /**
  68232. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68233. */
  68234. blurVPostProcesses: PostProcess[];
  68235. /**
  68236. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68237. */
  68238. textureAdderPostProcess: Nullable<PostProcess>;
  68239. /**
  68240. * Post-process used to create volumetric lighting effect
  68241. */
  68242. volumetricLightPostProcess: Nullable<PostProcess>;
  68243. /**
  68244. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68245. */
  68246. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68247. /**
  68248. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68249. */
  68250. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68251. /**
  68252. * Post-process used to merge the volumetric light effect and the real scene color
  68253. */
  68254. volumetricLightMergePostProces: Nullable<PostProcess>;
  68255. /**
  68256. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68257. */
  68258. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68259. /**
  68260. * Base post-process used to calculate the average luminance of the final image for HDR
  68261. */
  68262. luminancePostProcess: Nullable<PostProcess>;
  68263. /**
  68264. * Post-processes used to create down sample post-processes in order to get
  68265. * the average luminance of the final image for HDR
  68266. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68267. */
  68268. luminanceDownSamplePostProcesses: PostProcess[];
  68269. /**
  68270. * Post-process used to create a HDR effect (light adaptation)
  68271. */
  68272. hdrPostProcess: Nullable<PostProcess>;
  68273. /**
  68274. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68275. */
  68276. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68277. /**
  68278. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68279. */
  68280. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68281. /**
  68282. * Post-process used to merge the final HDR post-process and the real scene color
  68283. */
  68284. hdrFinalPostProcess: Nullable<PostProcess>;
  68285. /**
  68286. * Post-process used to create a lens flare effect
  68287. */
  68288. lensFlarePostProcess: Nullable<PostProcess>;
  68289. /**
  68290. * Post-process that merges the result of the lens flare post-process and the real scene color
  68291. */
  68292. lensFlareComposePostProcess: Nullable<PostProcess>;
  68293. /**
  68294. * Post-process used to create a motion blur effect
  68295. */
  68296. motionBlurPostProcess: Nullable<PostProcess>;
  68297. /**
  68298. * Post-process used to create a depth of field effect
  68299. */
  68300. depthOfFieldPostProcess: Nullable<PostProcess>;
  68301. /**
  68302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68303. */
  68304. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68305. /**
  68306. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68307. */
  68308. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68309. /**
  68310. * Represents the brightness threshold in order to configure the illuminated surfaces
  68311. */
  68312. brightThreshold: number;
  68313. /**
  68314. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68315. */
  68316. blurWidth: number;
  68317. /**
  68318. * Sets if the blur for highlighted surfaces must be only horizontal
  68319. */
  68320. horizontalBlur: boolean;
  68321. /**
  68322. * Gets the overall exposure used by the pipeline
  68323. */
  68324. get exposure(): number;
  68325. /**
  68326. * Sets the overall exposure used by the pipeline
  68327. */
  68328. set exposure(value: number);
  68329. /**
  68330. * Texture used typically to simulate "dirty" on camera lens
  68331. */
  68332. lensTexture: Nullable<Texture>;
  68333. /**
  68334. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68335. */
  68336. volumetricLightCoefficient: number;
  68337. /**
  68338. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68339. */
  68340. volumetricLightPower: number;
  68341. /**
  68342. * Used the set the blur intensity to smooth the volumetric lights
  68343. */
  68344. volumetricLightBlurScale: number;
  68345. /**
  68346. * Light (spot or directional) used to generate the volumetric lights rays
  68347. * The source light must have a shadow generate so the pipeline can get its
  68348. * depth map
  68349. */
  68350. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68351. /**
  68352. * For eye adaptation, represents the minimum luminance the eye can see
  68353. */
  68354. hdrMinimumLuminance: number;
  68355. /**
  68356. * For eye adaptation, represents the decrease luminance speed
  68357. */
  68358. hdrDecreaseRate: number;
  68359. /**
  68360. * For eye adaptation, represents the increase luminance speed
  68361. */
  68362. hdrIncreaseRate: number;
  68363. /**
  68364. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68365. */
  68366. get hdrAutoExposure(): boolean;
  68367. /**
  68368. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68369. */
  68370. set hdrAutoExposure(value: boolean);
  68371. /**
  68372. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68373. */
  68374. lensColorTexture: Nullable<Texture>;
  68375. /**
  68376. * The overall strengh for the lens flare effect
  68377. */
  68378. lensFlareStrength: number;
  68379. /**
  68380. * Dispersion coefficient for lens flare ghosts
  68381. */
  68382. lensFlareGhostDispersal: number;
  68383. /**
  68384. * Main lens flare halo width
  68385. */
  68386. lensFlareHaloWidth: number;
  68387. /**
  68388. * Based on the lens distortion effect, defines how much the lens flare result
  68389. * is distorted
  68390. */
  68391. lensFlareDistortionStrength: number;
  68392. /**
  68393. * Configures the blur intensity used for for lens flare (halo)
  68394. */
  68395. lensFlareBlurWidth: number;
  68396. /**
  68397. * Lens star texture must be used to simulate rays on the flares and is available
  68398. * in the documentation
  68399. */
  68400. lensStarTexture: Nullable<Texture>;
  68401. /**
  68402. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68403. * flare effect by taking account of the dirt texture
  68404. */
  68405. lensFlareDirtTexture: Nullable<Texture>;
  68406. /**
  68407. * Represents the focal length for the depth of field effect
  68408. */
  68409. depthOfFieldDistance: number;
  68410. /**
  68411. * Represents the blur intensity for the blurred part of the depth of field effect
  68412. */
  68413. depthOfFieldBlurWidth: number;
  68414. /**
  68415. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68416. */
  68417. get motionStrength(): number;
  68418. /**
  68419. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68420. */
  68421. set motionStrength(strength: number);
  68422. /**
  68423. * Gets wether or not the motion blur post-process is object based or screen based.
  68424. */
  68425. get objectBasedMotionBlur(): boolean;
  68426. /**
  68427. * Sets wether or not the motion blur post-process should be object based or screen based
  68428. */
  68429. set objectBasedMotionBlur(value: boolean);
  68430. /**
  68431. * List of animations for the pipeline (IAnimatable implementation)
  68432. */
  68433. animations: Animation[];
  68434. /**
  68435. * Private members
  68436. */
  68437. private _scene;
  68438. private _currentDepthOfFieldSource;
  68439. private _basePostProcess;
  68440. private _fixedExposure;
  68441. private _currentExposure;
  68442. private _hdrAutoExposure;
  68443. private _hdrCurrentLuminance;
  68444. private _motionStrength;
  68445. private _isObjectBasedMotionBlur;
  68446. private _floatTextureType;
  68447. private _camerasToBeAttached;
  68448. private _ratio;
  68449. private _bloomEnabled;
  68450. private _depthOfFieldEnabled;
  68451. private _vlsEnabled;
  68452. private _lensFlareEnabled;
  68453. private _hdrEnabled;
  68454. private _motionBlurEnabled;
  68455. private _fxaaEnabled;
  68456. private _screenSpaceReflectionsEnabled;
  68457. private _motionBlurSamples;
  68458. private _volumetricLightStepsCount;
  68459. private _samples;
  68460. /**
  68461. * @ignore
  68462. * Specifies if the bloom pipeline is enabled
  68463. */
  68464. get BloomEnabled(): boolean;
  68465. set BloomEnabled(enabled: boolean);
  68466. /**
  68467. * @ignore
  68468. * Specifies if the depth of field pipeline is enabed
  68469. */
  68470. get DepthOfFieldEnabled(): boolean;
  68471. set DepthOfFieldEnabled(enabled: boolean);
  68472. /**
  68473. * @ignore
  68474. * Specifies if the lens flare pipeline is enabed
  68475. */
  68476. get LensFlareEnabled(): boolean;
  68477. set LensFlareEnabled(enabled: boolean);
  68478. /**
  68479. * @ignore
  68480. * Specifies if the HDR pipeline is enabled
  68481. */
  68482. get HDREnabled(): boolean;
  68483. set HDREnabled(enabled: boolean);
  68484. /**
  68485. * @ignore
  68486. * Specifies if the volumetric lights scattering effect is enabled
  68487. */
  68488. get VLSEnabled(): boolean;
  68489. set VLSEnabled(enabled: boolean);
  68490. /**
  68491. * @ignore
  68492. * Specifies if the motion blur effect is enabled
  68493. */
  68494. get MotionBlurEnabled(): boolean;
  68495. set MotionBlurEnabled(enabled: boolean);
  68496. /**
  68497. * Specifies if anti-aliasing is enabled
  68498. */
  68499. get fxaaEnabled(): boolean;
  68500. set fxaaEnabled(enabled: boolean);
  68501. /**
  68502. * Specifies if screen space reflections are enabled.
  68503. */
  68504. get screenSpaceReflectionsEnabled(): boolean;
  68505. set screenSpaceReflectionsEnabled(enabled: boolean);
  68506. /**
  68507. * Specifies the number of steps used to calculate the volumetric lights
  68508. * Typically in interval [50, 200]
  68509. */
  68510. get volumetricLightStepsCount(): number;
  68511. set volumetricLightStepsCount(count: number);
  68512. /**
  68513. * Specifies the number of samples used for the motion blur effect
  68514. * Typically in interval [16, 64]
  68515. */
  68516. get motionBlurSamples(): number;
  68517. set motionBlurSamples(samples: number);
  68518. /**
  68519. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68520. */
  68521. get samples(): number;
  68522. set samples(sampleCount: number);
  68523. /**
  68524. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68525. * @constructor
  68526. * @param name The rendering pipeline name
  68527. * @param scene The scene linked to this pipeline
  68528. * @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)
  68529. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68531. */
  68532. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68533. private _buildPipeline;
  68534. private _createDownSampleX4PostProcess;
  68535. private _createBrightPassPostProcess;
  68536. private _createBlurPostProcesses;
  68537. private _createTextureAdderPostProcess;
  68538. private _createVolumetricLightPostProcess;
  68539. private _createLuminancePostProcesses;
  68540. private _createHdrPostProcess;
  68541. private _createLensFlarePostProcess;
  68542. private _createDepthOfFieldPostProcess;
  68543. private _createMotionBlurPostProcess;
  68544. private _getDepthTexture;
  68545. private _disposePostProcesses;
  68546. /**
  68547. * Dispose of the pipeline and stop all post processes
  68548. */
  68549. dispose(): void;
  68550. /**
  68551. * Serialize the rendering pipeline (Used when exporting)
  68552. * @returns the serialized object
  68553. */
  68554. serialize(): any;
  68555. /**
  68556. * Parse the serialized pipeline
  68557. * @param source Source pipeline.
  68558. * @param scene The scene to load the pipeline to.
  68559. * @param rootUrl The URL of the serialized pipeline.
  68560. * @returns An instantiated pipeline from the serialized object.
  68561. */
  68562. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68563. /**
  68564. * Luminance steps
  68565. */
  68566. static LuminanceSteps: number;
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /** @hidden */
  68571. export var stereoscopicInterlacePixelShader: {
  68572. name: string;
  68573. shader: string;
  68574. };
  68575. }
  68576. declare module BABYLON {
  68577. /**
  68578. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  68579. */
  68580. export class StereoscopicInterlacePostProcessI extends PostProcess {
  68581. private _stepSize;
  68582. private _passedProcess;
  68583. /**
  68584. * Initializes a StereoscopicInterlacePostProcessI
  68585. * @param name The name of the effect.
  68586. * @param rigCameras The rig cameras to be appled to the post process
  68587. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  68588. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  68589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68590. * @param engine The engine which the post process will be applied. (default: current engine)
  68591. * @param reusable If the post process can be reused on the same frame. (default: false)
  68592. */
  68593. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68594. }
  68595. /**
  68596. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  68597. */
  68598. export class StereoscopicInterlacePostProcess extends PostProcess {
  68599. private _stepSize;
  68600. private _passedProcess;
  68601. /**
  68602. * Initializes a StereoscopicInterlacePostProcess
  68603. * @param name The name of the effect.
  68604. * @param rigCameras The rig cameras to be appled to the post process
  68605. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  68606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68607. * @param engine The engine which the post process will be applied. (default: current engine)
  68608. * @param reusable If the post process can be reused on the same frame. (default: false)
  68609. */
  68610. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68611. }
  68612. }
  68613. declare module BABYLON {
  68614. /** @hidden */
  68615. export var tonemapPixelShader: {
  68616. name: string;
  68617. shader: string;
  68618. };
  68619. }
  68620. declare module BABYLON {
  68621. /** Defines operator used for tonemapping */
  68622. export enum TonemappingOperator {
  68623. /** Hable */
  68624. Hable = 0,
  68625. /** Reinhard */
  68626. Reinhard = 1,
  68627. /** HejiDawson */
  68628. HejiDawson = 2,
  68629. /** Photographic */
  68630. Photographic = 3
  68631. }
  68632. /**
  68633. * Defines a post process to apply tone mapping
  68634. */
  68635. export class TonemapPostProcess extends PostProcess {
  68636. private _operator;
  68637. /** Defines the required exposure adjustement */
  68638. exposureAdjustment: number;
  68639. /**
  68640. * Creates a new TonemapPostProcess
  68641. * @param name defines the name of the postprocess
  68642. * @param _operator defines the operator to use
  68643. * @param exposureAdjustment defines the required exposure adjustement
  68644. * @param camera defines the camera to use (can be null)
  68645. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68646. * @param engine defines the hosting engine (can be ignore if camera is set)
  68647. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68648. */
  68649. constructor(name: string, _operator: TonemappingOperator,
  68650. /** Defines the required exposure adjustement */
  68651. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /** @hidden */
  68656. export var volumetricLightScatteringPixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module BABYLON {
  68662. /** @hidden */
  68663. export var volumetricLightScatteringPassVertexShader: {
  68664. name: string;
  68665. shader: string;
  68666. };
  68667. }
  68668. declare module BABYLON {
  68669. /** @hidden */
  68670. export var volumetricLightScatteringPassPixelShader: {
  68671. name: string;
  68672. shader: string;
  68673. };
  68674. }
  68675. declare module BABYLON {
  68676. /**
  68677. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68678. */
  68679. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68680. private _volumetricLightScatteringPass;
  68681. private _volumetricLightScatteringRTT;
  68682. private _viewPort;
  68683. private _screenCoordinates;
  68684. private _cachedDefines;
  68685. /**
  68686. * If not undefined, the mesh position is computed from the attached node position
  68687. */
  68688. attachedNode: {
  68689. position: Vector3;
  68690. };
  68691. /**
  68692. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68693. */
  68694. customMeshPosition: Vector3;
  68695. /**
  68696. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68697. */
  68698. useCustomMeshPosition: boolean;
  68699. /**
  68700. * If the post-process should inverse the light scattering direction
  68701. */
  68702. invert: boolean;
  68703. /**
  68704. * The internal mesh used by the post-process
  68705. */
  68706. mesh: Mesh;
  68707. /**
  68708. * @hidden
  68709. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68710. */
  68711. get useDiffuseColor(): boolean;
  68712. set useDiffuseColor(useDiffuseColor: boolean);
  68713. /**
  68714. * Array containing the excluded meshes not rendered in the internal pass
  68715. */
  68716. excludedMeshes: AbstractMesh[];
  68717. /**
  68718. * Controls the overall intensity of the post-process
  68719. */
  68720. exposure: number;
  68721. /**
  68722. * Dissipates each sample's contribution in range [0, 1]
  68723. */
  68724. decay: number;
  68725. /**
  68726. * Controls the overall intensity of each sample
  68727. */
  68728. weight: number;
  68729. /**
  68730. * Controls the density of each sample
  68731. */
  68732. density: number;
  68733. /**
  68734. * @constructor
  68735. * @param name The post-process name
  68736. * @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)
  68737. * @param camera The camera that the post-process will be attached to
  68738. * @param mesh The mesh used to create the light scattering
  68739. * @param samples The post-process quality, default 100
  68740. * @param samplingModeThe post-process filtering mode
  68741. * @param engine The babylon engine
  68742. * @param reusable If the post-process is reusable
  68743. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68744. */
  68745. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68746. /**
  68747. * Returns the string "VolumetricLightScatteringPostProcess"
  68748. * @returns "VolumetricLightScatteringPostProcess"
  68749. */
  68750. getClassName(): string;
  68751. private _isReady;
  68752. /**
  68753. * Sets the new light position for light scattering effect
  68754. * @param position The new custom light position
  68755. */
  68756. setCustomMeshPosition(position: Vector3): void;
  68757. /**
  68758. * Returns the light position for light scattering effect
  68759. * @return Vector3 The custom light position
  68760. */
  68761. getCustomMeshPosition(): Vector3;
  68762. /**
  68763. * Disposes the internal assets and detaches the post-process from the camera
  68764. */
  68765. dispose(camera: Camera): void;
  68766. /**
  68767. * Returns the render target texture used by the post-process
  68768. * @return the render target texture used by the post-process
  68769. */
  68770. getPass(): RenderTargetTexture;
  68771. private _meshExcluded;
  68772. private _createPass;
  68773. private _updateMeshScreenCoordinates;
  68774. /**
  68775. * Creates a default mesh for the Volumeric Light Scattering post-process
  68776. * @param name The mesh name
  68777. * @param scene The scene where to create the mesh
  68778. * @return the default mesh
  68779. */
  68780. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68781. }
  68782. }
  68783. declare module BABYLON {
  68784. interface Scene {
  68785. /** @hidden (Backing field) */
  68786. _boundingBoxRenderer: BoundingBoxRenderer;
  68787. /** @hidden (Backing field) */
  68788. _forceShowBoundingBoxes: boolean;
  68789. /**
  68790. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68791. */
  68792. forceShowBoundingBoxes: boolean;
  68793. /**
  68794. * Gets the bounding box renderer associated with the scene
  68795. * @returns a BoundingBoxRenderer
  68796. */
  68797. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68798. }
  68799. interface AbstractMesh {
  68800. /** @hidden (Backing field) */
  68801. _showBoundingBox: boolean;
  68802. /**
  68803. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68804. */
  68805. showBoundingBox: boolean;
  68806. }
  68807. /**
  68808. * Component responsible of rendering the bounding box of the meshes in a scene.
  68809. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68810. */
  68811. export class BoundingBoxRenderer implements ISceneComponent {
  68812. /**
  68813. * The component name helpfull to identify the component in the list of scene components.
  68814. */
  68815. readonly name: string;
  68816. /**
  68817. * The scene the component belongs to.
  68818. */
  68819. scene: Scene;
  68820. /**
  68821. * Color of the bounding box lines placed in front of an object
  68822. */
  68823. frontColor: Color3;
  68824. /**
  68825. * Color of the bounding box lines placed behind an object
  68826. */
  68827. backColor: Color3;
  68828. /**
  68829. * Defines if the renderer should show the back lines or not
  68830. */
  68831. showBackLines: boolean;
  68832. /**
  68833. * @hidden
  68834. */
  68835. renderList: SmartArray<BoundingBox>;
  68836. private _colorShader;
  68837. private _vertexBuffers;
  68838. private _indexBuffer;
  68839. private _fillIndexBuffer;
  68840. private _fillIndexData;
  68841. /**
  68842. * Instantiates a new bounding box renderer in a scene.
  68843. * @param scene the scene the renderer renders in
  68844. */
  68845. constructor(scene: Scene);
  68846. /**
  68847. * Registers the component in a given scene
  68848. */
  68849. register(): void;
  68850. private _evaluateSubMesh;
  68851. private _activeMesh;
  68852. private _prepareRessources;
  68853. private _createIndexBuffer;
  68854. /**
  68855. * Rebuilds the elements related to this component in case of
  68856. * context lost for instance.
  68857. */
  68858. rebuild(): void;
  68859. /**
  68860. * @hidden
  68861. */
  68862. reset(): void;
  68863. /**
  68864. * Render the bounding boxes of a specific rendering group
  68865. * @param renderingGroupId defines the rendering group to render
  68866. */
  68867. render(renderingGroupId: number): void;
  68868. /**
  68869. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68870. * @param mesh Define the mesh to render the occlusion bounding box for
  68871. */
  68872. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68873. /**
  68874. * Dispose and release the resources attached to this renderer.
  68875. */
  68876. dispose(): void;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. interface Scene {
  68881. /** @hidden (Backing field) */
  68882. _depthRenderer: {
  68883. [id: string]: DepthRenderer;
  68884. };
  68885. /**
  68886. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68887. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68888. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68889. * @returns the created depth renderer
  68890. */
  68891. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68892. /**
  68893. * Disables a depth renderer for a given camera
  68894. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68895. */
  68896. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68897. }
  68898. /**
  68899. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68900. * in several rendering techniques.
  68901. */
  68902. export class DepthRendererSceneComponent implements ISceneComponent {
  68903. /**
  68904. * The component name helpfull to identify the component in the list of scene components.
  68905. */
  68906. readonly name: string;
  68907. /**
  68908. * The scene the component belongs to.
  68909. */
  68910. scene: Scene;
  68911. /**
  68912. * Creates a new instance of the component for the given scene
  68913. * @param scene Defines the scene to register the component in
  68914. */
  68915. constructor(scene: Scene);
  68916. /**
  68917. * Registers the component in a given scene
  68918. */
  68919. register(): void;
  68920. /**
  68921. * Rebuilds the elements related to this component in case of
  68922. * context lost for instance.
  68923. */
  68924. rebuild(): void;
  68925. /**
  68926. * Disposes the component and the associated ressources
  68927. */
  68928. dispose(): void;
  68929. private _gatherRenderTargets;
  68930. private _gatherActiveCameraRenderTargets;
  68931. }
  68932. }
  68933. declare module BABYLON {
  68934. /** @hidden */
  68935. export var outlinePixelShader: {
  68936. name: string;
  68937. shader: string;
  68938. };
  68939. }
  68940. declare module BABYLON {
  68941. /** @hidden */
  68942. export var outlineVertexShader: {
  68943. name: string;
  68944. shader: string;
  68945. };
  68946. }
  68947. declare module BABYLON {
  68948. interface Scene {
  68949. /** @hidden */
  68950. _outlineRenderer: OutlineRenderer;
  68951. /**
  68952. * Gets the outline renderer associated with the scene
  68953. * @returns a OutlineRenderer
  68954. */
  68955. getOutlineRenderer(): OutlineRenderer;
  68956. }
  68957. interface AbstractMesh {
  68958. /** @hidden (Backing field) */
  68959. _renderOutline: boolean;
  68960. /**
  68961. * Gets or sets a boolean indicating if the outline must be rendered as well
  68962. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68963. */
  68964. renderOutline: boolean;
  68965. /** @hidden (Backing field) */
  68966. _renderOverlay: boolean;
  68967. /**
  68968. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68969. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68970. */
  68971. renderOverlay: boolean;
  68972. }
  68973. /**
  68974. * This class is responsible to draw bothe outline/overlay of meshes.
  68975. * It should not be used directly but through the available method on mesh.
  68976. */
  68977. export class OutlineRenderer implements ISceneComponent {
  68978. /**
  68979. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68980. */
  68981. private static _StencilReference;
  68982. /**
  68983. * The name of the component. Each component must have a unique name.
  68984. */
  68985. name: string;
  68986. /**
  68987. * The scene the component belongs to.
  68988. */
  68989. scene: Scene;
  68990. /**
  68991. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68992. */
  68993. zOffset: number;
  68994. private _engine;
  68995. private _effect;
  68996. private _cachedDefines;
  68997. private _savedDepthWrite;
  68998. /**
  68999. * Instantiates a new outline renderer. (There could be only one per scene).
  69000. * @param scene Defines the scene it belongs to
  69001. */
  69002. constructor(scene: Scene);
  69003. /**
  69004. * Register the component to one instance of a scene.
  69005. */
  69006. register(): void;
  69007. /**
  69008. * Rebuilds the elements related to this component in case of
  69009. * context lost for instance.
  69010. */
  69011. rebuild(): void;
  69012. /**
  69013. * Disposes the component and the associated ressources.
  69014. */
  69015. dispose(): void;
  69016. /**
  69017. * Renders the outline in the canvas.
  69018. * @param subMesh Defines the sumesh to render
  69019. * @param batch Defines the batch of meshes in case of instances
  69020. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69021. */
  69022. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69023. /**
  69024. * Returns whether or not the outline renderer is ready for a given submesh.
  69025. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69026. * @param subMesh Defines the submesh to check readyness for
  69027. * @param useInstances Defines wheter wee are trying to render instances or not
  69028. * @returns true if ready otherwise false
  69029. */
  69030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69031. private _beforeRenderingMesh;
  69032. private _afterRenderingMesh;
  69033. }
  69034. }
  69035. declare module BABYLON {
  69036. /**
  69037. * Defines the basic options interface of a Sprite Frame Source Size.
  69038. */
  69039. export interface ISpriteJSONSpriteSourceSize {
  69040. /**
  69041. * number of the original width of the Frame
  69042. */
  69043. w: number;
  69044. /**
  69045. * number of the original height of the Frame
  69046. */
  69047. h: number;
  69048. }
  69049. /**
  69050. * Defines the basic options interface of a Sprite Frame Data.
  69051. */
  69052. export interface ISpriteJSONSpriteFrameData {
  69053. /**
  69054. * number of the x offset of the Frame
  69055. */
  69056. x: number;
  69057. /**
  69058. * number of the y offset of the Frame
  69059. */
  69060. y: number;
  69061. /**
  69062. * number of the width of the Frame
  69063. */
  69064. w: number;
  69065. /**
  69066. * number of the height of the Frame
  69067. */
  69068. h: number;
  69069. }
  69070. /**
  69071. * Defines the basic options interface of a JSON Sprite.
  69072. */
  69073. export interface ISpriteJSONSprite {
  69074. /**
  69075. * string name of the Frame
  69076. */
  69077. filename: string;
  69078. /**
  69079. * ISpriteJSONSpriteFrame basic object of the frame data
  69080. */
  69081. frame: ISpriteJSONSpriteFrameData;
  69082. /**
  69083. * boolean to flag is the frame was rotated.
  69084. */
  69085. rotated: boolean;
  69086. /**
  69087. * boolean to flag is the frame was trimmed.
  69088. */
  69089. trimmed: boolean;
  69090. /**
  69091. * ISpriteJSONSpriteFrame basic object of the source data
  69092. */
  69093. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69094. /**
  69095. * ISpriteJSONSpriteFrame basic object of the source data
  69096. */
  69097. sourceSize: ISpriteJSONSpriteSourceSize;
  69098. }
  69099. /**
  69100. * Defines the basic options interface of a JSON atlas.
  69101. */
  69102. export interface ISpriteJSONAtlas {
  69103. /**
  69104. * Array of objects that contain the frame data.
  69105. */
  69106. frames: Array<ISpriteJSONSprite>;
  69107. /**
  69108. * object basic object containing the sprite meta data.
  69109. */
  69110. meta?: object;
  69111. }
  69112. }
  69113. declare module BABYLON {
  69114. /** @hidden */
  69115. export var spriteMapPixelShader: {
  69116. name: string;
  69117. shader: string;
  69118. };
  69119. }
  69120. declare module BABYLON {
  69121. /** @hidden */
  69122. export var spriteMapVertexShader: {
  69123. name: string;
  69124. shader: string;
  69125. };
  69126. }
  69127. declare module BABYLON {
  69128. /**
  69129. * Defines the basic options interface of a SpriteMap
  69130. */
  69131. export interface ISpriteMapOptions {
  69132. /**
  69133. * Vector2 of the number of cells in the grid.
  69134. */
  69135. stageSize?: Vector2;
  69136. /**
  69137. * Vector2 of the size of the output plane in World Units.
  69138. */
  69139. outputSize?: Vector2;
  69140. /**
  69141. * Vector3 of the position of the output plane in World Units.
  69142. */
  69143. outputPosition?: Vector3;
  69144. /**
  69145. * Vector3 of the rotation of the output plane.
  69146. */
  69147. outputRotation?: Vector3;
  69148. /**
  69149. * number of layers that the system will reserve in resources.
  69150. */
  69151. layerCount?: number;
  69152. /**
  69153. * number of max animation frames a single cell will reserve in resources.
  69154. */
  69155. maxAnimationFrames?: number;
  69156. /**
  69157. * number cell index of the base tile when the system compiles.
  69158. */
  69159. baseTile?: number;
  69160. /**
  69161. * boolean flip the sprite after its been repositioned by the framing data.
  69162. */
  69163. flipU?: boolean;
  69164. /**
  69165. * Vector3 scalar of the global RGB values of the SpriteMap.
  69166. */
  69167. colorMultiply?: Vector3;
  69168. }
  69169. /**
  69170. * Defines the IDisposable interface in order to be cleanable from resources.
  69171. */
  69172. export interface ISpriteMap extends IDisposable {
  69173. /**
  69174. * String name of the SpriteMap.
  69175. */
  69176. name: string;
  69177. /**
  69178. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69179. */
  69180. atlasJSON: ISpriteJSONAtlas;
  69181. /**
  69182. * Texture of the SpriteMap.
  69183. */
  69184. spriteSheet: Texture;
  69185. /**
  69186. * The parameters to initialize the SpriteMap with.
  69187. */
  69188. options: ISpriteMapOptions;
  69189. }
  69190. /**
  69191. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69192. */
  69193. export class SpriteMap implements ISpriteMap {
  69194. /** The Name of the spriteMap */
  69195. name: string;
  69196. /** The JSON file with the frame and meta data */
  69197. atlasJSON: ISpriteJSONAtlas;
  69198. /** The systems Sprite Sheet Texture */
  69199. spriteSheet: Texture;
  69200. /** Arguments passed with the Constructor */
  69201. options: ISpriteMapOptions;
  69202. /** Public Sprite Storage array, parsed from atlasJSON */
  69203. sprites: Array<ISpriteJSONSprite>;
  69204. /** Returns the Number of Sprites in the System */
  69205. get spriteCount(): number;
  69206. /** Returns the Position of Output Plane*/
  69207. get position(): Vector3;
  69208. /** Returns the Position of Output Plane*/
  69209. set position(v: Vector3);
  69210. /** Returns the Rotation of Output Plane*/
  69211. get rotation(): Vector3;
  69212. /** Returns the Rotation of Output Plane*/
  69213. set rotation(v: Vector3);
  69214. /** Sets the AnimationMap*/
  69215. get animationMap(): RawTexture;
  69216. /** Sets the AnimationMap*/
  69217. set animationMap(v: RawTexture);
  69218. /** Scene that the SpriteMap was created in */
  69219. private _scene;
  69220. /** Texture Buffer of Float32 that holds tile frame data*/
  69221. private _frameMap;
  69222. /** Texture Buffers of Float32 that holds tileMap data*/
  69223. private _tileMaps;
  69224. /** Texture Buffer of Float32 that holds Animation Data*/
  69225. private _animationMap;
  69226. /** Custom ShaderMaterial Central to the System*/
  69227. private _material;
  69228. /** Custom ShaderMaterial Central to the System*/
  69229. private _output;
  69230. /** Systems Time Ticker*/
  69231. private _time;
  69232. /**
  69233. * Creates a new SpriteMap
  69234. * @param name defines the SpriteMaps Name
  69235. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69236. * @param spriteSheet is the Texture that the Sprites are on.
  69237. * @param options a basic deployment configuration
  69238. * @param scene The Scene that the map is deployed on
  69239. */
  69240. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69241. /**
  69242. * Returns tileID location
  69243. * @returns Vector2 the cell position ID
  69244. */
  69245. getTileID(): Vector2;
  69246. /**
  69247. * Gets the UV location of the mouse over the SpriteMap.
  69248. * @returns Vector2 the UV position of the mouse interaction
  69249. */
  69250. getMousePosition(): Vector2;
  69251. /**
  69252. * Creates the "frame" texture Buffer
  69253. * -------------------------------------
  69254. * Structure of frames
  69255. * "filename": "Falling-Water-2.png",
  69256. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69257. * "rotated": true,
  69258. * "trimmed": true,
  69259. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69260. * "sourceSize": {"w":32,"h":32}
  69261. * @returns RawTexture of the frameMap
  69262. */
  69263. private _createFrameBuffer;
  69264. /**
  69265. * Creates the tileMap texture Buffer
  69266. * @param buffer normally and array of numbers, or a false to generate from scratch
  69267. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69268. * @returns RawTexture of the tileMap
  69269. */
  69270. private _createTileBuffer;
  69271. /**
  69272. * Modifies the data of the tileMaps
  69273. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69274. * @param pos is the iVector2 Coordinates of the Tile
  69275. * @param tile The SpriteIndex of the new Tile
  69276. */
  69277. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69278. /**
  69279. * Creates the animationMap texture Buffer
  69280. * @param buffer normally and array of numbers, or a false to generate from scratch
  69281. * @returns RawTexture of the animationMap
  69282. */
  69283. private _createTileAnimationBuffer;
  69284. /**
  69285. * Modifies the data of the animationMap
  69286. * @param cellID is the Index of the Sprite
  69287. * @param _frame is the target Animation frame
  69288. * @param toCell is the Target Index of the next frame of the animation
  69289. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69290. * @param speed is a global scalar of the time variable on the map.
  69291. */
  69292. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69293. /**
  69294. * Exports the .tilemaps file
  69295. */
  69296. saveTileMaps(): void;
  69297. /**
  69298. * Imports the .tilemaps file
  69299. * @param url of the .tilemaps file
  69300. */
  69301. loadTileMaps(url: string): void;
  69302. /**
  69303. * Release associated resources
  69304. */
  69305. dispose(): void;
  69306. }
  69307. }
  69308. declare module BABYLON {
  69309. /**
  69310. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69311. * @see http://doc.babylonjs.com/babylon101/sprites
  69312. */
  69313. export class SpritePackedManager extends SpriteManager {
  69314. /** defines the packed manager's name */
  69315. name: string;
  69316. /**
  69317. * Creates a new sprite manager from a packed sprite sheet
  69318. * @param name defines the manager's name
  69319. * @param imgUrl defines the sprite sheet url
  69320. * @param capacity defines the maximum allowed number of sprites
  69321. * @param scene defines the hosting scene
  69322. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69323. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69324. * @param samplingMode defines the smapling mode to use with spritesheet
  69325. * @param fromPacked set to true; do not alter
  69326. */
  69327. constructor(
  69328. /** defines the packed manager's name */
  69329. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * Defines the list of states available for a task inside a AssetsManager
  69335. */
  69336. export enum AssetTaskState {
  69337. /**
  69338. * Initialization
  69339. */
  69340. INIT = 0,
  69341. /**
  69342. * Running
  69343. */
  69344. RUNNING = 1,
  69345. /**
  69346. * Done
  69347. */
  69348. DONE = 2,
  69349. /**
  69350. * Error
  69351. */
  69352. ERROR = 3
  69353. }
  69354. /**
  69355. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69356. */
  69357. export abstract class AbstractAssetTask {
  69358. /**
  69359. * Task name
  69360. */ name: string;
  69361. /**
  69362. * Callback called when the task is successful
  69363. */
  69364. onSuccess: (task: any) => void;
  69365. /**
  69366. * Callback called when the task is not successful
  69367. */
  69368. onError: (task: any, message?: string, exception?: any) => void;
  69369. /**
  69370. * Creates a new AssetsManager
  69371. * @param name defines the name of the task
  69372. */
  69373. constructor(
  69374. /**
  69375. * Task name
  69376. */ name: string);
  69377. private _isCompleted;
  69378. private _taskState;
  69379. private _errorObject;
  69380. /**
  69381. * Get if the task is completed
  69382. */
  69383. get isCompleted(): boolean;
  69384. /**
  69385. * Gets the current state of the task
  69386. */
  69387. get taskState(): AssetTaskState;
  69388. /**
  69389. * Gets the current error object (if task is in error)
  69390. */
  69391. get errorObject(): {
  69392. message?: string;
  69393. exception?: any;
  69394. };
  69395. /**
  69396. * Internal only
  69397. * @hidden
  69398. */
  69399. _setErrorObject(message?: string, exception?: any): void;
  69400. /**
  69401. * Execute the current task
  69402. * @param scene defines the scene where you want your assets to be loaded
  69403. * @param onSuccess is a callback called when the task is successfully executed
  69404. * @param onError is a callback called if an error occurs
  69405. */
  69406. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69407. /**
  69408. * Execute the current task
  69409. * @param scene defines the scene where you want your assets to be loaded
  69410. * @param onSuccess is a callback called when the task is successfully executed
  69411. * @param onError is a callback called if an error occurs
  69412. */
  69413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69414. /**
  69415. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69416. * This can be used with failed tasks that have the reason for failure fixed.
  69417. */
  69418. reset(): void;
  69419. private onErrorCallback;
  69420. private onDoneCallback;
  69421. }
  69422. /**
  69423. * Define the interface used by progress events raised during assets loading
  69424. */
  69425. export interface IAssetsProgressEvent {
  69426. /**
  69427. * Defines the number of remaining tasks to process
  69428. */
  69429. remainingCount: number;
  69430. /**
  69431. * Defines the total number of tasks
  69432. */
  69433. totalCount: number;
  69434. /**
  69435. * Defines the task that was just processed
  69436. */
  69437. task: AbstractAssetTask;
  69438. }
  69439. /**
  69440. * Class used to share progress information about assets loading
  69441. */
  69442. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69443. /**
  69444. * Defines the number of remaining tasks to process
  69445. */
  69446. remainingCount: number;
  69447. /**
  69448. * Defines the total number of tasks
  69449. */
  69450. totalCount: number;
  69451. /**
  69452. * Defines the task that was just processed
  69453. */
  69454. task: AbstractAssetTask;
  69455. /**
  69456. * Creates a AssetsProgressEvent
  69457. * @param remainingCount defines the number of remaining tasks to process
  69458. * @param totalCount defines the total number of tasks
  69459. * @param task defines the task that was just processed
  69460. */
  69461. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69462. }
  69463. /**
  69464. * Define a task used by AssetsManager to load meshes
  69465. */
  69466. export class MeshAssetTask extends AbstractAssetTask {
  69467. /**
  69468. * Defines the name of the task
  69469. */
  69470. name: string;
  69471. /**
  69472. * Defines the list of mesh's names you want to load
  69473. */
  69474. meshesNames: any;
  69475. /**
  69476. * Defines the root url to use as a base to load your meshes and associated resources
  69477. */
  69478. rootUrl: string;
  69479. /**
  69480. * Defines the filename or File of the scene to load from
  69481. */
  69482. sceneFilename: string | File;
  69483. /**
  69484. * Gets the list of loaded meshes
  69485. */
  69486. loadedMeshes: Array<AbstractMesh>;
  69487. /**
  69488. * Gets the list of loaded particle systems
  69489. */
  69490. loadedParticleSystems: Array<IParticleSystem>;
  69491. /**
  69492. * Gets the list of loaded skeletons
  69493. */
  69494. loadedSkeletons: Array<Skeleton>;
  69495. /**
  69496. * Gets the list of loaded animation groups
  69497. */
  69498. loadedAnimationGroups: Array<AnimationGroup>;
  69499. /**
  69500. * Callback called when the task is successful
  69501. */
  69502. onSuccess: (task: MeshAssetTask) => void;
  69503. /**
  69504. * Callback called when the task is successful
  69505. */
  69506. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69507. /**
  69508. * Creates a new MeshAssetTask
  69509. * @param name defines the name of the task
  69510. * @param meshesNames defines the list of mesh's names you want to load
  69511. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69512. * @param sceneFilename defines the filename or File of the scene to load from
  69513. */
  69514. constructor(
  69515. /**
  69516. * Defines the name of the task
  69517. */
  69518. name: string,
  69519. /**
  69520. * Defines the list of mesh's names you want to load
  69521. */
  69522. meshesNames: any,
  69523. /**
  69524. * Defines the root url to use as a base to load your meshes and associated resources
  69525. */
  69526. rootUrl: string,
  69527. /**
  69528. * Defines the filename or File of the scene to load from
  69529. */
  69530. sceneFilename: string | File);
  69531. /**
  69532. * Execute the current task
  69533. * @param scene defines the scene where you want your assets to be loaded
  69534. * @param onSuccess is a callback called when the task is successfully executed
  69535. * @param onError is a callback called if an error occurs
  69536. */
  69537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69538. }
  69539. /**
  69540. * Define a task used by AssetsManager to load text content
  69541. */
  69542. export class TextFileAssetTask extends AbstractAssetTask {
  69543. /**
  69544. * Defines the name of the task
  69545. */
  69546. name: string;
  69547. /**
  69548. * Defines the location of the file to load
  69549. */
  69550. url: string;
  69551. /**
  69552. * Gets the loaded text string
  69553. */
  69554. text: string;
  69555. /**
  69556. * Callback called when the task is successful
  69557. */
  69558. onSuccess: (task: TextFileAssetTask) => void;
  69559. /**
  69560. * Callback called when the task is successful
  69561. */
  69562. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69563. /**
  69564. * Creates a new TextFileAssetTask object
  69565. * @param name defines the name of the task
  69566. * @param url defines the location of the file to load
  69567. */
  69568. constructor(
  69569. /**
  69570. * Defines the name of the task
  69571. */
  69572. name: string,
  69573. /**
  69574. * Defines the location of the file to load
  69575. */
  69576. url: string);
  69577. /**
  69578. * Execute the current task
  69579. * @param scene defines the scene where you want your assets to be loaded
  69580. * @param onSuccess is a callback called when the task is successfully executed
  69581. * @param onError is a callback called if an error occurs
  69582. */
  69583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69584. }
  69585. /**
  69586. * Define a task used by AssetsManager to load binary data
  69587. */
  69588. export class BinaryFileAssetTask extends AbstractAssetTask {
  69589. /**
  69590. * Defines the name of the task
  69591. */
  69592. name: string;
  69593. /**
  69594. * Defines the location of the file to load
  69595. */
  69596. url: string;
  69597. /**
  69598. * Gets the lodaded data (as an array buffer)
  69599. */
  69600. data: ArrayBuffer;
  69601. /**
  69602. * Callback called when the task is successful
  69603. */
  69604. onSuccess: (task: BinaryFileAssetTask) => void;
  69605. /**
  69606. * Callback called when the task is successful
  69607. */
  69608. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69609. /**
  69610. * Creates a new BinaryFileAssetTask object
  69611. * @param name defines the name of the new task
  69612. * @param url defines the location of the file to load
  69613. */
  69614. constructor(
  69615. /**
  69616. * Defines the name of the task
  69617. */
  69618. name: string,
  69619. /**
  69620. * Defines the location of the file to load
  69621. */
  69622. url: string);
  69623. /**
  69624. * Execute the current task
  69625. * @param scene defines the scene where you want your assets to be loaded
  69626. * @param onSuccess is a callback called when the task is successfully executed
  69627. * @param onError is a callback called if an error occurs
  69628. */
  69629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69630. }
  69631. /**
  69632. * Define a task used by AssetsManager to load images
  69633. */
  69634. export class ImageAssetTask extends AbstractAssetTask {
  69635. /**
  69636. * Defines the name of the task
  69637. */
  69638. name: string;
  69639. /**
  69640. * Defines the location of the image to load
  69641. */
  69642. url: string;
  69643. /**
  69644. * Gets the loaded images
  69645. */
  69646. image: HTMLImageElement;
  69647. /**
  69648. * Callback called when the task is successful
  69649. */
  69650. onSuccess: (task: ImageAssetTask) => void;
  69651. /**
  69652. * Callback called when the task is successful
  69653. */
  69654. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69655. /**
  69656. * Creates a new ImageAssetTask
  69657. * @param name defines the name of the task
  69658. * @param url defines the location of the image to load
  69659. */
  69660. constructor(
  69661. /**
  69662. * Defines the name of the task
  69663. */
  69664. name: string,
  69665. /**
  69666. * Defines the location of the image to load
  69667. */
  69668. url: string);
  69669. /**
  69670. * Execute the current task
  69671. * @param scene defines the scene where you want your assets to be loaded
  69672. * @param onSuccess is a callback called when the task is successfully executed
  69673. * @param onError is a callback called if an error occurs
  69674. */
  69675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69676. }
  69677. /**
  69678. * Defines the interface used by texture loading tasks
  69679. */
  69680. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69681. /**
  69682. * Gets the loaded texture
  69683. */
  69684. texture: TEX;
  69685. }
  69686. /**
  69687. * Define a task used by AssetsManager to load 2D textures
  69688. */
  69689. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69690. /**
  69691. * Defines the name of the task
  69692. */
  69693. name: string;
  69694. /**
  69695. * Defines the location of the file to load
  69696. */
  69697. url: string;
  69698. /**
  69699. * Defines if mipmap should not be generated (default is false)
  69700. */
  69701. noMipmap?: boolean | undefined;
  69702. /**
  69703. * Defines if texture must be inverted on Y axis (default is true)
  69704. */
  69705. invertY: boolean;
  69706. /**
  69707. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69708. */
  69709. samplingMode: number;
  69710. /**
  69711. * Gets the loaded texture
  69712. */
  69713. texture: Texture;
  69714. /**
  69715. * Callback called when the task is successful
  69716. */
  69717. onSuccess: (task: TextureAssetTask) => void;
  69718. /**
  69719. * Callback called when the task is successful
  69720. */
  69721. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69722. /**
  69723. * Creates a new TextureAssetTask object
  69724. * @param name defines the name of the task
  69725. * @param url defines the location of the file to load
  69726. * @param noMipmap defines if mipmap should not be generated (default is false)
  69727. * @param invertY defines if texture must be inverted on Y axis (default is true)
  69728. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69729. */
  69730. constructor(
  69731. /**
  69732. * Defines the name of the task
  69733. */
  69734. name: string,
  69735. /**
  69736. * Defines the location of the file to load
  69737. */
  69738. url: string,
  69739. /**
  69740. * Defines if mipmap should not be generated (default is false)
  69741. */
  69742. noMipmap?: boolean | undefined,
  69743. /**
  69744. * Defines if texture must be inverted on Y axis (default is true)
  69745. */
  69746. invertY?: boolean,
  69747. /**
  69748. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69749. */
  69750. samplingMode?: number);
  69751. /**
  69752. * Execute the current task
  69753. * @param scene defines the scene where you want your assets to be loaded
  69754. * @param onSuccess is a callback called when the task is successfully executed
  69755. * @param onError is a callback called if an error occurs
  69756. */
  69757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69758. }
  69759. /**
  69760. * Define a task used by AssetsManager to load cube textures
  69761. */
  69762. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69763. /**
  69764. * Defines the name of the task
  69765. */
  69766. name: string;
  69767. /**
  69768. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69769. */
  69770. url: string;
  69771. /**
  69772. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69773. */
  69774. extensions?: string[] | undefined;
  69775. /**
  69776. * Defines if mipmaps should not be generated (default is false)
  69777. */
  69778. noMipmap?: boolean | undefined;
  69779. /**
  69780. * Defines the explicit list of files (undefined by default)
  69781. */
  69782. files?: string[] | undefined;
  69783. /**
  69784. * Gets the loaded texture
  69785. */
  69786. texture: CubeTexture;
  69787. /**
  69788. * Callback called when the task is successful
  69789. */
  69790. onSuccess: (task: CubeTextureAssetTask) => void;
  69791. /**
  69792. * Callback called when the task is successful
  69793. */
  69794. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69795. /**
  69796. * Creates a new CubeTextureAssetTask
  69797. * @param name defines the name of the task
  69798. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69799. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69800. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69801. * @param files defines the explicit list of files (undefined by default)
  69802. */
  69803. constructor(
  69804. /**
  69805. * Defines the name of the task
  69806. */
  69807. name: string,
  69808. /**
  69809. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69810. */
  69811. url: string,
  69812. /**
  69813. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69814. */
  69815. extensions?: string[] | undefined,
  69816. /**
  69817. * Defines if mipmaps should not be generated (default is false)
  69818. */
  69819. noMipmap?: boolean | undefined,
  69820. /**
  69821. * Defines the explicit list of files (undefined by default)
  69822. */
  69823. files?: string[] | undefined);
  69824. /**
  69825. * Execute the current task
  69826. * @param scene defines the scene where you want your assets to be loaded
  69827. * @param onSuccess is a callback called when the task is successfully executed
  69828. * @param onError is a callback called if an error occurs
  69829. */
  69830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69831. }
  69832. /**
  69833. * Define a task used by AssetsManager to load HDR cube textures
  69834. */
  69835. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69836. /**
  69837. * Defines the name of the task
  69838. */
  69839. name: string;
  69840. /**
  69841. * Defines the location of the file to load
  69842. */
  69843. url: string;
  69844. /**
  69845. * Defines the desired size (the more it increases the longer the generation will be)
  69846. */
  69847. size: number;
  69848. /**
  69849. * Defines if mipmaps should not be generated (default is false)
  69850. */
  69851. noMipmap: boolean;
  69852. /**
  69853. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69854. */
  69855. generateHarmonics: boolean;
  69856. /**
  69857. * 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)
  69858. */
  69859. gammaSpace: boolean;
  69860. /**
  69861. * Internal Use Only
  69862. */
  69863. reserved: boolean;
  69864. /**
  69865. * Gets the loaded texture
  69866. */
  69867. texture: HDRCubeTexture;
  69868. /**
  69869. * Callback called when the task is successful
  69870. */
  69871. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69872. /**
  69873. * Callback called when the task is successful
  69874. */
  69875. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69876. /**
  69877. * Creates a new HDRCubeTextureAssetTask object
  69878. * @param name defines the name of the task
  69879. * @param url defines the location of the file to load
  69880. * @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.
  69881. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69882. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69883. * @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)
  69884. * @param reserved Internal use only
  69885. */
  69886. constructor(
  69887. /**
  69888. * Defines the name of the task
  69889. */
  69890. name: string,
  69891. /**
  69892. * Defines the location of the file to load
  69893. */
  69894. url: string,
  69895. /**
  69896. * Defines the desired size (the more it increases the longer the generation will be)
  69897. */
  69898. size: number,
  69899. /**
  69900. * Defines if mipmaps should not be generated (default is false)
  69901. */
  69902. noMipmap?: boolean,
  69903. /**
  69904. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69905. */
  69906. generateHarmonics?: boolean,
  69907. /**
  69908. * 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)
  69909. */
  69910. gammaSpace?: boolean,
  69911. /**
  69912. * Internal Use Only
  69913. */
  69914. reserved?: boolean);
  69915. /**
  69916. * Execute the current task
  69917. * @param scene defines the scene where you want your assets to be loaded
  69918. * @param onSuccess is a callback called when the task is successfully executed
  69919. * @param onError is a callback called if an error occurs
  69920. */
  69921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69922. }
  69923. /**
  69924. * Define a task used by AssetsManager to load Equirectangular cube textures
  69925. */
  69926. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69927. /**
  69928. * Defines the name of the task
  69929. */
  69930. name: string;
  69931. /**
  69932. * Defines the location of the file to load
  69933. */
  69934. url: string;
  69935. /**
  69936. * Defines the desired size (the more it increases the longer the generation will be)
  69937. */
  69938. size: number;
  69939. /**
  69940. * Defines if mipmaps should not be generated (default is false)
  69941. */
  69942. noMipmap: boolean;
  69943. /**
  69944. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69945. * but the standard material would require them in Gamma space) (default is true)
  69946. */
  69947. gammaSpace: boolean;
  69948. /**
  69949. * Gets the loaded texture
  69950. */
  69951. texture: EquiRectangularCubeTexture;
  69952. /**
  69953. * Callback called when the task is successful
  69954. */
  69955. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69956. /**
  69957. * Callback called when the task is successful
  69958. */
  69959. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69960. /**
  69961. * Creates a new EquiRectangularCubeTextureAssetTask object
  69962. * @param name defines the name of the task
  69963. * @param url defines the location of the file to load
  69964. * @param size defines the desired size (the more it increases the longer the generation will be)
  69965. * If the size is omitted this implies you are using a preprocessed cubemap.
  69966. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69967. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69968. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69969. * (default is true)
  69970. */
  69971. constructor(
  69972. /**
  69973. * Defines the name of the task
  69974. */
  69975. name: string,
  69976. /**
  69977. * Defines the location of the file to load
  69978. */
  69979. url: string,
  69980. /**
  69981. * Defines the desired size (the more it increases the longer the generation will be)
  69982. */
  69983. size: number,
  69984. /**
  69985. * Defines if mipmaps should not be generated (default is false)
  69986. */
  69987. noMipmap?: boolean,
  69988. /**
  69989. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69990. * but the standard material would require them in Gamma space) (default is true)
  69991. */
  69992. gammaSpace?: boolean);
  69993. /**
  69994. * Execute the current task
  69995. * @param scene defines the scene where you want your assets to be loaded
  69996. * @param onSuccess is a callback called when the task is successfully executed
  69997. * @param onError is a callback called if an error occurs
  69998. */
  69999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70000. }
  70001. /**
  70002. * This class can be used to easily import assets into a scene
  70003. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70004. */
  70005. export class AssetsManager {
  70006. private _scene;
  70007. private _isLoading;
  70008. protected _tasks: AbstractAssetTask[];
  70009. protected _waitingTasksCount: number;
  70010. protected _totalTasksCount: number;
  70011. /**
  70012. * Callback called when all tasks are processed
  70013. */
  70014. onFinish: (tasks: AbstractAssetTask[]) => void;
  70015. /**
  70016. * Callback called when a task is successful
  70017. */
  70018. onTaskSuccess: (task: AbstractAssetTask) => void;
  70019. /**
  70020. * Callback called when a task had an error
  70021. */
  70022. onTaskError: (task: AbstractAssetTask) => void;
  70023. /**
  70024. * Callback called when a task is done (whatever the result is)
  70025. */
  70026. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70027. /**
  70028. * Observable called when all tasks are processed
  70029. */
  70030. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70031. /**
  70032. * Observable called when a task had an error
  70033. */
  70034. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70035. /**
  70036. * Observable called when all tasks were executed
  70037. */
  70038. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70039. /**
  70040. * Observable called when a task is done (whatever the result is)
  70041. */
  70042. onProgressObservable: Observable<IAssetsProgressEvent>;
  70043. /**
  70044. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70046. */
  70047. useDefaultLoadingScreen: boolean;
  70048. /**
  70049. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70050. * when all assets have been downloaded.
  70051. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70052. */
  70053. autoHideLoadingUI: boolean;
  70054. /**
  70055. * Creates a new AssetsManager
  70056. * @param scene defines the scene to work on
  70057. */
  70058. constructor(scene: Scene);
  70059. /**
  70060. * Add a MeshAssetTask to the list of active tasks
  70061. * @param taskName defines the name of the new task
  70062. * @param meshesNames defines the name of meshes to load
  70063. * @param rootUrl defines the root url to use to locate files
  70064. * @param sceneFilename defines the filename of the scene file
  70065. * @returns a new MeshAssetTask object
  70066. */
  70067. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70068. /**
  70069. * Add a TextFileAssetTask to the list of active tasks
  70070. * @param taskName defines the name of the new task
  70071. * @param url defines the url of the file to load
  70072. * @returns a new TextFileAssetTask object
  70073. */
  70074. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70075. /**
  70076. * Add a BinaryFileAssetTask to the list of active tasks
  70077. * @param taskName defines the name of the new task
  70078. * @param url defines the url of the file to load
  70079. * @returns a new BinaryFileAssetTask object
  70080. */
  70081. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70082. /**
  70083. * Add a ImageAssetTask to the list of active tasks
  70084. * @param taskName defines the name of the new task
  70085. * @param url defines the url of the file to load
  70086. * @returns a new ImageAssetTask object
  70087. */
  70088. addImageTask(taskName: string, url: string): ImageAssetTask;
  70089. /**
  70090. * Add a TextureAssetTask to the list of active tasks
  70091. * @param taskName defines the name of the new task
  70092. * @param url defines the url of the file to load
  70093. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70094. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70096. * @returns a new TextureAssetTask object
  70097. */
  70098. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70099. /**
  70100. * Add a CubeTextureAssetTask to the list of active tasks
  70101. * @param taskName defines the name of the new task
  70102. * @param url defines the url of the file to load
  70103. * @param extensions defines the extension to use to load the cube map (can be null)
  70104. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70105. * @param files defines the list of files to load (can be null)
  70106. * @returns a new CubeTextureAssetTask object
  70107. */
  70108. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70109. /**
  70110. *
  70111. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70112. * @param taskName defines the name of the new task
  70113. * @param url defines the url of the file to load
  70114. * @param size defines the size you want for the cubemap (can be null)
  70115. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70116. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70117. * @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)
  70118. * @param reserved Internal use only
  70119. * @returns a new HDRCubeTextureAssetTask object
  70120. */
  70121. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70122. /**
  70123. *
  70124. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70125. * @param taskName defines the name of the new task
  70126. * @param url defines the url of the file to load
  70127. * @param size defines the size you want for the cubemap (can be null)
  70128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70129. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70130. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70131. * @returns a new EquiRectangularCubeTextureAssetTask object
  70132. */
  70133. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70134. /**
  70135. * Remove a task from the assets manager.
  70136. * @param task the task to remove
  70137. */
  70138. removeTask(task: AbstractAssetTask): void;
  70139. private _decreaseWaitingTasksCount;
  70140. private _runTask;
  70141. /**
  70142. * Reset the AssetsManager and remove all tasks
  70143. * @return the current instance of the AssetsManager
  70144. */
  70145. reset(): AssetsManager;
  70146. /**
  70147. * Start the loading process
  70148. * @return the current instance of the AssetsManager
  70149. */
  70150. load(): AssetsManager;
  70151. /**
  70152. * Start the loading process as an async operation
  70153. * @return a promise returning the list of failed tasks
  70154. */
  70155. loadAsync(): Promise<void>;
  70156. }
  70157. }
  70158. declare module BABYLON {
  70159. /**
  70160. * Wrapper class for promise with external resolve and reject.
  70161. */
  70162. export class Deferred<T> {
  70163. /**
  70164. * The promise associated with this deferred object.
  70165. */
  70166. readonly promise: Promise<T>;
  70167. private _resolve;
  70168. private _reject;
  70169. /**
  70170. * The resolve method of the promise associated with this deferred object.
  70171. */
  70172. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70173. /**
  70174. * The reject method of the promise associated with this deferred object.
  70175. */
  70176. get reject(): (reason?: any) => void;
  70177. /**
  70178. * Constructor for this deferred object.
  70179. */
  70180. constructor();
  70181. }
  70182. }
  70183. declare module BABYLON {
  70184. /**
  70185. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70186. */
  70187. export class MeshExploder {
  70188. private _centerMesh;
  70189. private _meshes;
  70190. private _meshesOrigins;
  70191. private _toCenterVectors;
  70192. private _scaledDirection;
  70193. private _newPosition;
  70194. private _centerPosition;
  70195. /**
  70196. * Explodes meshes from a center mesh.
  70197. * @param meshes The meshes to explode.
  70198. * @param centerMesh The mesh to be center of explosion.
  70199. */
  70200. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70201. private _setCenterMesh;
  70202. /**
  70203. * Get class name
  70204. * @returns "MeshExploder"
  70205. */
  70206. getClassName(): string;
  70207. /**
  70208. * "Exploded meshes"
  70209. * @returns Array of meshes with the centerMesh at index 0.
  70210. */
  70211. getMeshes(): Array<Mesh>;
  70212. /**
  70213. * Explodes meshes giving a specific direction
  70214. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70215. */
  70216. explode(direction?: number): void;
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /**
  70221. * Class used to help managing file picking and drag'n'drop
  70222. */
  70223. export class FilesInput {
  70224. /**
  70225. * List of files ready to be loaded
  70226. */
  70227. static get FilesToLoad(): {
  70228. [key: string]: File;
  70229. };
  70230. /**
  70231. * Callback called when a file is processed
  70232. */
  70233. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70234. private _engine;
  70235. private _currentScene;
  70236. private _sceneLoadedCallback;
  70237. private _progressCallback;
  70238. private _additionalRenderLoopLogicCallback;
  70239. private _textureLoadingCallback;
  70240. private _startingProcessingFilesCallback;
  70241. private _onReloadCallback;
  70242. private _errorCallback;
  70243. private _elementToMonitor;
  70244. private _sceneFileToLoad;
  70245. private _filesToLoad;
  70246. /**
  70247. * Creates a new FilesInput
  70248. * @param engine defines the rendering engine
  70249. * @param scene defines the hosting scene
  70250. * @param sceneLoadedCallback callback called when scene is loaded
  70251. * @param progressCallback callback called to track progress
  70252. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70253. * @param textureLoadingCallback callback called when a texture is loading
  70254. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70255. * @param onReloadCallback callback called when a reload is requested
  70256. * @param errorCallback callback call if an error occurs
  70257. */
  70258. 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);
  70259. private _dragEnterHandler;
  70260. private _dragOverHandler;
  70261. private _dropHandler;
  70262. /**
  70263. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70264. * @param elementToMonitor defines the DOM element to track
  70265. */
  70266. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70267. /**
  70268. * Release all associated resources
  70269. */
  70270. dispose(): void;
  70271. private renderFunction;
  70272. private drag;
  70273. private drop;
  70274. private _traverseFolder;
  70275. private _processFiles;
  70276. /**
  70277. * Load files from a drop event
  70278. * @param event defines the drop event to use as source
  70279. */
  70280. loadFiles(event: any): void;
  70281. private _processReload;
  70282. /**
  70283. * Reload the current scene from the loaded files
  70284. */
  70285. reload(): void;
  70286. }
  70287. }
  70288. declare module BABYLON {
  70289. /**
  70290. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70292. */
  70293. export class SceneOptimization {
  70294. /**
  70295. * Defines the priority of this optimization (0 by default which means first in the list)
  70296. */
  70297. priority: number;
  70298. /**
  70299. * Gets a string describing the action executed by the current optimization
  70300. * @returns description string
  70301. */
  70302. getDescription(): string;
  70303. /**
  70304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70305. * @param scene defines the current scene where to apply this optimization
  70306. * @param optimizer defines the current optimizer
  70307. * @returns true if everything that can be done was applied
  70308. */
  70309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70310. /**
  70311. * Creates the SceneOptimization object
  70312. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70313. * @param desc defines the description associated with the optimization
  70314. */
  70315. constructor(
  70316. /**
  70317. * Defines the priority of this optimization (0 by default which means first in the list)
  70318. */
  70319. priority?: number);
  70320. }
  70321. /**
  70322. * Defines an optimization used to reduce the size of render target textures
  70323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70324. */
  70325. export class TextureOptimization extends SceneOptimization {
  70326. /**
  70327. * Defines the priority of this optimization (0 by default which means first in the list)
  70328. */
  70329. priority: number;
  70330. /**
  70331. * 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
  70332. */
  70333. maximumSize: number;
  70334. /**
  70335. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70336. */
  70337. step: number;
  70338. /**
  70339. * Gets a string describing the action executed by the current optimization
  70340. * @returns description string
  70341. */
  70342. getDescription(): string;
  70343. /**
  70344. * Creates the TextureOptimization object
  70345. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70346. * @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
  70347. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70348. */
  70349. constructor(
  70350. /**
  70351. * Defines the priority of this optimization (0 by default which means first in the list)
  70352. */
  70353. priority?: number,
  70354. /**
  70355. * 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
  70356. */
  70357. maximumSize?: number,
  70358. /**
  70359. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70360. */
  70361. step?: number);
  70362. /**
  70363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70364. * @param scene defines the current scene where to apply this optimization
  70365. * @param optimizer defines the current optimizer
  70366. * @returns true if everything that can be done was applied
  70367. */
  70368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70369. }
  70370. /**
  70371. * Defines an optimization used to increase or decrease the rendering resolution
  70372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70373. */
  70374. export class HardwareScalingOptimization extends SceneOptimization {
  70375. /**
  70376. * Defines the priority of this optimization (0 by default which means first in the list)
  70377. */
  70378. priority: number;
  70379. /**
  70380. * Defines the maximum scale to use (2 by default)
  70381. */
  70382. maximumScale: number;
  70383. /**
  70384. * Defines the step to use between two passes (0.5 by default)
  70385. */
  70386. step: number;
  70387. private _currentScale;
  70388. private _directionOffset;
  70389. /**
  70390. * Gets a string describing the action executed by the current optimization
  70391. * @return description string
  70392. */
  70393. getDescription(): string;
  70394. /**
  70395. * Creates the HardwareScalingOptimization object
  70396. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70397. * @param maximumScale defines the maximum scale to use (2 by default)
  70398. * @param step defines the step to use between two passes (0.5 by default)
  70399. */
  70400. constructor(
  70401. /**
  70402. * Defines the priority of this optimization (0 by default which means first in the list)
  70403. */
  70404. priority?: number,
  70405. /**
  70406. * Defines the maximum scale to use (2 by default)
  70407. */
  70408. maximumScale?: number,
  70409. /**
  70410. * Defines the step to use between two passes (0.5 by default)
  70411. */
  70412. step?: number);
  70413. /**
  70414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70415. * @param scene defines the current scene where to apply this optimization
  70416. * @param optimizer defines the current optimizer
  70417. * @returns true if everything that can be done was applied
  70418. */
  70419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70420. }
  70421. /**
  70422. * Defines an optimization used to remove shadows
  70423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70424. */
  70425. export class ShadowsOptimization extends SceneOptimization {
  70426. /**
  70427. * Gets a string describing the action executed by the current optimization
  70428. * @return description string
  70429. */
  70430. getDescription(): string;
  70431. /**
  70432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70433. * @param scene defines the current scene where to apply this optimization
  70434. * @param optimizer defines the current optimizer
  70435. * @returns true if everything that can be done was applied
  70436. */
  70437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70438. }
  70439. /**
  70440. * Defines an optimization used to turn post-processes off
  70441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70442. */
  70443. export class PostProcessesOptimization extends SceneOptimization {
  70444. /**
  70445. * Gets a string describing the action executed by the current optimization
  70446. * @return description string
  70447. */
  70448. getDescription(): string;
  70449. /**
  70450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70451. * @param scene defines the current scene where to apply this optimization
  70452. * @param optimizer defines the current optimizer
  70453. * @returns true if everything that can be done was applied
  70454. */
  70455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70456. }
  70457. /**
  70458. * Defines an optimization used to turn lens flares off
  70459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70460. */
  70461. export class LensFlaresOptimization extends SceneOptimization {
  70462. /**
  70463. * Gets a string describing the action executed by the current optimization
  70464. * @return description string
  70465. */
  70466. getDescription(): string;
  70467. /**
  70468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70469. * @param scene defines the current scene where to apply this optimization
  70470. * @param optimizer defines the current optimizer
  70471. * @returns true if everything that can be done was applied
  70472. */
  70473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70474. }
  70475. /**
  70476. * Defines an optimization based on user defined callback.
  70477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70478. */
  70479. export class CustomOptimization extends SceneOptimization {
  70480. /**
  70481. * Callback called to apply the custom optimization.
  70482. */
  70483. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70484. /**
  70485. * Callback called to get custom description
  70486. */
  70487. onGetDescription: () => string;
  70488. /**
  70489. * Gets a string describing the action executed by the current optimization
  70490. * @returns description string
  70491. */
  70492. getDescription(): string;
  70493. /**
  70494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70495. * @param scene defines the current scene where to apply this optimization
  70496. * @param optimizer defines the current optimizer
  70497. * @returns true if everything that can be done was applied
  70498. */
  70499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70500. }
  70501. /**
  70502. * Defines an optimization used to turn particles off
  70503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70504. */
  70505. export class ParticlesOptimization extends SceneOptimization {
  70506. /**
  70507. * Gets a string describing the action executed by the current optimization
  70508. * @return description string
  70509. */
  70510. getDescription(): string;
  70511. /**
  70512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70513. * @param scene defines the current scene where to apply this optimization
  70514. * @param optimizer defines the current optimizer
  70515. * @returns true if everything that can be done was applied
  70516. */
  70517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70518. }
  70519. /**
  70520. * Defines an optimization used to turn render targets off
  70521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70522. */
  70523. export class RenderTargetsOptimization extends SceneOptimization {
  70524. /**
  70525. * Gets a string describing the action executed by the current optimization
  70526. * @return description string
  70527. */
  70528. getDescription(): string;
  70529. /**
  70530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70531. * @param scene defines the current scene where to apply this optimization
  70532. * @param optimizer defines the current optimizer
  70533. * @returns true if everything that can be done was applied
  70534. */
  70535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70536. }
  70537. /**
  70538. * Defines an optimization used to merge meshes with compatible materials
  70539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70540. */
  70541. export class MergeMeshesOptimization extends SceneOptimization {
  70542. private static _UpdateSelectionTree;
  70543. /**
  70544. * Gets or sets a boolean which defines if optimization octree has to be updated
  70545. */
  70546. static get UpdateSelectionTree(): boolean;
  70547. /**
  70548. * Gets or sets a boolean which defines if optimization octree has to be updated
  70549. */
  70550. static set UpdateSelectionTree(value: boolean);
  70551. /**
  70552. * Gets a string describing the action executed by the current optimization
  70553. * @return description string
  70554. */
  70555. getDescription(): string;
  70556. private _canBeMerged;
  70557. /**
  70558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70559. * @param scene defines the current scene where to apply this optimization
  70560. * @param optimizer defines the current optimizer
  70561. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70562. * @returns true if everything that can be done was applied
  70563. */
  70564. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70565. }
  70566. /**
  70567. * Defines a list of options used by SceneOptimizer
  70568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70569. */
  70570. export class SceneOptimizerOptions {
  70571. /**
  70572. * Defines the target frame rate to reach (60 by default)
  70573. */
  70574. targetFrameRate: number;
  70575. /**
  70576. * Defines the interval between two checkes (2000ms by default)
  70577. */
  70578. trackerDuration: number;
  70579. /**
  70580. * Gets the list of optimizations to apply
  70581. */
  70582. optimizations: SceneOptimization[];
  70583. /**
  70584. * Creates a new list of options used by SceneOptimizer
  70585. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70586. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70587. */
  70588. constructor(
  70589. /**
  70590. * Defines the target frame rate to reach (60 by default)
  70591. */
  70592. targetFrameRate?: number,
  70593. /**
  70594. * Defines the interval between two checkes (2000ms by default)
  70595. */
  70596. trackerDuration?: number);
  70597. /**
  70598. * Add a new optimization
  70599. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70600. * @returns the current SceneOptimizerOptions
  70601. */
  70602. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70603. /**
  70604. * Add a new custom optimization
  70605. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70606. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70608. * @returns the current SceneOptimizerOptions
  70609. */
  70610. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70611. /**
  70612. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70613. * @param targetFrameRate defines the target frame rate (60 by default)
  70614. * @returns a SceneOptimizerOptions object
  70615. */
  70616. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70617. /**
  70618. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70619. * @param targetFrameRate defines the target frame rate (60 by default)
  70620. * @returns a SceneOptimizerOptions object
  70621. */
  70622. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70623. /**
  70624. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70625. * @param targetFrameRate defines the target frame rate (60 by default)
  70626. * @returns a SceneOptimizerOptions object
  70627. */
  70628. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70629. }
  70630. /**
  70631. * Class used to run optimizations in order to reach a target frame rate
  70632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70633. */
  70634. export class SceneOptimizer implements IDisposable {
  70635. private _isRunning;
  70636. private _options;
  70637. private _scene;
  70638. private _currentPriorityLevel;
  70639. private _targetFrameRate;
  70640. private _trackerDuration;
  70641. private _currentFrameRate;
  70642. private _sceneDisposeObserver;
  70643. private _improvementMode;
  70644. /**
  70645. * Defines an observable called when the optimizer reaches the target frame rate
  70646. */
  70647. onSuccessObservable: Observable<SceneOptimizer>;
  70648. /**
  70649. * Defines an observable called when the optimizer enables an optimization
  70650. */
  70651. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70652. /**
  70653. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70654. */
  70655. onFailureObservable: Observable<SceneOptimizer>;
  70656. /**
  70657. * Gets a boolean indicating if the optimizer is in improvement mode
  70658. */
  70659. get isInImprovementMode(): boolean;
  70660. /**
  70661. * Gets the current priority level (0 at start)
  70662. */
  70663. get currentPriorityLevel(): number;
  70664. /**
  70665. * Gets the current frame rate checked by the SceneOptimizer
  70666. */
  70667. get currentFrameRate(): number;
  70668. /**
  70669. * Gets or sets the current target frame rate (60 by default)
  70670. */
  70671. get targetFrameRate(): number;
  70672. /**
  70673. * Gets or sets the current target frame rate (60 by default)
  70674. */
  70675. set targetFrameRate(value: number);
  70676. /**
  70677. * Gets or sets the current interval between two checks (every 2000ms by default)
  70678. */
  70679. get trackerDuration(): number;
  70680. /**
  70681. * Gets or sets the current interval between two checks (every 2000ms by default)
  70682. */
  70683. set trackerDuration(value: number);
  70684. /**
  70685. * Gets the list of active optimizations
  70686. */
  70687. get optimizations(): SceneOptimization[];
  70688. /**
  70689. * Creates a new SceneOptimizer
  70690. * @param scene defines the scene to work on
  70691. * @param options defines the options to use with the SceneOptimizer
  70692. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70693. * @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)
  70694. */
  70695. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70696. /**
  70697. * Stops the current optimizer
  70698. */
  70699. stop(): void;
  70700. /**
  70701. * Reset the optimizer to initial step (current priority level = 0)
  70702. */
  70703. reset(): void;
  70704. /**
  70705. * Start the optimizer. By default it will try to reach a specific framerate
  70706. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70707. */
  70708. start(): void;
  70709. private _checkCurrentState;
  70710. /**
  70711. * Release all resources
  70712. */
  70713. dispose(): void;
  70714. /**
  70715. * Helper function to create a SceneOptimizer with one single line of code
  70716. * @param scene defines the scene to work on
  70717. * @param options defines the options to use with the SceneOptimizer
  70718. * @param onSuccess defines a callback to call on success
  70719. * @param onFailure defines a callback to call on failure
  70720. * @returns the new SceneOptimizer object
  70721. */
  70722. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70723. }
  70724. }
  70725. declare module BABYLON {
  70726. /**
  70727. * Class used to serialize a scene into a string
  70728. */
  70729. export class SceneSerializer {
  70730. /**
  70731. * Clear cache used by a previous serialization
  70732. */
  70733. static ClearCache(): void;
  70734. /**
  70735. * Serialize a scene into a JSON compatible object
  70736. * @param scene defines the scene to serialize
  70737. * @returns a JSON compatible object
  70738. */
  70739. static Serialize(scene: Scene): any;
  70740. /**
  70741. * Serialize a mesh into a JSON compatible object
  70742. * @param toSerialize defines the mesh to serialize
  70743. * @param withParents defines if parents must be serialized as well
  70744. * @param withChildren defines if children must be serialized as well
  70745. * @returns a JSON compatible object
  70746. */
  70747. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70748. }
  70749. }
  70750. declare module BABYLON {
  70751. /**
  70752. * Class used to host texture specific utilities
  70753. */
  70754. export class TextureTools {
  70755. /**
  70756. * Uses the GPU to create a copy texture rescaled at a given size
  70757. * @param texture Texture to copy from
  70758. * @param width defines the desired width
  70759. * @param height defines the desired height
  70760. * @param useBilinearMode defines if bilinear mode has to be used
  70761. * @return the generated texture
  70762. */
  70763. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70764. }
  70765. }
  70766. declare module BABYLON {
  70767. /**
  70768. * This represents the different options available for the video capture.
  70769. */
  70770. export interface VideoRecorderOptions {
  70771. /** Defines the mime type of the video. */
  70772. mimeType: string;
  70773. /** Defines the FPS the video should be recorded at. */
  70774. fps: number;
  70775. /** Defines the chunk size for the recording data. */
  70776. recordChunckSize: number;
  70777. /** The audio tracks to attach to the recording. */
  70778. audioTracks?: MediaStreamTrack[];
  70779. }
  70780. /**
  70781. * This can help with recording videos from BabylonJS.
  70782. * This is based on the available WebRTC functionalities of the browser.
  70783. *
  70784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70785. */
  70786. export class VideoRecorder {
  70787. private static readonly _defaultOptions;
  70788. /**
  70789. * Returns whether or not the VideoRecorder is available in your browser.
  70790. * @param engine Defines the Babylon Engine.
  70791. * @returns true if supported otherwise false.
  70792. */
  70793. static IsSupported(engine: Engine): boolean;
  70794. private readonly _options;
  70795. private _canvas;
  70796. private _mediaRecorder;
  70797. private _recordedChunks;
  70798. private _fileName;
  70799. private _resolve;
  70800. private _reject;
  70801. /**
  70802. * True when a recording is already in progress.
  70803. */
  70804. get isRecording(): boolean;
  70805. /**
  70806. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70807. * @param engine Defines the BabylonJS Engine you wish to record.
  70808. * @param options Defines options that can be used to customize the capture.
  70809. */
  70810. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70811. /**
  70812. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70813. */
  70814. stopRecording(): void;
  70815. /**
  70816. * Starts recording the canvas for a max duration specified in parameters.
  70817. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70818. * If null no automatic download will start and you can rely on the promise to get the data back.
  70819. * @param maxDuration Defines the maximum recording time in seconds.
  70820. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70821. * @return A promise callback at the end of the recording with the video data in Blob.
  70822. */
  70823. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70824. /**
  70825. * Releases internal resources used during the recording.
  70826. */
  70827. dispose(): void;
  70828. private _handleDataAvailable;
  70829. private _handleError;
  70830. private _handleStop;
  70831. }
  70832. }
  70833. declare module BABYLON {
  70834. /**
  70835. * Class containing a set of static utilities functions for screenshots
  70836. */
  70837. export class ScreenshotTools {
  70838. /**
  70839. * Captures a screenshot of the current rendering
  70840. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70841. * @param engine defines the rendering engine
  70842. * @param camera defines the source camera
  70843. * @param size This parameter can be set to a single number or to an object with the
  70844. * following (optional) properties: precision, width, height. If a single number is passed,
  70845. * it will be used for both width and height. If an object is passed, the screenshot size
  70846. * will be derived from the parameters. The precision property is a multiplier allowing
  70847. * rendering at a higher or lower resolution
  70848. * @param successCallback defines the callback receives a single parameter which contains the
  70849. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70850. * src parameter of an <img> to display it
  70851. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70852. * Check your browser for supported MIME types
  70853. */
  70854. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70855. /**
  70856. * Captures a screenshot of the current rendering
  70857. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70858. * @param engine defines the rendering engine
  70859. * @param camera defines the source camera
  70860. * @param size This parameter can be set to a single number or to an object with the
  70861. * following (optional) properties: precision, width, height. If a single number is passed,
  70862. * it will be used for both width and height. If an object is passed, the screenshot size
  70863. * will be derived from the parameters. The precision property is a multiplier allowing
  70864. * rendering at a higher or lower resolution
  70865. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70866. * Check your browser for supported MIME types
  70867. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70868. * to the src parameter of an <img> to display it
  70869. */
  70870. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70871. /**
  70872. * Generates an image screenshot from the specified camera.
  70873. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70874. * @param engine The engine to use for rendering
  70875. * @param camera The camera to use for rendering
  70876. * @param size This parameter can be set to a single number or to an object with the
  70877. * following (optional) properties: precision, width, height. If a single number is passed,
  70878. * it will be used for both width and height. If an object is passed, the screenshot size
  70879. * will be derived from the parameters. The precision property is a multiplier allowing
  70880. * rendering at a higher or lower resolution
  70881. * @param successCallback The callback receives a single parameter which contains the
  70882. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70883. * src parameter of an <img> to display it
  70884. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70885. * Check your browser for supported MIME types
  70886. * @param samples Texture samples (default: 1)
  70887. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70888. * @param fileName A name for for the downloaded file.
  70889. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70890. */
  70891. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  70892. /**
  70893. * Generates an image screenshot from the specified camera.
  70894. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70895. * @param engine The engine to use for rendering
  70896. * @param camera The camera to use for rendering
  70897. * @param size This parameter can be set to a single number or to an object with the
  70898. * following (optional) properties: precision, width, height. If a single number is passed,
  70899. * it will be used for both width and height. If an object is passed, the screenshot size
  70900. * will be derived from the parameters. The precision property is a multiplier allowing
  70901. * rendering at a higher or lower resolution
  70902. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70903. * Check your browser for supported MIME types
  70904. * @param samples Texture samples (default: 1)
  70905. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70906. * @param fileName A name for for the downloaded file.
  70907. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70908. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70909. * to the src parameter of an <img> to display it
  70910. */
  70911. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  70912. /**
  70913. * Gets height and width for screenshot size
  70914. * @private
  70915. */
  70916. private static _getScreenshotSize;
  70917. }
  70918. }
  70919. declare module BABYLON {
  70920. /**
  70921. * Interface for a data buffer
  70922. */
  70923. export interface IDataBuffer {
  70924. /**
  70925. * Reads bytes from the data buffer.
  70926. * @param byteOffset The byte offset to read
  70927. * @param byteLength The byte length to read
  70928. * @returns A promise that resolves when the bytes are read
  70929. */
  70930. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70931. /**
  70932. * The byte length of the buffer.
  70933. */
  70934. readonly byteLength: number;
  70935. }
  70936. /**
  70937. * Utility class for reading from a data buffer
  70938. */
  70939. export class DataReader {
  70940. /**
  70941. * The data buffer associated with this data reader.
  70942. */
  70943. readonly buffer: IDataBuffer;
  70944. /**
  70945. * The current byte offset from the beginning of the data buffer.
  70946. */
  70947. byteOffset: number;
  70948. private _dataView;
  70949. private _dataByteOffset;
  70950. /**
  70951. * Constructor
  70952. * @param buffer The buffer to read
  70953. */
  70954. constructor(buffer: IDataBuffer);
  70955. /**
  70956. * Loads the given byte length.
  70957. * @param byteLength The byte length to load
  70958. * @returns A promise that resolves when the load is complete
  70959. */
  70960. loadAsync(byteLength: number): Promise<void>;
  70961. /**
  70962. * Read a unsigned 32-bit integer from the currently loaded data range.
  70963. * @returns The 32-bit integer read
  70964. */
  70965. readUint32(): number;
  70966. /**
  70967. * Read a byte array from the currently loaded data range.
  70968. * @param byteLength The byte length to read
  70969. * @returns The byte array read
  70970. */
  70971. readUint8Array(byteLength: number): Uint8Array;
  70972. /**
  70973. * Read a string from the currently loaded data range.
  70974. * @param byteLength The byte length to read
  70975. * @returns The string read
  70976. */
  70977. readString(byteLength: number): string;
  70978. /**
  70979. * Skips the given byte length the currently loaded data range.
  70980. * @param byteLength The byte length to skip
  70981. */
  70982. skipBytes(byteLength: number): void;
  70983. }
  70984. }
  70985. declare module BABYLON {
  70986. /**
  70987. * Class for storing data to local storage if available or in-memory storage otherwise
  70988. */
  70989. export class DataStorage {
  70990. private static _Storage;
  70991. private static _GetStorage;
  70992. /**
  70993. * Reads a string from the data storage
  70994. * @param key The key to read
  70995. * @param defaultValue The value if the key doesn't exist
  70996. * @returns The string value
  70997. */
  70998. static ReadString(key: string, defaultValue: string): string;
  70999. /**
  71000. * Writes a string to the data storage
  71001. * @param key The key to write
  71002. * @param value The value to write
  71003. */
  71004. static WriteString(key: string, value: string): void;
  71005. /**
  71006. * Reads a boolean from the data storage
  71007. * @param key The key to read
  71008. * @param defaultValue The value if the key doesn't exist
  71009. * @returns The boolean value
  71010. */
  71011. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71012. /**
  71013. * Writes a boolean to the data storage
  71014. * @param key The key to write
  71015. * @param value The value to write
  71016. */
  71017. static WriteBoolean(key: string, value: boolean): void;
  71018. /**
  71019. * Reads a number from the data storage
  71020. * @param key The key to read
  71021. * @param defaultValue The value if the key doesn't exist
  71022. * @returns The number value
  71023. */
  71024. static ReadNumber(key: string, defaultValue: number): number;
  71025. /**
  71026. * Writes a number to the data storage
  71027. * @param key The key to write
  71028. * @param value The value to write
  71029. */
  71030. static WriteNumber(key: string, value: number): void;
  71031. }
  71032. }
  71033. declare module BABYLON {
  71034. /**
  71035. * Options used for hit testing
  71036. */
  71037. export interface IWebXRLegacyHitTestOptions {
  71038. /**
  71039. * Only test when user interacted with the scene. Default - hit test every frame
  71040. */
  71041. testOnPointerDownOnly?: boolean;
  71042. /**
  71043. * The node to use to transform the local results to world coordinates
  71044. */
  71045. worldParentNode?: TransformNode;
  71046. }
  71047. /**
  71048. * Interface defining the babylon result of raycasting/hit-test
  71049. */
  71050. export interface IWebXRLegacyHitResult {
  71051. /**
  71052. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71053. */
  71054. transformationMatrix: Matrix;
  71055. /**
  71056. * The native hit test result
  71057. */
  71058. xrHitResult: XRHitResult | XRHitTestResult;
  71059. }
  71060. /**
  71061. * The currently-working hit-test module.
  71062. * Hit test (or Ray-casting) is used to interact with the real world.
  71063. * For further information read here - https://github.com/immersive-web/hit-test
  71064. */
  71065. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71066. /**
  71067. * options to use when constructing this feature
  71068. */
  71069. readonly options: IWebXRLegacyHitTestOptions;
  71070. private _direction;
  71071. private _mat;
  71072. private _onSelectEnabled;
  71073. private _origin;
  71074. /**
  71075. * The module's name
  71076. */
  71077. static readonly Name: string;
  71078. /**
  71079. * The (Babylon) version of this module.
  71080. * This is an integer representing the implementation version.
  71081. * This number does not correspond to the WebXR specs version
  71082. */
  71083. static readonly Version: number;
  71084. /**
  71085. * Populated with the last native XR Hit Results
  71086. */
  71087. lastNativeXRHitResults: XRHitResult[];
  71088. /**
  71089. * Triggered when new babylon (transformed) hit test results are available
  71090. */
  71091. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71092. /**
  71093. * Creates a new instance of the (legacy version) hit test feature
  71094. * @param _xrSessionManager an instance of WebXRSessionManager
  71095. * @param options options to use when constructing this feature
  71096. */
  71097. constructor(_xrSessionManager: WebXRSessionManager,
  71098. /**
  71099. * options to use when constructing this feature
  71100. */
  71101. options?: IWebXRLegacyHitTestOptions);
  71102. /**
  71103. * execute a hit test with an XR Ray
  71104. *
  71105. * @param xrSession a native xrSession that will execute this hit test
  71106. * @param xrRay the ray (position and direction) to use for ray-casting
  71107. * @param referenceSpace native XR reference space to use for the hit-test
  71108. * @param filter filter function that will filter the results
  71109. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71110. */
  71111. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71112. /**
  71113. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71114. * @param event the (select) event to use to select with
  71115. * @param referenceSpace the reference space to use for this hit test
  71116. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71117. */
  71118. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71119. /**
  71120. * attach this feature
  71121. * Will usually be called by the features manager
  71122. *
  71123. * @returns true if successful.
  71124. */
  71125. attach(): boolean;
  71126. /**
  71127. * detach this feature.
  71128. * Will usually be called by the features manager
  71129. *
  71130. * @returns true if successful.
  71131. */
  71132. detach(): boolean;
  71133. /**
  71134. * Dispose this feature and all of the resources attached
  71135. */
  71136. dispose(): void;
  71137. protected _onXRFrame(frame: XRFrame): void;
  71138. private _onHitTestResults;
  71139. private _onSelect;
  71140. }
  71141. }
  71142. declare module BABYLON {
  71143. /**
  71144. * Options used in the plane detector module
  71145. */
  71146. export interface IWebXRPlaneDetectorOptions {
  71147. /**
  71148. * The node to use to transform the local results to world coordinates
  71149. */
  71150. worldParentNode?: TransformNode;
  71151. }
  71152. /**
  71153. * A babylon interface for a WebXR plane.
  71154. * A Plane is actually a polygon, built from N points in space
  71155. *
  71156. * Supported in chrome 79, not supported in canary 81 ATM
  71157. */
  71158. export interface IWebXRPlane {
  71159. /**
  71160. * a babylon-assigned ID for this polygon
  71161. */
  71162. id: number;
  71163. /**
  71164. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  71165. */
  71166. polygonDefinition: Array<Vector3>;
  71167. /**
  71168. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  71169. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  71170. */
  71171. transformationMatrix: Matrix;
  71172. /**
  71173. * the native xr-plane object
  71174. */
  71175. xrPlane: XRPlane;
  71176. }
  71177. /**
  71178. * The plane detector is used to detect planes in the real world when in AR
  71179. * For more information see https://github.com/immersive-web/real-world-geometry/
  71180. */
  71181. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71182. private _options;
  71183. private _detectedPlanes;
  71184. private _enabled;
  71185. private _lastFrameDetected;
  71186. /**
  71187. * The module's name
  71188. */
  71189. static readonly Name: string;
  71190. /**
  71191. * The (Babylon) version of this module.
  71192. * This is an integer representing the implementation version.
  71193. * This number does not correspond to the WebXR specs version
  71194. */
  71195. static readonly Version: number;
  71196. /**
  71197. * Observers registered here will be executed when a new plane was added to the session
  71198. */
  71199. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71200. /**
  71201. * Observers registered here will be executed when a plane is no longer detected in the session
  71202. */
  71203. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71204. /**
  71205. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71206. * This can execute N times every frame
  71207. */
  71208. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71209. /**
  71210. * construct a new Plane Detector
  71211. * @param _xrSessionManager an instance of xr Session manager
  71212. * @param _options configuration to use when constructing this feature
  71213. */
  71214. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71215. /**
  71216. * Dispose this feature and all of the resources attached
  71217. */
  71218. dispose(): void;
  71219. protected _onXRFrame(frame: XRFrame): void;
  71220. private _init;
  71221. private _updatePlaneWithXRPlane;
  71222. /**
  71223. * avoiding using Array.find for global support.
  71224. * @param xrPlane the plane to find in the array
  71225. */
  71226. private findIndexInPlaneArray;
  71227. }
  71228. }
  71229. declare module BABYLON {
  71230. /**
  71231. * Configuration options of the anchor system
  71232. */
  71233. export interface IWebXRAnchorSystemOptions {
  71234. /**
  71235. * Should a new anchor be added every time a select event is triggered
  71236. */
  71237. addAnchorOnSelect?: boolean;
  71238. /**
  71239. * should the anchor system use plane detection.
  71240. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71241. */
  71242. usePlaneDetection?: boolean;
  71243. /**
  71244. * a node that will be used to convert local to world coordinates
  71245. */
  71246. worldParentNode?: TransformNode;
  71247. }
  71248. /**
  71249. * A babylon container for an XR Anchor
  71250. */
  71251. export interface IWebXRAnchor {
  71252. /**
  71253. * A babylon-assigned ID for this anchor
  71254. */
  71255. id: number;
  71256. /**
  71257. * Transformation matrix to apply to an object attached to this anchor
  71258. */
  71259. transformationMatrix: Matrix;
  71260. /**
  71261. * The native anchor object
  71262. */
  71263. xrAnchor: XRAnchor;
  71264. }
  71265. /**
  71266. * An implementation of the anchor system of WebXR.
  71267. * Note that the current documented implementation is not available in any browser. Future implementations
  71268. * will use the frame to create an anchor and not the session or a detected plane
  71269. * For further information see https://github.com/immersive-web/anchors/
  71270. */
  71271. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71272. private _options;
  71273. private _enabled;
  71274. private _hitTestModule;
  71275. private _lastFrameDetected;
  71276. private _onSelect;
  71277. private _planeDetector;
  71278. private _trackedAnchors;
  71279. /**
  71280. * The module's name
  71281. */
  71282. static readonly Name: string;
  71283. /**
  71284. * The (Babylon) version of this module.
  71285. * This is an integer representing the implementation version.
  71286. * This number does not correspond to the WebXR specs version
  71287. */
  71288. static readonly Version: number;
  71289. /**
  71290. * Observers registered here will be executed when a new anchor was added to the session
  71291. */
  71292. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71293. /**
  71294. * Observers registered here will be executed when an anchor was removed from the session
  71295. */
  71296. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71297. /**
  71298. * Observers registered here will be executed when an existing anchor updates
  71299. * This can execute N times every frame
  71300. */
  71301. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71302. /**
  71303. * constructs a new anchor system
  71304. * @param _xrSessionManager an instance of WebXRSessionManager
  71305. * @param _options configuration object for this feature
  71306. */
  71307. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71308. /**
  71309. * Add anchor at a specific XR point.
  71310. *
  71311. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71312. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71313. * @returns a promise the fulfills when the anchor was created
  71314. */
  71315. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71316. /**
  71317. * attach this feature
  71318. * Will usually be called by the features manager
  71319. *
  71320. * @returns true if successful.
  71321. */
  71322. attach(): boolean;
  71323. /**
  71324. * detach this feature.
  71325. * Will usually be called by the features manager
  71326. *
  71327. * @returns true if successful.
  71328. */
  71329. detach(): boolean;
  71330. /**
  71331. * Dispose this feature and all of the resources attached
  71332. */
  71333. dispose(): void;
  71334. /**
  71335. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71336. * @param hitTestModule the hit-test module to use.
  71337. */
  71338. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71339. /**
  71340. * set the plane detector to use in order to create anchors from frames
  71341. * @param planeDetector the plane-detector module to use
  71342. * @param enable enable plane-anchors. default is true
  71343. */
  71344. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71345. protected _onXRFrame(frame: XRFrame): void;
  71346. /**
  71347. * avoiding using Array.find for global support.
  71348. * @param xrAnchor the plane to find in the array
  71349. */
  71350. private _findIndexInAnchorArray;
  71351. private _updateAnchorWithXRFrame;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /**
  71356. * Options interface for the background remover plugin
  71357. */
  71358. export interface IWebXRBackgroundRemoverOptions {
  71359. /**
  71360. * Further background meshes to disable when entering AR
  71361. */
  71362. backgroundMeshes?: AbstractMesh[];
  71363. /**
  71364. * flags to configure the removal of the environment helper.
  71365. * If not set, the entire background will be removed. If set, flags should be set as well.
  71366. */
  71367. environmentHelperRemovalFlags?: {
  71368. /**
  71369. * Should the skybox be removed (default false)
  71370. */
  71371. skyBox?: boolean;
  71372. /**
  71373. * Should the ground be removed (default false)
  71374. */
  71375. ground?: boolean;
  71376. };
  71377. /**
  71378. * don't disable the environment helper
  71379. */
  71380. ignoreEnvironmentHelper?: boolean;
  71381. }
  71382. /**
  71383. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71384. */
  71385. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71386. /**
  71387. * read-only options to be used in this module
  71388. */
  71389. readonly options: IWebXRBackgroundRemoverOptions;
  71390. /**
  71391. * The module's name
  71392. */
  71393. static readonly Name: string;
  71394. /**
  71395. * The (Babylon) version of this module.
  71396. * This is an integer representing the implementation version.
  71397. * This number does not correspond to the WebXR specs version
  71398. */
  71399. static readonly Version: number;
  71400. /**
  71401. * registered observers will be triggered when the background state changes
  71402. */
  71403. onBackgroundStateChangedObservable: Observable<boolean>;
  71404. /**
  71405. * constructs a new background remover module
  71406. * @param _xrSessionManager the session manager for this module
  71407. * @param options read-only options to be used in this module
  71408. */
  71409. constructor(_xrSessionManager: WebXRSessionManager,
  71410. /**
  71411. * read-only options to be used in this module
  71412. */
  71413. options?: IWebXRBackgroundRemoverOptions);
  71414. /**
  71415. * attach this feature
  71416. * Will usually be called by the features manager
  71417. *
  71418. * @returns true if successful.
  71419. */
  71420. attach(): boolean;
  71421. /**
  71422. * detach this feature.
  71423. * Will usually be called by the features manager
  71424. *
  71425. * @returns true if successful.
  71426. */
  71427. detach(): boolean;
  71428. /**
  71429. * Dispose this feature and all of the resources attached
  71430. */
  71431. dispose(): void;
  71432. protected _onXRFrame(_xrFrame: XRFrame): void;
  71433. private _setBackgroundState;
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /**
  71438. * Options for the controller physics feature
  71439. */
  71440. export class IWebXRControllerPhysicsOptions {
  71441. /**
  71442. * Should the headset get its own impostor
  71443. */
  71444. enableHeadsetImpostor?: boolean;
  71445. /**
  71446. * Optional parameters for the headset impostor
  71447. */
  71448. headsetImpostorParams?: {
  71449. /**
  71450. * The type of impostor to create. Default is sphere
  71451. */
  71452. impostorType: number;
  71453. /**
  71454. * the size of the impostor. Defaults to 10cm
  71455. */
  71456. impostorSize?: number | {
  71457. width: number;
  71458. height: number;
  71459. depth: number;
  71460. };
  71461. /**
  71462. * Friction definitions
  71463. */
  71464. friction?: number;
  71465. /**
  71466. * Restitution
  71467. */
  71468. restitution?: number;
  71469. };
  71470. /**
  71471. * The physics properties of the future impostors
  71472. */
  71473. physicsProperties?: {
  71474. /**
  71475. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71476. * Note that this requires a physics engine that supports mesh impostors!
  71477. */
  71478. useControllerMesh?: boolean;
  71479. /**
  71480. * The type of impostor to create. Default is sphere
  71481. */
  71482. impostorType?: number;
  71483. /**
  71484. * the size of the impostor. Defaults to 10cm
  71485. */
  71486. impostorSize?: number | {
  71487. width: number;
  71488. height: number;
  71489. depth: number;
  71490. };
  71491. /**
  71492. * Friction definitions
  71493. */
  71494. friction?: number;
  71495. /**
  71496. * Restitution
  71497. */
  71498. restitution?: number;
  71499. };
  71500. /**
  71501. * the xr input to use with this pointer selection
  71502. */
  71503. xrInput: WebXRInput;
  71504. }
  71505. /**
  71506. * Add physics impostor to your webxr controllers,
  71507. * including naive calculation of their linear and angular velocity
  71508. */
  71509. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71510. private readonly _options;
  71511. private _attachController;
  71512. private _controllers;
  71513. private _debugMode;
  71514. private _delta;
  71515. private _headsetImpostor?;
  71516. private _headsetMesh?;
  71517. private _lastTimestamp;
  71518. private _tmpQuaternion;
  71519. private _tmpVector;
  71520. /**
  71521. * The module's name
  71522. */
  71523. static readonly Name: string;
  71524. /**
  71525. * The (Babylon) version of this module.
  71526. * This is an integer representing the implementation version.
  71527. * This number does not correspond to the webxr specs version
  71528. */
  71529. static readonly Version: number;
  71530. /**
  71531. * Construct a new Controller Physics Feature
  71532. * @param _xrSessionManager the corresponding xr session manager
  71533. * @param _options options to create this feature with
  71534. */
  71535. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  71536. /**
  71537. * @hidden
  71538. * enable debugging - will show console outputs and the impostor mesh
  71539. */
  71540. _enablePhysicsDebug(): void;
  71541. /**
  71542. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  71543. * @param xrController the controller to add
  71544. */
  71545. addController(xrController: WebXRInputSource): void;
  71546. /**
  71547. * attach this feature
  71548. * Will usually be called by the features manager
  71549. *
  71550. * @returns true if successful.
  71551. */
  71552. attach(): boolean;
  71553. /**
  71554. * detach this feature.
  71555. * Will usually be called by the features manager
  71556. *
  71557. * @returns true if successful.
  71558. */
  71559. detach(): boolean;
  71560. /**
  71561. * Get the headset impostor, if enabled
  71562. * @returns the impostor
  71563. */
  71564. getHeadsetImpostor(): PhysicsImpostor | undefined;
  71565. /**
  71566. * Get the physics impostor of a specific controller.
  71567. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  71568. * @param controller the controller or the controller id of which to get the impostor
  71569. * @returns the impostor or null
  71570. */
  71571. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  71572. /**
  71573. * Update the physics properties provided in the constructor
  71574. * @param newProperties the new properties object
  71575. */
  71576. setPhysicsProperties(newProperties: {
  71577. impostorType?: number;
  71578. impostorSize?: number | {
  71579. width: number;
  71580. height: number;
  71581. depth: number;
  71582. };
  71583. friction?: number;
  71584. restitution?: number;
  71585. }): void;
  71586. protected _onXRFrame(_xrFrame: any): void;
  71587. private _detachController;
  71588. }
  71589. }
  71590. declare module BABYLON {
  71591. /**
  71592. * Options used for hit testing (version 2)
  71593. */
  71594. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  71595. /**
  71596. * Do not create a permanent hit test. Will usually be used when only
  71597. * transient inputs are needed.
  71598. */
  71599. disablePermanentHitTest?: boolean;
  71600. /**
  71601. * Enable transient (for example touch-based) hit test inspections
  71602. */
  71603. enableTransientHitTest?: boolean;
  71604. /**
  71605. * Offset ray for the permanent hit test
  71606. */
  71607. offsetRay?: Vector3;
  71608. /**
  71609. * Offset ray for the transient hit test
  71610. */
  71611. transientOffsetRay?: Vector3;
  71612. /**
  71613. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  71614. */
  71615. useReferenceSpace?: boolean;
  71616. }
  71617. /**
  71618. * Interface defining the babylon result of hit-test
  71619. */
  71620. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  71621. /**
  71622. * The input source that generated this hit test (if transient)
  71623. */
  71624. inputSource?: XRInputSource;
  71625. /**
  71626. * Is this a transient hit test
  71627. */
  71628. isTransient?: boolean;
  71629. /**
  71630. * Position of the hit test result
  71631. */
  71632. position: Vector3;
  71633. /**
  71634. * Rotation of the hit test result
  71635. */
  71636. rotationQuaternion: Quaternion;
  71637. }
  71638. /**
  71639. * The currently-working hit-test module.
  71640. * Hit test (or Ray-casting) is used to interact with the real world.
  71641. * For further information read here - https://github.com/immersive-web/hit-test
  71642. *
  71643. * Tested on chrome (mobile) 80.
  71644. */
  71645. export class WebXRHitTest extends WebXRAbstractFeature {
  71646. /**
  71647. * options to use when constructing this feature
  71648. */
  71649. readonly options: IWebXRHitTestOptions;
  71650. private _tmpMat;
  71651. private _tmpPos;
  71652. private _tmpQuat;
  71653. private _transientXrHitTestSource;
  71654. private _xrHitTestSource;
  71655. private initHitTestSource;
  71656. /**
  71657. * The module's name
  71658. */
  71659. static readonly Name: string;
  71660. /**
  71661. * The (Babylon) version of this module.
  71662. * This is an integer representing the implementation version.
  71663. * This number does not correspond to the WebXR specs version
  71664. */
  71665. static readonly Version: number;
  71666. /**
  71667. * When set to true, each hit test will have its own position/rotation objects
  71668. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  71669. * the developers will clone them or copy them as they see fit.
  71670. */
  71671. autoCloneTransformation: boolean;
  71672. /**
  71673. * Populated with the last native XR Hit Results
  71674. */
  71675. lastNativeXRHitResults: XRHitResult[];
  71676. /**
  71677. * Triggered when new babylon (transformed) hit test results are available
  71678. */
  71679. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  71680. /**
  71681. * Use this to temporarily pause hit test checks.
  71682. */
  71683. paused: boolean;
  71684. /**
  71685. * Creates a new instance of the hit test feature
  71686. * @param _xrSessionManager an instance of WebXRSessionManager
  71687. * @param options options to use when constructing this feature
  71688. */
  71689. constructor(_xrSessionManager: WebXRSessionManager,
  71690. /**
  71691. * options to use when constructing this feature
  71692. */
  71693. options?: IWebXRHitTestOptions);
  71694. /**
  71695. * attach this feature
  71696. * Will usually be called by the features manager
  71697. *
  71698. * @returns true if successful.
  71699. */
  71700. attach(): boolean;
  71701. /**
  71702. * detach this feature.
  71703. * Will usually be called by the features manager
  71704. *
  71705. * @returns true if successful.
  71706. */
  71707. detach(): boolean;
  71708. /**
  71709. * Dispose this feature and all of the resources attached
  71710. */
  71711. dispose(): void;
  71712. protected _onXRFrame(frame: XRFrame): void;
  71713. private _processWebXRHitTestResult;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * The motion controller class for all microsoft mixed reality controllers
  71719. */
  71720. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  71721. protected readonly _mapping: {
  71722. defaultButton: {
  71723. valueNodeName: string;
  71724. unpressedNodeName: string;
  71725. pressedNodeName: string;
  71726. };
  71727. defaultAxis: {
  71728. valueNodeName: string;
  71729. minNodeName: string;
  71730. maxNodeName: string;
  71731. };
  71732. buttons: {
  71733. "xr-standard-trigger": {
  71734. rootNodeName: string;
  71735. componentProperty: string;
  71736. states: string[];
  71737. };
  71738. "xr-standard-squeeze": {
  71739. rootNodeName: string;
  71740. componentProperty: string;
  71741. states: string[];
  71742. };
  71743. "xr-standard-touchpad": {
  71744. rootNodeName: string;
  71745. labelAnchorNodeName: string;
  71746. touchPointNodeName: string;
  71747. };
  71748. "xr-standard-thumbstick": {
  71749. rootNodeName: string;
  71750. componentProperty: string;
  71751. states: string[];
  71752. };
  71753. };
  71754. axes: {
  71755. "xr-standard-touchpad": {
  71756. "x-axis": {
  71757. rootNodeName: string;
  71758. };
  71759. "y-axis": {
  71760. rootNodeName: string;
  71761. };
  71762. };
  71763. "xr-standard-thumbstick": {
  71764. "x-axis": {
  71765. rootNodeName: string;
  71766. };
  71767. "y-axis": {
  71768. rootNodeName: string;
  71769. };
  71770. };
  71771. };
  71772. };
  71773. /**
  71774. * The base url used to load the left and right controller models
  71775. */
  71776. static MODEL_BASE_URL: string;
  71777. /**
  71778. * The name of the left controller model file
  71779. */
  71780. static MODEL_LEFT_FILENAME: string;
  71781. /**
  71782. * The name of the right controller model file
  71783. */
  71784. static MODEL_RIGHT_FILENAME: string;
  71785. profileId: string;
  71786. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71787. protected _getFilenameAndPath(): {
  71788. filename: string;
  71789. path: string;
  71790. };
  71791. protected _getModelLoadingConstraints(): boolean;
  71792. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71793. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71794. protected _updateModel(): void;
  71795. }
  71796. }
  71797. declare module BABYLON {
  71798. /**
  71799. * The motion controller class for oculus touch (quest, rift).
  71800. * This class supports legacy mapping as well the standard xr mapping
  71801. */
  71802. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  71803. private _forceLegacyControllers;
  71804. private _modelRootNode;
  71805. /**
  71806. * The base url used to load the left and right controller models
  71807. */
  71808. static MODEL_BASE_URL: string;
  71809. /**
  71810. * The name of the left controller model file
  71811. */
  71812. static MODEL_LEFT_FILENAME: string;
  71813. /**
  71814. * The name of the right controller model file
  71815. */
  71816. static MODEL_RIGHT_FILENAME: string;
  71817. /**
  71818. * Base Url for the Quest controller model.
  71819. */
  71820. static QUEST_MODEL_BASE_URL: string;
  71821. profileId: string;
  71822. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  71823. protected _getFilenameAndPath(): {
  71824. filename: string;
  71825. path: string;
  71826. };
  71827. protected _getModelLoadingConstraints(): boolean;
  71828. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71829. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71830. protected _updateModel(): void;
  71831. /**
  71832. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  71833. * between the touch and touch 2.
  71834. */
  71835. private _isQuest;
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. /**
  71840. * The motion controller class for the standard HTC-Vive controllers
  71841. */
  71842. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  71843. private _modelRootNode;
  71844. /**
  71845. * The base url used to load the left and right controller models
  71846. */
  71847. static MODEL_BASE_URL: string;
  71848. /**
  71849. * File name for the controller model.
  71850. */
  71851. static MODEL_FILENAME: string;
  71852. profileId: string;
  71853. /**
  71854. * Create a new Vive motion controller object
  71855. * @param scene the scene to use to create this controller
  71856. * @param gamepadObject the corresponding gamepad object
  71857. * @param handedness the handedness of the controller
  71858. */
  71859. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71860. protected _getFilenameAndPath(): {
  71861. filename: string;
  71862. path: string;
  71863. };
  71864. protected _getModelLoadingConstraints(): boolean;
  71865. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71866. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71867. protected _updateModel(): void;
  71868. }
  71869. }
  71870. declare module BABYLON {
  71871. /**
  71872. * A cursor which tracks a point on a path
  71873. */
  71874. export class PathCursor {
  71875. private path;
  71876. /**
  71877. * Stores path cursor callbacks for when an onchange event is triggered
  71878. */
  71879. private _onchange;
  71880. /**
  71881. * The value of the path cursor
  71882. */
  71883. value: number;
  71884. /**
  71885. * The animation array of the path cursor
  71886. */
  71887. animations: Animation[];
  71888. /**
  71889. * Initializes the path cursor
  71890. * @param path The path to track
  71891. */
  71892. constructor(path: Path2);
  71893. /**
  71894. * Gets the cursor point on the path
  71895. * @returns A point on the path cursor at the cursor location
  71896. */
  71897. getPoint(): Vector3;
  71898. /**
  71899. * Moves the cursor ahead by the step amount
  71900. * @param step The amount to move the cursor forward
  71901. * @returns This path cursor
  71902. */
  71903. moveAhead(step?: number): PathCursor;
  71904. /**
  71905. * Moves the cursor behind by the step amount
  71906. * @param step The amount to move the cursor back
  71907. * @returns This path cursor
  71908. */
  71909. moveBack(step?: number): PathCursor;
  71910. /**
  71911. * Moves the cursor by the step amount
  71912. * If the step amount is greater than one, an exception is thrown
  71913. * @param step The amount to move the cursor
  71914. * @returns This path cursor
  71915. */
  71916. move(step: number): PathCursor;
  71917. /**
  71918. * Ensures that the value is limited between zero and one
  71919. * @returns This path cursor
  71920. */
  71921. private ensureLimits;
  71922. /**
  71923. * Runs onchange callbacks on change (used by the animation engine)
  71924. * @returns This path cursor
  71925. */
  71926. private raiseOnChange;
  71927. /**
  71928. * Executes a function on change
  71929. * @param f A path cursor onchange callback
  71930. * @returns This path cursor
  71931. */
  71932. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /** @hidden */
  71937. export var blurPixelShader: {
  71938. name: string;
  71939. shader: string;
  71940. };
  71941. }
  71942. declare module BABYLON {
  71943. /** @hidden */
  71944. export var pointCloudVertexDeclaration: {
  71945. name: string;
  71946. shader: string;
  71947. };
  71948. }
  71949. // Mixins
  71950. interface Window {
  71951. mozIndexedDB: IDBFactory;
  71952. webkitIndexedDB: IDBFactory;
  71953. msIndexedDB: IDBFactory;
  71954. webkitURL: typeof URL;
  71955. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  71956. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  71957. WebGLRenderingContext: WebGLRenderingContext;
  71958. MSGesture: MSGesture;
  71959. CANNON: any;
  71960. AudioContext: AudioContext;
  71961. webkitAudioContext: AudioContext;
  71962. PointerEvent: any;
  71963. Math: Math;
  71964. Uint8Array: Uint8ArrayConstructor;
  71965. Float32Array: Float32ArrayConstructor;
  71966. mozURL: typeof URL;
  71967. msURL: typeof URL;
  71968. VRFrameData: any; // WebVR, from specs 1.1
  71969. DracoDecoderModule: any;
  71970. setImmediate(handler: (...args: any[]) => void): number;
  71971. }
  71972. interface HTMLCanvasElement {
  71973. requestPointerLock(): void;
  71974. msRequestPointerLock?(): void;
  71975. mozRequestPointerLock?(): void;
  71976. webkitRequestPointerLock?(): void;
  71977. /** Track wether a record is in progress */
  71978. isRecording: boolean;
  71979. /** Capture Stream method defined by some browsers */
  71980. captureStream(fps?: number): MediaStream;
  71981. }
  71982. interface CanvasRenderingContext2D {
  71983. msImageSmoothingEnabled: boolean;
  71984. }
  71985. interface MouseEvent {
  71986. mozMovementX: number;
  71987. mozMovementY: number;
  71988. webkitMovementX: number;
  71989. webkitMovementY: number;
  71990. msMovementX: number;
  71991. msMovementY: number;
  71992. }
  71993. interface Navigator {
  71994. mozGetVRDevices: (any: any) => any;
  71995. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71996. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71997. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71998. webkitGetGamepads(): Gamepad[];
  71999. msGetGamepads(): Gamepad[];
  72000. webkitGamepads(): Gamepad[];
  72001. }
  72002. interface HTMLVideoElement {
  72003. mozSrcObject: any;
  72004. }
  72005. interface Math {
  72006. fround(x: number): number;
  72007. imul(a: number, b: number): number;
  72008. }
  72009. interface WebGLRenderingContext {
  72010. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72011. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72012. vertexAttribDivisor(index: number, divisor: number): void;
  72013. createVertexArray(): any;
  72014. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72015. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72016. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72017. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72018. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72019. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72020. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72021. // Queries
  72022. createQuery(): WebGLQuery;
  72023. deleteQuery(query: WebGLQuery): void;
  72024. beginQuery(target: number, query: WebGLQuery): void;
  72025. endQuery(target: number): void;
  72026. getQueryParameter(query: WebGLQuery, pname: number): any;
  72027. getQuery(target: number, pname: number): any;
  72028. MAX_SAMPLES: number;
  72029. RGBA8: number;
  72030. READ_FRAMEBUFFER: number;
  72031. DRAW_FRAMEBUFFER: number;
  72032. UNIFORM_BUFFER: number;
  72033. HALF_FLOAT_OES: number;
  72034. RGBA16F: number;
  72035. RGBA32F: number;
  72036. R32F: number;
  72037. RG32F: number;
  72038. RGB32F: number;
  72039. R16F: number;
  72040. RG16F: number;
  72041. RGB16F: number;
  72042. RED: number;
  72043. RG: number;
  72044. R8: number;
  72045. RG8: number;
  72046. UNSIGNED_INT_24_8: number;
  72047. DEPTH24_STENCIL8: number;
  72048. MIN: number;
  72049. MAX: number;
  72050. /* Multiple Render Targets */
  72051. drawBuffers(buffers: number[]): void;
  72052. readBuffer(src: number): void;
  72053. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72054. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72055. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72056. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72057. // Occlusion Query
  72058. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72059. ANY_SAMPLES_PASSED: number;
  72060. QUERY_RESULT_AVAILABLE: number;
  72061. QUERY_RESULT: number;
  72062. }
  72063. interface WebGLProgram {
  72064. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72065. }
  72066. interface EXT_disjoint_timer_query {
  72067. QUERY_COUNTER_BITS_EXT: number;
  72068. TIME_ELAPSED_EXT: number;
  72069. TIMESTAMP_EXT: number;
  72070. GPU_DISJOINT_EXT: number;
  72071. QUERY_RESULT_EXT: number;
  72072. QUERY_RESULT_AVAILABLE_EXT: number;
  72073. queryCounterEXT(query: WebGLQuery, target: number): void;
  72074. createQueryEXT(): WebGLQuery;
  72075. beginQueryEXT(target: number, query: WebGLQuery): void;
  72076. endQueryEXT(target: number): void;
  72077. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72078. deleteQueryEXT(query: WebGLQuery): void;
  72079. }
  72080. interface WebGLUniformLocation {
  72081. _currentState: any;
  72082. }
  72083. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72084. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72085. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72086. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72087. interface WebGLRenderingContext {
  72088. readonly RASTERIZER_DISCARD: number;
  72089. readonly DEPTH_COMPONENT24: number;
  72090. readonly TEXTURE_3D: number;
  72091. readonly TEXTURE_2D_ARRAY: number;
  72092. readonly TEXTURE_COMPARE_FUNC: number;
  72093. readonly TEXTURE_COMPARE_MODE: number;
  72094. readonly COMPARE_REF_TO_TEXTURE: number;
  72095. readonly TEXTURE_WRAP_R: number;
  72096. readonly HALF_FLOAT: number;
  72097. readonly RGB8: number;
  72098. readonly RED_INTEGER: number;
  72099. readonly RG_INTEGER: number;
  72100. readonly RGB_INTEGER: number;
  72101. readonly RGBA_INTEGER: number;
  72102. readonly R8_SNORM: number;
  72103. readonly RG8_SNORM: number;
  72104. readonly RGB8_SNORM: number;
  72105. readonly RGBA8_SNORM: number;
  72106. readonly R8I: number;
  72107. readonly RG8I: number;
  72108. readonly RGB8I: number;
  72109. readonly RGBA8I: number;
  72110. readonly R8UI: number;
  72111. readonly RG8UI: number;
  72112. readonly RGB8UI: number;
  72113. readonly RGBA8UI: number;
  72114. readonly R16I: number;
  72115. readonly RG16I: number;
  72116. readonly RGB16I: number;
  72117. readonly RGBA16I: number;
  72118. readonly R16UI: number;
  72119. readonly RG16UI: number;
  72120. readonly RGB16UI: number;
  72121. readonly RGBA16UI: number;
  72122. readonly R32I: number;
  72123. readonly RG32I: number;
  72124. readonly RGB32I: number;
  72125. readonly RGBA32I: number;
  72126. readonly R32UI: number;
  72127. readonly RG32UI: number;
  72128. readonly RGB32UI: number;
  72129. readonly RGBA32UI: number;
  72130. readonly RGB10_A2UI: number;
  72131. readonly R11F_G11F_B10F: number;
  72132. readonly RGB9_E5: number;
  72133. readonly RGB10_A2: number;
  72134. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72135. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72136. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72137. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72138. readonly DEPTH_COMPONENT32F: number;
  72139. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72140. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72141. 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;
  72142. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72143. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72144. readonly TRANSFORM_FEEDBACK: number;
  72145. readonly INTERLEAVED_ATTRIBS: number;
  72146. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72147. createTransformFeedback(): WebGLTransformFeedback;
  72148. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72149. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72150. beginTransformFeedback(primitiveMode: number): void;
  72151. endTransformFeedback(): void;
  72152. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72153. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72154. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72155. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72156. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72157. }
  72158. interface ImageBitmap {
  72159. readonly width: number;
  72160. readonly height: number;
  72161. close(): void;
  72162. }
  72163. interface WebGLQuery extends WebGLObject {
  72164. }
  72165. declare var WebGLQuery: {
  72166. prototype: WebGLQuery;
  72167. new(): WebGLQuery;
  72168. };
  72169. interface WebGLSampler extends WebGLObject {
  72170. }
  72171. declare var WebGLSampler: {
  72172. prototype: WebGLSampler;
  72173. new(): WebGLSampler;
  72174. };
  72175. interface WebGLSync extends WebGLObject {
  72176. }
  72177. declare var WebGLSync: {
  72178. prototype: WebGLSync;
  72179. new(): WebGLSync;
  72180. };
  72181. interface WebGLTransformFeedback extends WebGLObject {
  72182. }
  72183. declare var WebGLTransformFeedback: {
  72184. prototype: WebGLTransformFeedback;
  72185. new(): WebGLTransformFeedback;
  72186. };
  72187. interface WebGLVertexArrayObject extends WebGLObject {
  72188. }
  72189. declare var WebGLVertexArrayObject: {
  72190. prototype: WebGLVertexArrayObject;
  72191. new(): WebGLVertexArrayObject;
  72192. };
  72193. // Type definitions for WebVR API
  72194. // Project: https://w3c.github.io/webvr/
  72195. // Definitions by: six a <https://github.com/lostfictions>
  72196. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72197. interface VRDisplay extends EventTarget {
  72198. /**
  72199. * Dictionary of capabilities describing the VRDisplay.
  72200. */
  72201. readonly capabilities: VRDisplayCapabilities;
  72202. /**
  72203. * z-depth defining the far plane of the eye view frustum
  72204. * enables mapping of values in the render target depth
  72205. * attachment to scene coordinates. Initially set to 10000.0.
  72206. */
  72207. depthFar: number;
  72208. /**
  72209. * z-depth defining the near plane of the eye view frustum
  72210. * enables mapping of values in the render target depth
  72211. * attachment to scene coordinates. Initially set to 0.01.
  72212. */
  72213. depthNear: number;
  72214. /**
  72215. * An identifier for this distinct VRDisplay. Used as an
  72216. * association point in the Gamepad API.
  72217. */
  72218. readonly displayId: number;
  72219. /**
  72220. * A display name, a user-readable name identifying it.
  72221. */
  72222. readonly displayName: string;
  72223. readonly isConnected: boolean;
  72224. readonly isPresenting: boolean;
  72225. /**
  72226. * If this VRDisplay supports room-scale experiences, the optional
  72227. * stage attribute contains details on the room-scale parameters.
  72228. */
  72229. readonly stageParameters: VRStageParameters | null;
  72230. /**
  72231. * Passing the value returned by `requestAnimationFrame` to
  72232. * `cancelAnimationFrame` will unregister the callback.
  72233. * @param handle Define the hanle of the request to cancel
  72234. */
  72235. cancelAnimationFrame(handle: number): void;
  72236. /**
  72237. * Stops presenting to the VRDisplay.
  72238. * @returns a promise to know when it stopped
  72239. */
  72240. exitPresent(): Promise<void>;
  72241. /**
  72242. * Return the current VREyeParameters for the given eye.
  72243. * @param whichEye Define the eye we want the parameter for
  72244. * @returns the eye parameters
  72245. */
  72246. getEyeParameters(whichEye: string): VREyeParameters;
  72247. /**
  72248. * Populates the passed VRFrameData with the information required to render
  72249. * the current frame.
  72250. * @param frameData Define the data structure to populate
  72251. * @returns true if ok otherwise false
  72252. */
  72253. getFrameData(frameData: VRFrameData): boolean;
  72254. /**
  72255. * Get the layers currently being presented.
  72256. * @returns the list of VR layers
  72257. */
  72258. getLayers(): VRLayer[];
  72259. /**
  72260. * Return a VRPose containing the future predicted pose of the VRDisplay
  72261. * when the current frame will be presented. The value returned will not
  72262. * change until JavaScript has returned control to the browser.
  72263. *
  72264. * The VRPose will contain the position, orientation, velocity,
  72265. * and acceleration of each of these properties.
  72266. * @returns the pose object
  72267. */
  72268. getPose(): VRPose;
  72269. /**
  72270. * Return the current instantaneous pose of the VRDisplay, with no
  72271. * prediction applied.
  72272. * @returns the current instantaneous pose
  72273. */
  72274. getImmediatePose(): VRPose;
  72275. /**
  72276. * The callback passed to `requestAnimationFrame` will be called
  72277. * any time a new frame should be rendered. When the VRDisplay is
  72278. * presenting the callback will be called at the native refresh
  72279. * rate of the HMD. When not presenting this function acts
  72280. * identically to how window.requestAnimationFrame acts. Content should
  72281. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72282. * asynchronously from other displays and at differing refresh rates.
  72283. * @param callback Define the eaction to run next frame
  72284. * @returns the request handle it
  72285. */
  72286. requestAnimationFrame(callback: FrameRequestCallback): number;
  72287. /**
  72288. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72289. * Repeat calls while already presenting will update the VRLayers being displayed.
  72290. * @param layers Define the list of layer to present
  72291. * @returns a promise to know when the request has been fulfilled
  72292. */
  72293. requestPresent(layers: VRLayer[]): Promise<void>;
  72294. /**
  72295. * Reset the pose for this display, treating its current position and
  72296. * orientation as the "origin/zero" values. VRPose.position,
  72297. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72298. * updated when calling resetPose(). This should be called in only
  72299. * sitting-space experiences.
  72300. */
  72301. resetPose(): void;
  72302. /**
  72303. * The VRLayer provided to the VRDisplay will be captured and presented
  72304. * in the HMD. Calling this function has the same effect on the source
  72305. * canvas as any other operation that uses its source image, and canvases
  72306. * created without preserveDrawingBuffer set to true will be cleared.
  72307. * @param pose Define the pose to submit
  72308. */
  72309. submitFrame(pose?: VRPose): void;
  72310. }
  72311. declare var VRDisplay: {
  72312. prototype: VRDisplay;
  72313. new(): VRDisplay;
  72314. };
  72315. interface VRLayer {
  72316. leftBounds?: number[] | Float32Array | null;
  72317. rightBounds?: number[] | Float32Array | null;
  72318. source?: HTMLCanvasElement | null;
  72319. }
  72320. interface VRDisplayCapabilities {
  72321. readonly canPresent: boolean;
  72322. readonly hasExternalDisplay: boolean;
  72323. readonly hasOrientation: boolean;
  72324. readonly hasPosition: boolean;
  72325. readonly maxLayers: number;
  72326. }
  72327. interface VREyeParameters {
  72328. /** @deprecated */
  72329. readonly fieldOfView: VRFieldOfView;
  72330. readonly offset: Float32Array;
  72331. readonly renderHeight: number;
  72332. readonly renderWidth: number;
  72333. }
  72334. interface VRFieldOfView {
  72335. readonly downDegrees: number;
  72336. readonly leftDegrees: number;
  72337. readonly rightDegrees: number;
  72338. readonly upDegrees: number;
  72339. }
  72340. interface VRFrameData {
  72341. readonly leftProjectionMatrix: Float32Array;
  72342. readonly leftViewMatrix: Float32Array;
  72343. readonly pose: VRPose;
  72344. readonly rightProjectionMatrix: Float32Array;
  72345. readonly rightViewMatrix: Float32Array;
  72346. readonly timestamp: number;
  72347. }
  72348. interface VRPose {
  72349. readonly angularAcceleration: Float32Array | null;
  72350. readonly angularVelocity: Float32Array | null;
  72351. readonly linearAcceleration: Float32Array | null;
  72352. readonly linearVelocity: Float32Array | null;
  72353. readonly orientation: Float32Array | null;
  72354. readonly position: Float32Array | null;
  72355. readonly timestamp: number;
  72356. }
  72357. interface VRStageParameters {
  72358. sittingToStandingTransform?: Float32Array;
  72359. sizeX?: number;
  72360. sizeY?: number;
  72361. }
  72362. interface Navigator {
  72363. getVRDisplays(): Promise<VRDisplay[]>;
  72364. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72365. }
  72366. interface Window {
  72367. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72368. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72369. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72370. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72371. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72372. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72373. }
  72374. interface Gamepad {
  72375. readonly displayId: number;
  72376. }
  72377. type XRSessionMode =
  72378. | "inline"
  72379. | "immersive-vr"
  72380. | "immersive-ar";
  72381. type XRReferenceSpaceType =
  72382. | "viewer"
  72383. | "local"
  72384. | "local-floor"
  72385. | "bounded-floor"
  72386. | "unbounded";
  72387. type XREnvironmentBlendMode =
  72388. | "opaque"
  72389. | "additive"
  72390. | "alpha-blend";
  72391. type XRVisibilityState =
  72392. | "visible"
  72393. | "visible-blurred"
  72394. | "hidden";
  72395. type XRHandedness =
  72396. | "none"
  72397. | "left"
  72398. | "right";
  72399. type XRTargetRayMode =
  72400. | "gaze"
  72401. | "tracked-pointer"
  72402. | "screen";
  72403. type XREye =
  72404. | "none"
  72405. | "left"
  72406. | "right";
  72407. type XREventType =
  72408. | "devicechange"
  72409. | "visibilitychange"
  72410. | "end"
  72411. | "inputsourceschange"
  72412. | "select"
  72413. | "selectstart"
  72414. | "selectend"
  72415. | "squeeze"
  72416. | "squeezestart"
  72417. | "squeezeend"
  72418. | "reset";
  72419. interface XRSpace extends EventTarget {
  72420. }
  72421. interface XRRenderState {
  72422. depthNear?: number;
  72423. depthFar?: number;
  72424. inlineVerticalFieldOfView?: number;
  72425. baseLayer?: XRWebGLLayer;
  72426. }
  72427. interface XRInputSource {
  72428. handedness: XRHandedness;
  72429. targetRayMode: XRTargetRayMode;
  72430. targetRaySpace: XRSpace;
  72431. gripSpace: XRSpace | undefined;
  72432. gamepad: Gamepad | undefined;
  72433. profiles: Array<string>;
  72434. }
  72435. interface XRSessionInit {
  72436. optionalFeatures?: string[];
  72437. requiredFeatures?: string[];
  72438. }
  72439. interface XRSession extends XRAnchorCreator {
  72440. addEventListener: Function;
  72441. removeEventListener: Function;
  72442. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72443. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72444. requestAnimationFrame: Function;
  72445. end(): Promise<void>;
  72446. renderState: XRRenderState;
  72447. inputSources: Array<XRInputSource>;
  72448. // hit test
  72449. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72450. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72451. // legacy AR hit test
  72452. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72453. // legacy plane detection
  72454. updateWorldTrackingState(options: {
  72455. planeDetectionState?: { enabled: boolean; }
  72456. }): void;
  72457. }
  72458. interface XRReferenceSpace extends XRSpace {
  72459. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72460. onreset: any;
  72461. }
  72462. type XRPlaneSet = Set<XRPlane>;
  72463. type XRAnchorSet = Set<XRAnchor>;
  72464. interface XRFrame {
  72465. session: XRSession;
  72466. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72467. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72468. // AR
  72469. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72470. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72471. // Anchors
  72472. trackedAnchors?: XRAnchorSet;
  72473. // Planes
  72474. worldInformation: {
  72475. detectedPlanes?: XRPlaneSet;
  72476. };
  72477. }
  72478. interface XRViewerPose extends XRPose {
  72479. views: Array<XRView>;
  72480. }
  72481. interface XRPose {
  72482. transform: XRRigidTransform;
  72483. emulatedPosition: boolean;
  72484. }
  72485. interface XRWebGLLayerOptions {
  72486. antialias?: boolean;
  72487. depth?: boolean;
  72488. stencil?: boolean;
  72489. alpha?: boolean;
  72490. multiview?: boolean;
  72491. framebufferScaleFactor?: number;
  72492. }
  72493. declare var XRWebGLLayer: {
  72494. prototype: XRWebGLLayer;
  72495. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72496. };
  72497. interface XRWebGLLayer {
  72498. framebuffer: WebGLFramebuffer;
  72499. framebufferWidth: number;
  72500. framebufferHeight: number;
  72501. getViewport: Function;
  72502. }
  72503. declare class XRRigidTransform {
  72504. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72505. position: DOMPointReadOnly;
  72506. orientation: DOMPointReadOnly;
  72507. matrix: Float32Array;
  72508. inverse: XRRigidTransform;
  72509. }
  72510. interface XRView {
  72511. eye: XREye;
  72512. projectionMatrix: Float32Array;
  72513. transform: XRRigidTransform;
  72514. }
  72515. interface XRInputSourceChangeEvent {
  72516. session: XRSession;
  72517. removed: Array<XRInputSource>;
  72518. added: Array<XRInputSource>;
  72519. }
  72520. interface XRInputSourceEvent extends Event {
  72521. readonly frame: XRFrame;
  72522. readonly inputSource: XRInputSource;
  72523. }
  72524. // Experimental(er) features
  72525. declare class XRRay {
  72526. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  72527. origin: DOMPointReadOnly;
  72528. direction: DOMPointReadOnly;
  72529. matrix: Float32Array;
  72530. }
  72531. declare enum XRHitTestTrackableType {
  72532. "point",
  72533. "plane"
  72534. }
  72535. interface XRHitResult {
  72536. hitMatrix: Float32Array;
  72537. }
  72538. interface XRTransientInputHitTestResult {
  72539. readonly inputSource: XRInputSource;
  72540. readonly results: Array<XRHitTestResult>;
  72541. }
  72542. interface XRHitTestResult {
  72543. getPose(baseSpace: XRSpace): XRPose | undefined;
  72544. }
  72545. interface XRHitTestSource {
  72546. cancel(): void;
  72547. }
  72548. interface XRTransientInputHitTestSource {
  72549. cancel(): void;
  72550. }
  72551. interface XRHitTestOptionsInit {
  72552. space: XRSpace;
  72553. entityTypes?: Array<XRHitTestTrackableType>;
  72554. offsetRay?: XRRay;
  72555. }
  72556. interface XRTransientInputHitTestOptionsInit {
  72557. profile: string;
  72558. entityTypes?: Array<XRHitTestTrackableType>;
  72559. offsetRay?: XRRay;
  72560. }
  72561. interface XRAnchor {
  72562. // remove?
  72563. id?: string;
  72564. anchorSpace: XRSpace;
  72565. lastChangedTime: number;
  72566. detach(): void;
  72567. }
  72568. interface XRPlane extends XRAnchorCreator {
  72569. orientation: "Horizontal" | "Vertical";
  72570. planeSpace: XRSpace;
  72571. polygon: Array<DOMPointReadOnly>;
  72572. lastChangedTime: number;
  72573. }
  72574. interface XRAnchorCreator {
  72575. // AR Anchors
  72576. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  72577. }
  72578. /**
  72579. * @ignore
  72580. */
  72581. declare module BABYLON.GLTF2.Exporter {
  72582. }
  72583. /**
  72584. * @ignore
  72585. */
  72586. declare module BABYLON.GLTF1 {
  72587. }
  72588. declare module BABYLON.GUI {
  72589. /**
  72590. * Class used to specific a value and its associated unit
  72591. */
  72592. export class ValueAndUnit {
  72593. /** defines the unit to store */
  72594. unit: number;
  72595. /** defines a boolean indicating if the value can be negative */
  72596. negativeValueAllowed: boolean;
  72597. private _value;
  72598. private _originalUnit;
  72599. /**
  72600. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  72601. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72602. */
  72603. ignoreAdaptiveScaling: boolean;
  72604. /**
  72605. * Creates a new ValueAndUnit
  72606. * @param value defines the value to store
  72607. * @param unit defines the unit to store
  72608. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  72609. */
  72610. constructor(value: number,
  72611. /** defines the unit to store */
  72612. unit?: number,
  72613. /** defines a boolean indicating if the value can be negative */
  72614. negativeValueAllowed?: boolean);
  72615. /** Gets a boolean indicating if the value is a percentage */
  72616. get isPercentage(): boolean;
  72617. /** Gets a boolean indicating if the value is store as pixel */
  72618. get isPixel(): boolean;
  72619. /** Gets direct internal value */
  72620. get internalValue(): number;
  72621. /**
  72622. * Gets value as pixel
  72623. * @param host defines the root host
  72624. * @param refValue defines the reference value for percentages
  72625. * @returns the value as pixel
  72626. */
  72627. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  72628. /**
  72629. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  72630. * @param value defines the value to store
  72631. * @param unit defines the unit to store
  72632. * @returns the current ValueAndUnit
  72633. */
  72634. updateInPlace(value: number, unit?: number): ValueAndUnit;
  72635. /**
  72636. * Gets the value accordingly to its unit
  72637. * @param host defines the root host
  72638. * @returns the value
  72639. */
  72640. getValue(host: AdvancedDynamicTexture): number;
  72641. /**
  72642. * Gets a string representation of the value
  72643. * @param host defines the root host
  72644. * @param decimals defines an optional number of decimals to display
  72645. * @returns a string
  72646. */
  72647. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  72648. /**
  72649. * Store a value parsed from a string
  72650. * @param source defines the source string
  72651. * @returns true if the value was successfully parsed
  72652. */
  72653. fromString(source: string | number): boolean;
  72654. private static _Regex;
  72655. private static _UNITMODE_PERCENTAGE;
  72656. private static _UNITMODE_PIXEL;
  72657. /** UNITMODE_PERCENTAGE */
  72658. static get UNITMODE_PERCENTAGE(): number;
  72659. /** UNITMODE_PIXEL */
  72660. static get UNITMODE_PIXEL(): number;
  72661. }
  72662. }
  72663. declare module BABYLON.GUI {
  72664. /**
  72665. * Define a style used by control to automatically setup properties based on a template.
  72666. * Only support font related properties so far
  72667. */
  72668. export class Style implements BABYLON.IDisposable {
  72669. private _fontFamily;
  72670. private _fontStyle;
  72671. private _fontWeight;
  72672. /** @hidden */
  72673. _host: AdvancedDynamicTexture;
  72674. /** @hidden */
  72675. _fontSize: ValueAndUnit;
  72676. /**
  72677. * BABYLON.Observable raised when the style values are changed
  72678. */
  72679. onChangedObservable: BABYLON.Observable<Style>;
  72680. /**
  72681. * Creates a new style object
  72682. * @param host defines the AdvancedDynamicTexture which hosts this style
  72683. */
  72684. constructor(host: AdvancedDynamicTexture);
  72685. /**
  72686. * Gets or sets the font size
  72687. */
  72688. get fontSize(): string | number;
  72689. set fontSize(value: string | number);
  72690. /**
  72691. * Gets or sets the font family
  72692. */
  72693. get fontFamily(): string;
  72694. set fontFamily(value: string);
  72695. /**
  72696. * Gets or sets the font style
  72697. */
  72698. get fontStyle(): string;
  72699. set fontStyle(value: string);
  72700. /** Gets or sets font weight */
  72701. get fontWeight(): string;
  72702. set fontWeight(value: string);
  72703. /** Dispose all associated resources */
  72704. dispose(): void;
  72705. }
  72706. }
  72707. declare module BABYLON.GUI {
  72708. /**
  72709. * Class used to transport BABYLON.Vector2 information for pointer events
  72710. */
  72711. export class Vector2WithInfo extends BABYLON.Vector2 {
  72712. /** defines the current mouse button index */
  72713. buttonIndex: number;
  72714. /**
  72715. * Creates a new Vector2WithInfo
  72716. * @param source defines the vector2 data to transport
  72717. * @param buttonIndex defines the current mouse button index
  72718. */
  72719. constructor(source: BABYLON.Vector2,
  72720. /** defines the current mouse button index */
  72721. buttonIndex?: number);
  72722. }
  72723. /** Class used to provide 2D matrix features */
  72724. export class Matrix2D {
  72725. /** Gets the internal array of 6 floats used to store matrix data */
  72726. m: Float32Array;
  72727. /**
  72728. * Creates a new matrix
  72729. * @param m00 defines value for (0, 0)
  72730. * @param m01 defines value for (0, 1)
  72731. * @param m10 defines value for (1, 0)
  72732. * @param m11 defines value for (1, 1)
  72733. * @param m20 defines value for (2, 0)
  72734. * @param m21 defines value for (2, 1)
  72735. */
  72736. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  72737. /**
  72738. * Fills the matrix from direct values
  72739. * @param m00 defines value for (0, 0)
  72740. * @param m01 defines value for (0, 1)
  72741. * @param m10 defines value for (1, 0)
  72742. * @param m11 defines value for (1, 1)
  72743. * @param m20 defines value for (2, 0)
  72744. * @param m21 defines value for (2, 1)
  72745. * @returns the current modified matrix
  72746. */
  72747. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  72748. /**
  72749. * Gets matrix determinant
  72750. * @returns the determinant
  72751. */
  72752. determinant(): number;
  72753. /**
  72754. * Inverses the matrix and stores it in a target matrix
  72755. * @param result defines the target matrix
  72756. * @returns the current matrix
  72757. */
  72758. invertToRef(result: Matrix2D): Matrix2D;
  72759. /**
  72760. * Multiplies the current matrix with another one
  72761. * @param other defines the second operand
  72762. * @param result defines the target matrix
  72763. * @returns the current matrix
  72764. */
  72765. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  72766. /**
  72767. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  72768. * @param x defines the x coordinate to transform
  72769. * @param y defines the x coordinate to transform
  72770. * @param result defines the target vector2
  72771. * @returns the current matrix
  72772. */
  72773. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  72774. /**
  72775. * Creates an identity matrix
  72776. * @returns a new matrix
  72777. */
  72778. static Identity(): Matrix2D;
  72779. /**
  72780. * Creates a translation matrix and stores it in a target matrix
  72781. * @param x defines the x coordinate of the translation
  72782. * @param y defines the y coordinate of the translation
  72783. * @param result defines the target matrix
  72784. */
  72785. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  72786. /**
  72787. * Creates a scaling matrix and stores it in a target matrix
  72788. * @param x defines the x coordinate of the scaling
  72789. * @param y defines the y coordinate of the scaling
  72790. * @param result defines the target matrix
  72791. */
  72792. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  72793. /**
  72794. * Creates a rotation matrix and stores it in a target matrix
  72795. * @param angle defines the rotation angle
  72796. * @param result defines the target matrix
  72797. */
  72798. static RotationToRef(angle: number, result: Matrix2D): void;
  72799. private static _TempPreTranslationMatrix;
  72800. private static _TempPostTranslationMatrix;
  72801. private static _TempRotationMatrix;
  72802. private static _TempScalingMatrix;
  72803. private static _TempCompose0;
  72804. private static _TempCompose1;
  72805. private static _TempCompose2;
  72806. /**
  72807. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  72808. * @param tx defines the x coordinate of the translation
  72809. * @param ty defines the y coordinate of the translation
  72810. * @param angle defines the rotation angle
  72811. * @param scaleX defines the x coordinate of the scaling
  72812. * @param scaleY defines the y coordinate of the scaling
  72813. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  72814. * @param result defines the target matrix
  72815. */
  72816. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  72817. }
  72818. }
  72819. declare module BABYLON.GUI {
  72820. /**
  72821. * Class used to store 2D control sizes
  72822. */
  72823. export class Measure {
  72824. /** defines left coordinate */
  72825. left: number;
  72826. /** defines top coordinate */
  72827. top: number;
  72828. /** defines width dimension */
  72829. width: number;
  72830. /** defines height dimension */
  72831. height: number;
  72832. /**
  72833. * Creates a new measure
  72834. * @param left defines left coordinate
  72835. * @param top defines top coordinate
  72836. * @param width defines width dimension
  72837. * @param height defines height dimension
  72838. */
  72839. constructor(
  72840. /** defines left coordinate */
  72841. left: number,
  72842. /** defines top coordinate */
  72843. top: number,
  72844. /** defines width dimension */
  72845. width: number,
  72846. /** defines height dimension */
  72847. height: number);
  72848. /**
  72849. * Copy from another measure
  72850. * @param other defines the other measure to copy from
  72851. */
  72852. copyFrom(other: Measure): void;
  72853. /**
  72854. * Copy from a group of 4 floats
  72855. * @param left defines left coordinate
  72856. * @param top defines top coordinate
  72857. * @param width defines width dimension
  72858. * @param height defines height dimension
  72859. */
  72860. copyFromFloats(left: number, top: number, width: number, height: number): void;
  72861. /**
  72862. * Computes the axis aligned bounding box measure for two given measures
  72863. * @param a Input measure
  72864. * @param b Input measure
  72865. * @param result the resulting bounding measure
  72866. */
  72867. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  72868. /**
  72869. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  72870. * @param transform the matrix to transform the measure before computing the AABB
  72871. * @param result the resulting AABB
  72872. */
  72873. transformToRef(transform: Matrix2D, result: Measure): void;
  72874. /**
  72875. * Check equality between this measure and another one
  72876. * @param other defines the other measures
  72877. * @returns true if both measures are equals
  72878. */
  72879. isEqualsTo(other: Measure): boolean;
  72880. /**
  72881. * Creates an empty measure
  72882. * @returns a new measure
  72883. */
  72884. static Empty(): Measure;
  72885. }
  72886. }
  72887. declare module BABYLON.GUI {
  72888. /**
  72889. * Interface used to define a control that can receive focus
  72890. */
  72891. export interface IFocusableControl {
  72892. /**
  72893. * Function called when the control receives the focus
  72894. */
  72895. onFocus(): void;
  72896. /**
  72897. * Function called when the control loses the focus
  72898. */
  72899. onBlur(): void;
  72900. /**
  72901. * Function called to let the control handle keyboard events
  72902. * @param evt defines the current keyboard event
  72903. */
  72904. processKeyboard(evt: KeyboardEvent): void;
  72905. /**
  72906. * Function called to get the list of controls that should not steal the focus from this control
  72907. * @returns an array of controls
  72908. */
  72909. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72910. }
  72911. /**
  72912. * Class used to create texture to support 2D GUI elements
  72913. * @see http://doc.babylonjs.com/how_to/gui
  72914. */
  72915. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  72916. private _isDirty;
  72917. private _renderObserver;
  72918. private _resizeObserver;
  72919. private _preKeyboardObserver;
  72920. private _pointerMoveObserver;
  72921. private _pointerObserver;
  72922. private _canvasPointerOutObserver;
  72923. private _background;
  72924. /** @hidden */
  72925. _rootContainer: Container;
  72926. /** @hidden */
  72927. _lastPickedControl: Control;
  72928. /** @hidden */
  72929. _lastControlOver: {
  72930. [pointerId: number]: Control;
  72931. };
  72932. /** @hidden */
  72933. _lastControlDown: {
  72934. [pointerId: number]: Control;
  72935. };
  72936. /** @hidden */
  72937. _capturingControl: {
  72938. [pointerId: number]: Control;
  72939. };
  72940. /** @hidden */
  72941. _shouldBlockPointer: boolean;
  72942. /** @hidden */
  72943. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  72944. /** @hidden */
  72945. _linkedControls: Control[];
  72946. private _isFullscreen;
  72947. private _fullscreenViewport;
  72948. private _idealWidth;
  72949. private _idealHeight;
  72950. private _useSmallestIdeal;
  72951. private _renderAtIdealSize;
  72952. private _focusedControl;
  72953. private _blockNextFocusCheck;
  72954. private _renderScale;
  72955. private _rootElement;
  72956. private _cursorChanged;
  72957. private _defaultMousePointerId;
  72958. /** @hidden */
  72959. _numLayoutCalls: number;
  72960. /** Gets the number of layout calls made the last time the ADT has been rendered */
  72961. get numLayoutCalls(): number;
  72962. /** @hidden */
  72963. _numRenderCalls: number;
  72964. /** Gets the number of render calls made the last time the ADT has been rendered */
  72965. get numRenderCalls(): number;
  72966. /**
  72967. * Define type to string to ensure compatibility across browsers
  72968. * Safari doesn't support DataTransfer constructor
  72969. */
  72970. private _clipboardData;
  72971. /**
  72972. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  72973. */
  72974. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  72975. /**
  72976. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  72977. */
  72978. onControlPickedObservable: BABYLON.Observable<Control>;
  72979. /**
  72980. * BABYLON.Observable event triggered before layout is evaluated
  72981. */
  72982. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72983. /**
  72984. * BABYLON.Observable event triggered after the layout was evaluated
  72985. */
  72986. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72987. /**
  72988. * BABYLON.Observable event triggered before the texture is rendered
  72989. */
  72990. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72991. /**
  72992. * BABYLON.Observable event triggered after the texture was rendered
  72993. */
  72994. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72995. /**
  72996. * Gets or sets a boolean defining if alpha is stored as premultiplied
  72997. */
  72998. premulAlpha: boolean;
  72999. /**
  73000. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73001. * Useful when you want more antialiasing
  73002. */
  73003. get renderScale(): number;
  73004. set renderScale(value: number);
  73005. /** Gets or sets the background color */
  73006. get background(): string;
  73007. set background(value: string);
  73008. /**
  73009. * Gets or sets the ideal width used to design controls.
  73010. * The GUI will then rescale everything accordingly
  73011. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73012. */
  73013. get idealWidth(): number;
  73014. set idealWidth(value: number);
  73015. /**
  73016. * Gets or sets the ideal height used to design controls.
  73017. * The GUI will then rescale everything accordingly
  73018. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73019. */
  73020. get idealHeight(): number;
  73021. set idealHeight(value: number);
  73022. /**
  73023. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73024. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73025. */
  73026. get useSmallestIdeal(): boolean;
  73027. set useSmallestIdeal(value: boolean);
  73028. /**
  73029. * Gets or sets a boolean indicating if adaptive scaling must be used
  73030. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73031. */
  73032. get renderAtIdealSize(): boolean;
  73033. set renderAtIdealSize(value: boolean);
  73034. /**
  73035. * Gets the ratio used when in "ideal mode"
  73036. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73037. * */
  73038. get idealRatio(): number;
  73039. /**
  73040. * Gets the underlying layer used to render the texture when in fullscreen mode
  73041. */
  73042. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73043. /**
  73044. * Gets the root container control
  73045. */
  73046. get rootContainer(): Container;
  73047. /**
  73048. * Returns an array containing the root container.
  73049. * This is mostly used to let the Inspector introspects the ADT
  73050. * @returns an array containing the rootContainer
  73051. */
  73052. getChildren(): Array<Container>;
  73053. /**
  73054. * Will return all controls that are inside this texture
  73055. * @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
  73056. * @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
  73057. * @return all child controls
  73058. */
  73059. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73060. /**
  73061. * Gets or sets the current focused control
  73062. */
  73063. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73064. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73065. /**
  73066. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73067. */
  73068. get isForeground(): boolean;
  73069. set isForeground(value: boolean);
  73070. /**
  73071. * Gets or set information about clipboardData
  73072. */
  73073. get clipboardData(): string;
  73074. set clipboardData(value: string);
  73075. /**
  73076. * Creates a new AdvancedDynamicTexture
  73077. * @param name defines the name of the texture
  73078. * @param width defines the width of the texture
  73079. * @param height defines the height of the texture
  73080. * @param scene defines the hosting scene
  73081. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73082. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73083. */
  73084. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73085. /**
  73086. * Get the current class name of the texture useful for serialization or dynamic coding.
  73087. * @returns "AdvancedDynamicTexture"
  73088. */
  73089. getClassName(): string;
  73090. /**
  73091. * Function used to execute a function on all controls
  73092. * @param func defines the function to execute
  73093. * @param container defines the container where controls belong. If null the root container will be used
  73094. */
  73095. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73096. private _useInvalidateRectOptimization;
  73097. /**
  73098. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73099. */
  73100. get useInvalidateRectOptimization(): boolean;
  73101. set useInvalidateRectOptimization(value: boolean);
  73102. private _invalidatedRectangle;
  73103. /**
  73104. * Invalidates a rectangle area on the gui texture
  73105. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73106. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73107. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73108. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73109. */
  73110. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73111. /**
  73112. * Marks the texture as dirty forcing a complete update
  73113. */
  73114. markAsDirty(): void;
  73115. /**
  73116. * Helper function used to create a new style
  73117. * @returns a new style
  73118. * @see http://doc.babylonjs.com/how_to/gui#styles
  73119. */
  73120. createStyle(): Style;
  73121. /**
  73122. * Adds a new control to the root container
  73123. * @param control defines the control to add
  73124. * @returns the current texture
  73125. */
  73126. addControl(control: Control): AdvancedDynamicTexture;
  73127. /**
  73128. * Removes a control from the root container
  73129. * @param control defines the control to remove
  73130. * @returns the current texture
  73131. */
  73132. removeControl(control: Control): AdvancedDynamicTexture;
  73133. /**
  73134. * Release all resources
  73135. */
  73136. dispose(): void;
  73137. private _onResize;
  73138. /** @hidden */
  73139. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73140. /**
  73141. * Get screen coordinates for a vector3
  73142. * @param position defines the position to project
  73143. * @param worldMatrix defines the world matrix to use
  73144. * @returns the projected position
  73145. */
  73146. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73147. private _checkUpdate;
  73148. private _clearMeasure;
  73149. private _render;
  73150. /** @hidden */
  73151. _changeCursor(cursor: string): void;
  73152. /** @hidden */
  73153. _registerLastControlDown(control: Control, pointerId: number): void;
  73154. private _doPicking;
  73155. /** @hidden */
  73156. _cleanControlAfterRemovalFromList(list: {
  73157. [pointerId: number]: Control;
  73158. }, control: Control): void;
  73159. /** @hidden */
  73160. _cleanControlAfterRemoval(control: Control): void;
  73161. /** Attach to all scene events required to support pointer events */
  73162. attach(): void;
  73163. /** @hidden */
  73164. private onClipboardCopy;
  73165. /** @hidden */
  73166. private onClipboardCut;
  73167. /** @hidden */
  73168. private onClipboardPaste;
  73169. /**
  73170. * Register the clipboard Events onto the canvas
  73171. */
  73172. registerClipboardEvents(): void;
  73173. /**
  73174. * Unregister the clipboard Events from the canvas
  73175. */
  73176. unRegisterClipboardEvents(): void;
  73177. /**
  73178. * Connect the texture to a hosting mesh to enable interactions
  73179. * @param mesh defines the mesh to attach to
  73180. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73181. */
  73182. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73183. /**
  73184. * Move the focus to a specific control
  73185. * @param control defines the control which will receive the focus
  73186. */
  73187. moveFocusToControl(control: IFocusableControl): void;
  73188. private _manageFocus;
  73189. private _attachToOnPointerOut;
  73190. /**
  73191. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73192. * @param mesh defines the mesh which will receive the texture
  73193. * @param width defines the texture width (1024 by default)
  73194. * @param height defines the texture height (1024 by default)
  73195. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73196. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73197. * @returns a new AdvancedDynamicTexture
  73198. */
  73199. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73200. /**
  73201. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73202. * In this mode the texture will rely on a layer for its rendering.
  73203. * This allows it to be treated like any other layer.
  73204. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73205. * LayerMask is set through advancedTexture.layer.layerMask
  73206. * @param name defines name for the texture
  73207. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73208. * @param scene defines the hsoting scene
  73209. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73210. * @returns a new AdvancedDynamicTexture
  73211. */
  73212. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73213. }
  73214. }
  73215. declare module BABYLON.GUI {
  73216. /**
  73217. * Root class used for all 2D controls
  73218. * @see http://doc.babylonjs.com/how_to/gui#controls
  73219. */
  73220. export class Control {
  73221. /** defines the name of the control */
  73222. name?: string | undefined;
  73223. /**
  73224. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73225. */
  73226. static AllowAlphaInheritance: boolean;
  73227. private _alpha;
  73228. private _alphaSet;
  73229. private _zIndex;
  73230. /** @hidden */
  73231. _host: AdvancedDynamicTexture;
  73232. /** Gets or sets the control parent */
  73233. parent: BABYLON.Nullable<Container>;
  73234. /** @hidden */
  73235. _currentMeasure: Measure;
  73236. private _fontFamily;
  73237. private _fontStyle;
  73238. private _fontWeight;
  73239. private _fontSize;
  73240. private _font;
  73241. /** @hidden */
  73242. _width: ValueAndUnit;
  73243. /** @hidden */
  73244. _height: ValueAndUnit;
  73245. /** @hidden */
  73246. protected _fontOffset: {
  73247. ascent: number;
  73248. height: number;
  73249. descent: number;
  73250. };
  73251. private _color;
  73252. private _style;
  73253. private _styleObserver;
  73254. /** @hidden */
  73255. protected _horizontalAlignment: number;
  73256. /** @hidden */
  73257. protected _verticalAlignment: number;
  73258. /** @hidden */
  73259. protected _isDirty: boolean;
  73260. /** @hidden */
  73261. protected _wasDirty: boolean;
  73262. /** @hidden */
  73263. _tempParentMeasure: Measure;
  73264. /** @hidden */
  73265. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73266. /** @hidden */
  73267. protected _cachedParentMeasure: Measure;
  73268. private _paddingLeft;
  73269. private _paddingRight;
  73270. private _paddingTop;
  73271. private _paddingBottom;
  73272. /** @hidden */
  73273. _left: ValueAndUnit;
  73274. /** @hidden */
  73275. _top: ValueAndUnit;
  73276. private _scaleX;
  73277. private _scaleY;
  73278. private _rotation;
  73279. private _transformCenterX;
  73280. private _transformCenterY;
  73281. /** @hidden */
  73282. _transformMatrix: Matrix2D;
  73283. /** @hidden */
  73284. protected _invertTransformMatrix: Matrix2D;
  73285. /** @hidden */
  73286. protected _transformedPosition: BABYLON.Vector2;
  73287. private _isMatrixDirty;
  73288. private _cachedOffsetX;
  73289. private _cachedOffsetY;
  73290. private _isVisible;
  73291. private _isHighlighted;
  73292. /** @hidden */
  73293. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73294. private _fontSet;
  73295. private _dummyVector2;
  73296. private _downCount;
  73297. private _enterCount;
  73298. private _doNotRender;
  73299. private _downPointerIds;
  73300. protected _isEnabled: boolean;
  73301. protected _disabledColor: string;
  73302. protected _disabledColorItem: string;
  73303. /** @hidden */
  73304. protected _rebuildLayout: boolean;
  73305. /** @hidden */
  73306. _customData: any;
  73307. /** @hidden */
  73308. _isClipped: boolean;
  73309. /** @hidden */
  73310. _automaticSize: boolean;
  73311. /** @hidden */
  73312. _tag: any;
  73313. /**
  73314. * 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
  73315. */
  73316. uniqueId: number;
  73317. /**
  73318. * Gets or sets an object used to store user defined information for the node
  73319. */
  73320. metadata: any;
  73321. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73322. isHitTestVisible: boolean;
  73323. /** Gets or sets a boolean indicating if the control can block pointer events */
  73324. isPointerBlocker: boolean;
  73325. /** Gets or sets a boolean indicating if the control can be focusable */
  73326. isFocusInvisible: boolean;
  73327. /**
  73328. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73329. * 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
  73330. */
  73331. clipChildren: boolean;
  73332. /**
  73333. * Gets or sets a boolean indicating that control content must be clipped
  73334. * 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
  73335. */
  73336. clipContent: boolean;
  73337. /**
  73338. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73339. */
  73340. useBitmapCache: boolean;
  73341. private _cacheData;
  73342. private _shadowOffsetX;
  73343. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73344. get shadowOffsetX(): number;
  73345. set shadowOffsetX(value: number);
  73346. private _shadowOffsetY;
  73347. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73348. get shadowOffsetY(): number;
  73349. set shadowOffsetY(value: number);
  73350. private _shadowBlur;
  73351. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73352. get shadowBlur(): number;
  73353. set shadowBlur(value: number);
  73354. private _shadowColor;
  73355. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73356. get shadowColor(): string;
  73357. set shadowColor(value: string);
  73358. /** Gets or sets the cursor to use when the control is hovered */
  73359. hoverCursor: string;
  73360. /** @hidden */
  73361. protected _linkOffsetX: ValueAndUnit;
  73362. /** @hidden */
  73363. protected _linkOffsetY: ValueAndUnit;
  73364. /** Gets the control type name */
  73365. get typeName(): string;
  73366. /**
  73367. * Get the current class name of the control.
  73368. * @returns current class name
  73369. */
  73370. getClassName(): string;
  73371. /**
  73372. * An event triggered when pointer wheel is scrolled
  73373. */
  73374. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73375. /**
  73376. * An event triggered when the pointer move over the control.
  73377. */
  73378. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73379. /**
  73380. * An event triggered when the pointer move out of the control.
  73381. */
  73382. onPointerOutObservable: BABYLON.Observable<Control>;
  73383. /**
  73384. * An event triggered when the pointer taps the control
  73385. */
  73386. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73387. /**
  73388. * An event triggered when pointer up
  73389. */
  73390. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73391. /**
  73392. * An event triggered when a control is clicked on
  73393. */
  73394. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73395. /**
  73396. * An event triggered when pointer enters the control
  73397. */
  73398. onPointerEnterObservable: BABYLON.Observable<Control>;
  73399. /**
  73400. * An event triggered when the control is marked as dirty
  73401. */
  73402. onDirtyObservable: BABYLON.Observable<Control>;
  73403. /**
  73404. * An event triggered before drawing the control
  73405. */
  73406. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73407. /**
  73408. * An event triggered after the control was drawn
  73409. */
  73410. onAfterDrawObservable: BABYLON.Observable<Control>;
  73411. /**
  73412. * An event triggered when the control has been disposed
  73413. */
  73414. onDisposeObservable: BABYLON.Observable<Control>;
  73415. /**
  73416. * Get the hosting AdvancedDynamicTexture
  73417. */
  73418. get host(): AdvancedDynamicTexture;
  73419. /** Gets or set information about font offsets (used to render and align text) */
  73420. get fontOffset(): {
  73421. ascent: number;
  73422. height: number;
  73423. descent: number;
  73424. };
  73425. set fontOffset(offset: {
  73426. ascent: number;
  73427. height: number;
  73428. descent: number;
  73429. });
  73430. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73431. get alpha(): number;
  73432. set alpha(value: number);
  73433. /**
  73434. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73435. */
  73436. get isHighlighted(): boolean;
  73437. set isHighlighted(value: boolean);
  73438. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73439. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73440. */
  73441. get scaleX(): number;
  73442. set scaleX(value: number);
  73443. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73444. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73445. */
  73446. get scaleY(): number;
  73447. set scaleY(value: number);
  73448. /** Gets or sets the rotation angle (0 by default)
  73449. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73450. */
  73451. get rotation(): number;
  73452. set rotation(value: number);
  73453. /** Gets or sets the transformation center on Y axis (0 by default)
  73454. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73455. */
  73456. get transformCenterY(): number;
  73457. set transformCenterY(value: number);
  73458. /** Gets or sets the transformation center on X axis (0 by default)
  73459. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73460. */
  73461. get transformCenterX(): number;
  73462. set transformCenterX(value: number);
  73463. /**
  73464. * Gets or sets the horizontal alignment
  73465. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73466. */
  73467. get horizontalAlignment(): number;
  73468. set horizontalAlignment(value: number);
  73469. /**
  73470. * Gets or sets the vertical alignment
  73471. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73472. */
  73473. get verticalAlignment(): number;
  73474. set verticalAlignment(value: number);
  73475. /**
  73476. * Gets or sets control width
  73477. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73478. */
  73479. get width(): string | number;
  73480. set width(value: string | number);
  73481. /**
  73482. * Gets or sets the control width in pixel
  73483. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73484. */
  73485. get widthInPixels(): number;
  73486. set widthInPixels(value: number);
  73487. /**
  73488. * Gets or sets control height
  73489. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73490. */
  73491. get height(): string | number;
  73492. set height(value: string | number);
  73493. /**
  73494. * Gets or sets control height in pixel
  73495. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73496. */
  73497. get heightInPixels(): number;
  73498. set heightInPixels(value: number);
  73499. /** Gets or set font family */
  73500. get fontFamily(): string;
  73501. set fontFamily(value: string);
  73502. /** Gets or sets font style */
  73503. get fontStyle(): string;
  73504. set fontStyle(value: string);
  73505. /** Gets or sets font weight */
  73506. get fontWeight(): string;
  73507. set fontWeight(value: string);
  73508. /**
  73509. * Gets or sets style
  73510. * @see http://doc.babylonjs.com/how_to/gui#styles
  73511. */
  73512. get style(): BABYLON.Nullable<Style>;
  73513. set style(value: BABYLON.Nullable<Style>);
  73514. /** @hidden */
  73515. get _isFontSizeInPercentage(): boolean;
  73516. /** Gets or sets font size in pixels */
  73517. get fontSizeInPixels(): number;
  73518. set fontSizeInPixels(value: number);
  73519. /** Gets or sets font size */
  73520. get fontSize(): string | number;
  73521. set fontSize(value: string | number);
  73522. /** Gets or sets foreground color */
  73523. get color(): string;
  73524. set color(value: string);
  73525. /** Gets or sets z index which is used to reorder controls on the z axis */
  73526. get zIndex(): number;
  73527. set zIndex(value: number);
  73528. /** Gets or sets a boolean indicating if the control can be rendered */
  73529. get notRenderable(): boolean;
  73530. set notRenderable(value: boolean);
  73531. /** Gets or sets a boolean indicating if the control is visible */
  73532. get isVisible(): boolean;
  73533. set isVisible(value: boolean);
  73534. /** Gets a boolean indicating that the control needs to update its rendering */
  73535. get isDirty(): boolean;
  73536. /**
  73537. * Gets the current linked mesh (or null if none)
  73538. */
  73539. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73540. /**
  73541. * Gets or sets a value indicating the padding to use on the left of the control
  73542. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73543. */
  73544. get paddingLeft(): string | number;
  73545. set paddingLeft(value: string | number);
  73546. /**
  73547. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  73548. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73549. */
  73550. get paddingLeftInPixels(): number;
  73551. set paddingLeftInPixels(value: number);
  73552. /**
  73553. * Gets or sets a value indicating the padding to use on the right of the control
  73554. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73555. */
  73556. get paddingRight(): string | number;
  73557. set paddingRight(value: string | number);
  73558. /**
  73559. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  73560. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73561. */
  73562. get paddingRightInPixels(): number;
  73563. set paddingRightInPixels(value: number);
  73564. /**
  73565. * Gets or sets a value indicating the padding to use on the top of the control
  73566. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73567. */
  73568. get paddingTop(): string | number;
  73569. set paddingTop(value: string | number);
  73570. /**
  73571. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  73572. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73573. */
  73574. get paddingTopInPixels(): number;
  73575. set paddingTopInPixels(value: number);
  73576. /**
  73577. * Gets or sets a value indicating the padding to use on the bottom of the control
  73578. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73579. */
  73580. get paddingBottom(): string | number;
  73581. set paddingBottom(value: string | number);
  73582. /**
  73583. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  73584. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73585. */
  73586. get paddingBottomInPixels(): number;
  73587. set paddingBottomInPixels(value: number);
  73588. /**
  73589. * Gets or sets a value indicating the left coordinate of the control
  73590. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73591. */
  73592. get left(): string | number;
  73593. set left(value: string | number);
  73594. /**
  73595. * Gets or sets a value indicating the left coordinate in pixels of the control
  73596. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73597. */
  73598. get leftInPixels(): number;
  73599. set leftInPixels(value: number);
  73600. /**
  73601. * Gets or sets a value indicating the top coordinate of the control
  73602. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73603. */
  73604. get top(): string | number;
  73605. set top(value: string | number);
  73606. /**
  73607. * Gets or sets a value indicating the top coordinate in pixels of the control
  73608. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73609. */
  73610. get topInPixels(): number;
  73611. set topInPixels(value: number);
  73612. /**
  73613. * Gets or sets a value indicating the offset on X axis to the linked mesh
  73614. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73615. */
  73616. get linkOffsetX(): string | number;
  73617. set linkOffsetX(value: string | number);
  73618. /**
  73619. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  73620. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73621. */
  73622. get linkOffsetXInPixels(): number;
  73623. set linkOffsetXInPixels(value: number);
  73624. /**
  73625. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  73626. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73627. */
  73628. get linkOffsetY(): string | number;
  73629. set linkOffsetY(value: string | number);
  73630. /**
  73631. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  73632. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73633. */
  73634. get linkOffsetYInPixels(): number;
  73635. set linkOffsetYInPixels(value: number);
  73636. /** Gets the center coordinate on X axis */
  73637. get centerX(): number;
  73638. /** Gets the center coordinate on Y axis */
  73639. get centerY(): number;
  73640. /** Gets or sets if control is Enabled*/
  73641. get isEnabled(): boolean;
  73642. set isEnabled(value: boolean);
  73643. /** Gets or sets background color of control if it's disabled*/
  73644. get disabledColor(): string;
  73645. set disabledColor(value: string);
  73646. /** Gets or sets front color of control if it's disabled*/
  73647. get disabledColorItem(): string;
  73648. set disabledColorItem(value: string);
  73649. /**
  73650. * Creates a new control
  73651. * @param name defines the name of the control
  73652. */
  73653. constructor(
  73654. /** defines the name of the control */
  73655. name?: string | undefined);
  73656. /** @hidden */
  73657. protected _getTypeName(): string;
  73658. /**
  73659. * Gets the first ascendant in the hierarchy of the given type
  73660. * @param className defines the required type
  73661. * @returns the ascendant or null if not found
  73662. */
  73663. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  73664. /** @hidden */
  73665. _resetFontCache(): void;
  73666. /**
  73667. * Determines if a container is an ascendant of the current control
  73668. * @param container defines the container to look for
  73669. * @returns true if the container is one of the ascendant of the control
  73670. */
  73671. isAscendant(container: Control): boolean;
  73672. /**
  73673. * Gets coordinates in local control space
  73674. * @param globalCoordinates defines the coordinates to transform
  73675. * @returns the new coordinates in local space
  73676. */
  73677. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73678. /**
  73679. * Gets coordinates in local control space
  73680. * @param globalCoordinates defines the coordinates to transform
  73681. * @param result defines the target vector2 where to store the result
  73682. * @returns the current control
  73683. */
  73684. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  73685. /**
  73686. * Gets coordinates in parent local control space
  73687. * @param globalCoordinates defines the coordinates to transform
  73688. * @returns the new coordinates in parent local space
  73689. */
  73690. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73691. /**
  73692. * Move the current control to a vector3 position projected onto the screen.
  73693. * @param position defines the target position
  73694. * @param scene defines the hosting scene
  73695. */
  73696. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  73697. /**
  73698. * Will store all controls that have this control as ascendant in a given array
  73699. * @param results defines the array where to store the descendants
  73700. * @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
  73701. * @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
  73702. */
  73703. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73704. /**
  73705. * Will return all controls that have this control as ascendant
  73706. * @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
  73707. * @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
  73708. * @return all child controls
  73709. */
  73710. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73711. /**
  73712. * Link current control with a target mesh
  73713. * @param mesh defines the mesh to link with
  73714. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73715. */
  73716. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  73717. /** @hidden */
  73718. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  73719. /** @hidden */
  73720. _offsetLeft(offset: number): void;
  73721. /** @hidden */
  73722. _offsetTop(offset: number): void;
  73723. /** @hidden */
  73724. _markMatrixAsDirty(): void;
  73725. /** @hidden */
  73726. _flagDescendantsAsMatrixDirty(): void;
  73727. /** @hidden */
  73728. _intersectsRect(rect: Measure): boolean;
  73729. /** @hidden */
  73730. protected invalidateRect(): void;
  73731. /** @hidden */
  73732. _markAsDirty(force?: boolean): void;
  73733. /** @hidden */
  73734. _markAllAsDirty(): void;
  73735. /** @hidden */
  73736. _link(host: AdvancedDynamicTexture): void;
  73737. /** @hidden */
  73738. protected _transform(context?: CanvasRenderingContext2D): void;
  73739. /** @hidden */
  73740. _renderHighlight(context: CanvasRenderingContext2D): void;
  73741. /** @hidden */
  73742. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73743. /** @hidden */
  73744. protected _applyStates(context: CanvasRenderingContext2D): void;
  73745. /** @hidden */
  73746. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73747. /** @hidden */
  73748. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73749. protected _evaluateClippingState(parentMeasure: Measure): void;
  73750. /** @hidden */
  73751. _measure(): void;
  73752. /** @hidden */
  73753. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73754. /** @hidden */
  73755. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73756. /** @hidden */
  73757. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73758. /** @hidden */
  73759. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73760. private static _ClipMeasure;
  73761. private _tmpMeasureA;
  73762. private _clip;
  73763. /** @hidden */
  73764. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  73765. /** @hidden */
  73766. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73767. /**
  73768. * Tests if a given coordinates belong to the current control
  73769. * @param x defines x coordinate to test
  73770. * @param y defines y coordinate to test
  73771. * @returns true if the coordinates are inside the control
  73772. */
  73773. contains(x: number, y: number): boolean;
  73774. /** @hidden */
  73775. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73776. /** @hidden */
  73777. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73778. /** @hidden */
  73779. _onPointerEnter(target: Control): boolean;
  73780. /** @hidden */
  73781. _onPointerOut(target: Control, force?: boolean): void;
  73782. /** @hidden */
  73783. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73784. /** @hidden */
  73785. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73786. /** @hidden */
  73787. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73788. /** @hidden */
  73789. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  73790. /** @hidden */
  73791. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73792. private _prepareFont;
  73793. /** Releases associated resources */
  73794. dispose(): void;
  73795. private static _HORIZONTAL_ALIGNMENT_LEFT;
  73796. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  73797. private static _HORIZONTAL_ALIGNMENT_CENTER;
  73798. private static _VERTICAL_ALIGNMENT_TOP;
  73799. private static _VERTICAL_ALIGNMENT_BOTTOM;
  73800. private static _VERTICAL_ALIGNMENT_CENTER;
  73801. /** HORIZONTAL_ALIGNMENT_LEFT */
  73802. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  73803. /** HORIZONTAL_ALIGNMENT_RIGHT */
  73804. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  73805. /** HORIZONTAL_ALIGNMENT_CENTER */
  73806. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  73807. /** VERTICAL_ALIGNMENT_TOP */
  73808. static get VERTICAL_ALIGNMENT_TOP(): number;
  73809. /** VERTICAL_ALIGNMENT_BOTTOM */
  73810. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  73811. /** VERTICAL_ALIGNMENT_CENTER */
  73812. static get VERTICAL_ALIGNMENT_CENTER(): number;
  73813. private static _FontHeightSizes;
  73814. /** @hidden */
  73815. static _GetFontOffset(font: string): {
  73816. ascent: number;
  73817. height: number;
  73818. descent: number;
  73819. };
  73820. /**
  73821. * Creates a stack panel that can be used to render headers
  73822. * @param control defines the control to associate with the header
  73823. * @param text defines the text of the header
  73824. * @param size defines the size of the header
  73825. * @param options defines options used to configure the header
  73826. * @returns a new StackPanel
  73827. * @ignore
  73828. * @hidden
  73829. */
  73830. static AddHeader: (control: Control, text: string, size: string | number, options: {
  73831. isHorizontal: boolean;
  73832. controlFirst: boolean;
  73833. }) => any;
  73834. /** @hidden */
  73835. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  73836. }
  73837. }
  73838. declare module BABYLON.GUI {
  73839. /**
  73840. * Root class for 2D containers
  73841. * @see http://doc.babylonjs.com/how_to/gui#containers
  73842. */
  73843. export class Container extends Control {
  73844. name?: string | undefined;
  73845. /** @hidden */
  73846. _children: Control[];
  73847. /** @hidden */
  73848. protected _measureForChildren: Measure;
  73849. /** @hidden */
  73850. protected _background: string;
  73851. /** @hidden */
  73852. protected _adaptWidthToChildren: boolean;
  73853. /** @hidden */
  73854. protected _adaptHeightToChildren: boolean;
  73855. /**
  73856. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  73857. */
  73858. logLayoutCycleErrors: boolean;
  73859. /**
  73860. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  73861. */
  73862. maxLayoutCycle: number;
  73863. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  73864. get adaptHeightToChildren(): boolean;
  73865. set adaptHeightToChildren(value: boolean);
  73866. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  73867. get adaptWidthToChildren(): boolean;
  73868. set adaptWidthToChildren(value: boolean);
  73869. /** Gets or sets background color */
  73870. get background(): string;
  73871. set background(value: string);
  73872. /** Gets the list of children */
  73873. get children(): Control[];
  73874. /**
  73875. * Creates a new Container
  73876. * @param name defines the name of the container
  73877. */
  73878. constructor(name?: string | undefined);
  73879. protected _getTypeName(): string;
  73880. _flagDescendantsAsMatrixDirty(): void;
  73881. /**
  73882. * Gets a child using its name
  73883. * @param name defines the child name to look for
  73884. * @returns the child control if found
  73885. */
  73886. getChildByName(name: string): BABYLON.Nullable<Control>;
  73887. /**
  73888. * Gets a child using its type and its name
  73889. * @param name defines the child name to look for
  73890. * @param type defines the child type to look for
  73891. * @returns the child control if found
  73892. */
  73893. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  73894. /**
  73895. * Search for a specific control in children
  73896. * @param control defines the control to look for
  73897. * @returns true if the control is in child list
  73898. */
  73899. containsControl(control: Control): boolean;
  73900. /**
  73901. * Adds a new control to the current container
  73902. * @param control defines the control to add
  73903. * @returns the current container
  73904. */
  73905. addControl(control: BABYLON.Nullable<Control>): Container;
  73906. /**
  73907. * Removes all controls from the current container
  73908. * @returns the current container
  73909. */
  73910. clearControls(): Container;
  73911. /**
  73912. * Removes a control from the current container
  73913. * @param control defines the control to remove
  73914. * @returns the current container
  73915. */
  73916. removeControl(control: Control): Container;
  73917. /** @hidden */
  73918. _reOrderControl(control: Control): void;
  73919. /** @hidden */
  73920. _offsetLeft(offset: number): void;
  73921. /** @hidden */
  73922. _offsetTop(offset: number): void;
  73923. /** @hidden */
  73924. _markAllAsDirty(): void;
  73925. /** @hidden */
  73926. protected _localDraw(context: CanvasRenderingContext2D): void;
  73927. /** @hidden */
  73928. _link(host: AdvancedDynamicTexture): void;
  73929. /** @hidden */
  73930. protected _beforeLayout(): void;
  73931. /** @hidden */
  73932. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73933. /** @hidden */
  73934. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73935. protected _postMeasure(): void;
  73936. /** @hidden */
  73937. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73938. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73939. /** @hidden */
  73940. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73941. /** @hidden */
  73942. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73943. /** Releases associated resources */
  73944. dispose(): void;
  73945. }
  73946. }
  73947. declare module BABYLON.GUI {
  73948. /** Class used to create rectangle container */
  73949. export class Rectangle extends Container {
  73950. name?: string | undefined;
  73951. private _thickness;
  73952. private _cornerRadius;
  73953. /** Gets or sets border thickness */
  73954. get thickness(): number;
  73955. set thickness(value: number);
  73956. /** Gets or sets the corner radius angle */
  73957. get cornerRadius(): number;
  73958. set cornerRadius(value: number);
  73959. /**
  73960. * Creates a new Rectangle
  73961. * @param name defines the control name
  73962. */
  73963. constructor(name?: string | undefined);
  73964. protected _getTypeName(): string;
  73965. protected _localDraw(context: CanvasRenderingContext2D): void;
  73966. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73967. private _drawRoundedRect;
  73968. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73969. }
  73970. }
  73971. declare module BABYLON.GUI {
  73972. /**
  73973. * Enum that determines the text-wrapping mode to use.
  73974. */
  73975. export enum TextWrapping {
  73976. /**
  73977. * Clip the text when it's larger than Control.width; this is the default mode.
  73978. */
  73979. Clip = 0,
  73980. /**
  73981. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  73982. */
  73983. WordWrap = 1,
  73984. /**
  73985. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  73986. */
  73987. Ellipsis = 2
  73988. }
  73989. /**
  73990. * Class used to create text block control
  73991. */
  73992. export class TextBlock extends Control {
  73993. /**
  73994. * Defines the name of the control
  73995. */
  73996. name?: string | undefined;
  73997. private _text;
  73998. private _textWrapping;
  73999. private _textHorizontalAlignment;
  74000. private _textVerticalAlignment;
  74001. private _lines;
  74002. private _resizeToFit;
  74003. private _lineSpacing;
  74004. private _outlineWidth;
  74005. private _outlineColor;
  74006. /**
  74007. * An event triggered after the text is changed
  74008. */
  74009. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74010. /**
  74011. * An event triggered after the text was broken up into lines
  74012. */
  74013. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74014. /**
  74015. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74016. */
  74017. get lines(): any[];
  74018. /**
  74019. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74020. */
  74021. get resizeToFit(): boolean;
  74022. /**
  74023. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74024. */
  74025. set resizeToFit(value: boolean);
  74026. /**
  74027. * Gets or sets a boolean indicating if text must be wrapped
  74028. */
  74029. get textWrapping(): TextWrapping | boolean;
  74030. /**
  74031. * Gets or sets a boolean indicating if text must be wrapped
  74032. */
  74033. set textWrapping(value: TextWrapping | boolean);
  74034. /**
  74035. * Gets or sets text to display
  74036. */
  74037. get text(): string;
  74038. /**
  74039. * Gets or sets text to display
  74040. */
  74041. set text(value: string);
  74042. /**
  74043. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74044. */
  74045. get textHorizontalAlignment(): number;
  74046. /**
  74047. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74048. */
  74049. set textHorizontalAlignment(value: number);
  74050. /**
  74051. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74052. */
  74053. get textVerticalAlignment(): number;
  74054. /**
  74055. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74056. */
  74057. set textVerticalAlignment(value: number);
  74058. /**
  74059. * Gets or sets line spacing value
  74060. */
  74061. set lineSpacing(value: string | number);
  74062. /**
  74063. * Gets or sets line spacing value
  74064. */
  74065. get lineSpacing(): string | number;
  74066. /**
  74067. * Gets or sets outlineWidth of the text to display
  74068. */
  74069. get outlineWidth(): number;
  74070. /**
  74071. * Gets or sets outlineWidth of the text to display
  74072. */
  74073. set outlineWidth(value: number);
  74074. /**
  74075. * Gets or sets outlineColor of the text to display
  74076. */
  74077. get outlineColor(): string;
  74078. /**
  74079. * Gets or sets outlineColor of the text to display
  74080. */
  74081. set outlineColor(value: string);
  74082. /**
  74083. * Creates a new TextBlock object
  74084. * @param name defines the name of the control
  74085. * @param text defines the text to display (emptry string by default)
  74086. */
  74087. constructor(
  74088. /**
  74089. * Defines the name of the control
  74090. */
  74091. name?: string | undefined, text?: string);
  74092. protected _getTypeName(): string;
  74093. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74094. private _drawText;
  74095. /** @hidden */
  74096. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74097. protected _applyStates(context: CanvasRenderingContext2D): void;
  74098. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74099. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74100. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74101. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74102. protected _renderLines(context: CanvasRenderingContext2D): void;
  74103. /**
  74104. * Given a width constraint applied on the text block, find the expected height
  74105. * @returns expected height
  74106. */
  74107. computeExpectedHeight(): number;
  74108. dispose(): void;
  74109. }
  74110. }
  74111. declare module BABYLON.GUI {
  74112. /**
  74113. * Class used to create 2D images
  74114. */
  74115. export class Image extends Control {
  74116. name?: string | undefined;
  74117. private _workingCanvas;
  74118. private _domImage;
  74119. private _imageWidth;
  74120. private _imageHeight;
  74121. private _loaded;
  74122. private _stretch;
  74123. private _source;
  74124. private _autoScale;
  74125. private _sourceLeft;
  74126. private _sourceTop;
  74127. private _sourceWidth;
  74128. private _sourceHeight;
  74129. private _svgAttributesComputationCompleted;
  74130. private _isSVG;
  74131. private _cellWidth;
  74132. private _cellHeight;
  74133. private _cellId;
  74134. private _populateNinePatchSlicesFromImage;
  74135. private _sliceLeft;
  74136. private _sliceRight;
  74137. private _sliceTop;
  74138. private _sliceBottom;
  74139. private _detectPointerOnOpaqueOnly;
  74140. /**
  74141. * BABYLON.Observable notified when the content is loaded
  74142. */
  74143. onImageLoadedObservable: BABYLON.Observable<Image>;
  74144. /**
  74145. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74146. */
  74147. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74148. /**
  74149. * Gets a boolean indicating that the content is loaded
  74150. */
  74151. get isLoaded(): boolean;
  74152. /**
  74153. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74154. */
  74155. get populateNinePatchSlicesFromImage(): boolean;
  74156. set populateNinePatchSlicesFromImage(value: boolean);
  74157. /**
  74158. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  74159. * Beware using this as this will comsume more memory as the image has to be stored twice
  74160. */
  74161. get detectPointerOnOpaqueOnly(): boolean;
  74162. set detectPointerOnOpaqueOnly(value: boolean);
  74163. /**
  74164. * Gets or sets the left value for slicing (9-patch)
  74165. */
  74166. get sliceLeft(): number;
  74167. set sliceLeft(value: number);
  74168. /**
  74169. * Gets or sets the right value for slicing (9-patch)
  74170. */
  74171. get sliceRight(): number;
  74172. set sliceRight(value: number);
  74173. /**
  74174. * Gets or sets the top value for slicing (9-patch)
  74175. */
  74176. get sliceTop(): number;
  74177. set sliceTop(value: number);
  74178. /**
  74179. * Gets or sets the bottom value for slicing (9-patch)
  74180. */
  74181. get sliceBottom(): number;
  74182. set sliceBottom(value: number);
  74183. /**
  74184. * Gets or sets the left coordinate in the source image
  74185. */
  74186. get sourceLeft(): number;
  74187. set sourceLeft(value: number);
  74188. /**
  74189. * Gets or sets the top coordinate in the source image
  74190. */
  74191. get sourceTop(): number;
  74192. set sourceTop(value: number);
  74193. /**
  74194. * Gets or sets the width to capture in the source image
  74195. */
  74196. get sourceWidth(): number;
  74197. set sourceWidth(value: number);
  74198. /**
  74199. * Gets or sets the height to capture in the source image
  74200. */
  74201. get sourceHeight(): number;
  74202. set sourceHeight(value: number);
  74203. /** Indicates if the format of the image is SVG */
  74204. get isSVG(): boolean;
  74205. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74206. get svgAttributesComputationCompleted(): boolean;
  74207. /**
  74208. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74209. * @see http://doc.babylonjs.com/how_to/gui#image
  74210. */
  74211. get autoScale(): boolean;
  74212. set autoScale(value: boolean);
  74213. /** Gets or sets the streching mode used by the image */
  74214. get stretch(): number;
  74215. set stretch(value: number);
  74216. /** @hidden */
  74217. _rotate90(n: number, preserveProperties?: boolean): Image;
  74218. private _handleRotationForSVGImage;
  74219. private _rotate90SourceProperties;
  74220. /**
  74221. * Gets or sets the internal DOM image used to render the control
  74222. */
  74223. set domImage(value: HTMLImageElement);
  74224. get domImage(): HTMLImageElement;
  74225. private _onImageLoaded;
  74226. private _extractNinePatchSliceDataFromImage;
  74227. /**
  74228. * Gets or sets image source url
  74229. */
  74230. set source(value: BABYLON.Nullable<string>);
  74231. /**
  74232. * Checks for svg document with icon id present
  74233. */
  74234. private _svgCheck;
  74235. /**
  74236. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74237. * given external svg file and icon id
  74238. */
  74239. private _getSVGAttribs;
  74240. /**
  74241. * Gets or sets the cell width to use when animation sheet is enabled
  74242. * @see http://doc.babylonjs.com/how_to/gui#image
  74243. */
  74244. get cellWidth(): number;
  74245. set cellWidth(value: number);
  74246. /**
  74247. * Gets or sets the cell height to use when animation sheet is enabled
  74248. * @see http://doc.babylonjs.com/how_to/gui#image
  74249. */
  74250. get cellHeight(): number;
  74251. set cellHeight(value: number);
  74252. /**
  74253. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74254. * @see http://doc.babylonjs.com/how_to/gui#image
  74255. */
  74256. get cellId(): number;
  74257. set cellId(value: number);
  74258. /**
  74259. * Creates a new Image
  74260. * @param name defines the control name
  74261. * @param url defines the image url
  74262. */
  74263. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74264. /**
  74265. * Tests if a given coordinates belong to the current control
  74266. * @param x defines x coordinate to test
  74267. * @param y defines y coordinate to test
  74268. * @returns true if the coordinates are inside the control
  74269. */
  74270. contains(x: number, y: number): boolean;
  74271. protected _getTypeName(): string;
  74272. /** Force the control to synchronize with its content */
  74273. synchronizeSizeWithContent(): void;
  74274. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74275. private _prepareWorkingCanvasForOpaqueDetection;
  74276. private _drawImage;
  74277. _draw(context: CanvasRenderingContext2D): void;
  74278. private _renderCornerPatch;
  74279. private _renderNinePatch;
  74280. dispose(): void;
  74281. /** STRETCH_NONE */
  74282. static readonly STRETCH_NONE: number;
  74283. /** STRETCH_FILL */
  74284. static readonly STRETCH_FILL: number;
  74285. /** STRETCH_UNIFORM */
  74286. static readonly STRETCH_UNIFORM: number;
  74287. /** STRETCH_EXTEND */
  74288. static readonly STRETCH_EXTEND: number;
  74289. /** NINE_PATCH */
  74290. static readonly STRETCH_NINE_PATCH: number;
  74291. }
  74292. }
  74293. declare module BABYLON.GUI {
  74294. /**
  74295. * Class used to create 2D buttons
  74296. */
  74297. export class Button extends Rectangle {
  74298. name?: string | undefined;
  74299. /**
  74300. * Function called to generate a pointer enter animation
  74301. */
  74302. pointerEnterAnimation: () => void;
  74303. /**
  74304. * Function called to generate a pointer out animation
  74305. */
  74306. pointerOutAnimation: () => void;
  74307. /**
  74308. * Function called to generate a pointer down animation
  74309. */
  74310. pointerDownAnimation: () => void;
  74311. /**
  74312. * Function called to generate a pointer up animation
  74313. */
  74314. pointerUpAnimation: () => void;
  74315. /**
  74316. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74317. */
  74318. delegatePickingToChildren: boolean;
  74319. private _image;
  74320. /**
  74321. * Returns the image part of the button (if any)
  74322. */
  74323. get image(): BABYLON.Nullable<Image>;
  74324. private _textBlock;
  74325. /**
  74326. * Returns the image part of the button (if any)
  74327. */
  74328. get textBlock(): BABYLON.Nullable<TextBlock>;
  74329. /**
  74330. * Creates a new Button
  74331. * @param name defines the name of the button
  74332. */
  74333. constructor(name?: string | undefined);
  74334. protected _getTypeName(): string;
  74335. /** @hidden */
  74336. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74337. /** @hidden */
  74338. _onPointerEnter(target: Control): boolean;
  74339. /** @hidden */
  74340. _onPointerOut(target: Control, force?: boolean): void;
  74341. /** @hidden */
  74342. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74343. /** @hidden */
  74344. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74345. /**
  74346. * Creates a new button made with an image and a text
  74347. * @param name defines the name of the button
  74348. * @param text defines the text of the button
  74349. * @param imageUrl defines the url of the image
  74350. * @returns a new Button
  74351. */
  74352. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74353. /**
  74354. * Creates a new button made with an image
  74355. * @param name defines the name of the button
  74356. * @param imageUrl defines the url of the image
  74357. * @returns a new Button
  74358. */
  74359. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74360. /**
  74361. * Creates a new button made with a text
  74362. * @param name defines the name of the button
  74363. * @param text defines the text of the button
  74364. * @returns a new Button
  74365. */
  74366. static CreateSimpleButton(name: string, text: string): Button;
  74367. /**
  74368. * Creates a new button made with an image and a centered text
  74369. * @param name defines the name of the button
  74370. * @param text defines the text of the button
  74371. * @param imageUrl defines the url of the image
  74372. * @returns a new Button
  74373. */
  74374. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74375. }
  74376. }
  74377. declare module BABYLON.GUI {
  74378. /**
  74379. * Class used to create a 2D stack panel container
  74380. */
  74381. export class StackPanel extends Container {
  74382. name?: string | undefined;
  74383. private _isVertical;
  74384. private _manualWidth;
  74385. private _manualHeight;
  74386. private _doNotTrackManualChanges;
  74387. /**
  74388. * Gets or sets a boolean indicating that layou warnings should be ignored
  74389. */
  74390. ignoreLayoutWarnings: boolean;
  74391. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74392. get isVertical(): boolean;
  74393. set isVertical(value: boolean);
  74394. /**
  74395. * Gets or sets panel width.
  74396. * This value should not be set when in horizontal mode as it will be computed automatically
  74397. */
  74398. set width(value: string | number);
  74399. get width(): string | number;
  74400. /**
  74401. * Gets or sets panel height.
  74402. * This value should not be set when in vertical mode as it will be computed automatically
  74403. */
  74404. set height(value: string | number);
  74405. get height(): string | number;
  74406. /**
  74407. * Creates a new StackPanel
  74408. * @param name defines control name
  74409. */
  74410. constructor(name?: string | undefined);
  74411. protected _getTypeName(): string;
  74412. /** @hidden */
  74413. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74414. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74415. protected _postMeasure(): void;
  74416. }
  74417. }
  74418. declare module BABYLON.GUI {
  74419. /**
  74420. * Class used to represent a 2D checkbox
  74421. */
  74422. export class Checkbox extends Control {
  74423. name?: string | undefined;
  74424. private _isChecked;
  74425. private _background;
  74426. private _checkSizeRatio;
  74427. private _thickness;
  74428. /** Gets or sets border thickness */
  74429. get thickness(): number;
  74430. set thickness(value: number);
  74431. /**
  74432. * BABYLON.Observable raised when isChecked property changes
  74433. */
  74434. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74435. /** Gets or sets a value indicating the ratio between overall size and check size */
  74436. get checkSizeRatio(): number;
  74437. set checkSizeRatio(value: number);
  74438. /** Gets or sets background color */
  74439. get background(): string;
  74440. set background(value: string);
  74441. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74442. get isChecked(): boolean;
  74443. set isChecked(value: boolean);
  74444. /**
  74445. * Creates a new CheckBox
  74446. * @param name defines the control name
  74447. */
  74448. constructor(name?: string | undefined);
  74449. protected _getTypeName(): string;
  74450. /** @hidden */
  74451. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74452. /** @hidden */
  74453. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74454. /**
  74455. * Utility function to easily create a checkbox with a header
  74456. * @param title defines the label to use for the header
  74457. * @param onValueChanged defines the callback to call when value changes
  74458. * @returns a StackPanel containing the checkbox and a textBlock
  74459. */
  74460. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74461. }
  74462. }
  74463. declare module BABYLON.GUI {
  74464. /**
  74465. * Class used to store key control properties
  74466. */
  74467. export class KeyPropertySet {
  74468. /** Width */
  74469. width?: string;
  74470. /** Height */
  74471. height?: string;
  74472. /** Left padding */
  74473. paddingLeft?: string;
  74474. /** Right padding */
  74475. paddingRight?: string;
  74476. /** Top padding */
  74477. paddingTop?: string;
  74478. /** Bottom padding */
  74479. paddingBottom?: string;
  74480. /** Foreground color */
  74481. color?: string;
  74482. /** Background color */
  74483. background?: string;
  74484. }
  74485. /**
  74486. * Class used to create virtual keyboard
  74487. */
  74488. export class VirtualKeyboard extends StackPanel {
  74489. /** BABYLON.Observable raised when a key is pressed */
  74490. onKeyPressObservable: BABYLON.Observable<string>;
  74491. /** Gets or sets default key button width */
  74492. defaultButtonWidth: string;
  74493. /** Gets or sets default key button height */
  74494. defaultButtonHeight: string;
  74495. /** Gets or sets default key button left padding */
  74496. defaultButtonPaddingLeft: string;
  74497. /** Gets or sets default key button right padding */
  74498. defaultButtonPaddingRight: string;
  74499. /** Gets or sets default key button top padding */
  74500. defaultButtonPaddingTop: string;
  74501. /** Gets or sets default key button bottom padding */
  74502. defaultButtonPaddingBottom: string;
  74503. /** Gets or sets default key button foreground color */
  74504. defaultButtonColor: string;
  74505. /** Gets or sets default key button background color */
  74506. defaultButtonBackground: string;
  74507. /** Gets or sets shift button foreground color */
  74508. shiftButtonColor: string;
  74509. /** Gets or sets shift button thickness*/
  74510. selectedShiftThickness: number;
  74511. /** Gets shift key state */
  74512. shiftState: number;
  74513. protected _getTypeName(): string;
  74514. private _createKey;
  74515. /**
  74516. * Adds a new row of keys
  74517. * @param keys defines the list of keys to add
  74518. * @param propertySets defines the associated property sets
  74519. */
  74520. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  74521. /**
  74522. * Set the shift key to a specific state
  74523. * @param shiftState defines the new shift state
  74524. */
  74525. applyShiftState(shiftState: number): void;
  74526. private _currentlyConnectedInputText;
  74527. private _connectedInputTexts;
  74528. private _onKeyPressObserver;
  74529. /** Gets the input text control currently attached to the keyboard */
  74530. get connectedInputText(): BABYLON.Nullable<InputText>;
  74531. /**
  74532. * Connects the keyboard with an input text control
  74533. *
  74534. * @param input defines the target control
  74535. */
  74536. connect(input: InputText): void;
  74537. /**
  74538. * Disconnects the keyboard from connected InputText controls
  74539. *
  74540. * @param input optionally defines a target control, otherwise all are disconnected
  74541. */
  74542. disconnect(input?: InputText): void;
  74543. private _removeConnectedInputObservables;
  74544. /**
  74545. * Release all resources
  74546. */
  74547. dispose(): void;
  74548. /**
  74549. * Creates a new keyboard using a default layout
  74550. *
  74551. * @param name defines control name
  74552. * @returns a new VirtualKeyboard
  74553. */
  74554. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  74555. }
  74556. }
  74557. declare module BABYLON.GUI {
  74558. /**
  74559. * Class used to create input text control
  74560. */
  74561. export class InputText extends Control implements IFocusableControl {
  74562. name?: string | undefined;
  74563. private _text;
  74564. private _placeholderText;
  74565. private _background;
  74566. private _focusedBackground;
  74567. private _focusedColor;
  74568. private _placeholderColor;
  74569. private _thickness;
  74570. private _margin;
  74571. private _autoStretchWidth;
  74572. private _maxWidth;
  74573. private _isFocused;
  74574. private _blinkTimeout;
  74575. private _blinkIsEven;
  74576. private _cursorOffset;
  74577. private _scrollLeft;
  74578. private _textWidth;
  74579. private _clickedCoordinate;
  74580. private _deadKey;
  74581. private _addKey;
  74582. private _currentKey;
  74583. private _isTextHighlightOn;
  74584. private _textHighlightColor;
  74585. private _highligherOpacity;
  74586. private _highlightedText;
  74587. private _startHighlightIndex;
  74588. private _endHighlightIndex;
  74589. private _cursorIndex;
  74590. private _onFocusSelectAll;
  74591. private _isPointerDown;
  74592. private _onClipboardObserver;
  74593. private _onPointerDblTapObserver;
  74594. /** @hidden */
  74595. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  74596. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  74597. promptMessage: string;
  74598. /** Force disable prompt on mobile device */
  74599. disableMobilePrompt: boolean;
  74600. /** BABYLON.Observable raised when the text changes */
  74601. onTextChangedObservable: BABYLON.Observable<InputText>;
  74602. /** BABYLON.Observable raised just before an entered character is to be added */
  74603. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  74604. /** BABYLON.Observable raised when the control gets the focus */
  74605. onFocusObservable: BABYLON.Observable<InputText>;
  74606. /** BABYLON.Observable raised when the control loses the focus */
  74607. onBlurObservable: BABYLON.Observable<InputText>;
  74608. /**Observable raised when the text is highlighted */
  74609. onTextHighlightObservable: BABYLON.Observable<InputText>;
  74610. /**Observable raised when copy event is triggered */
  74611. onTextCopyObservable: BABYLON.Observable<InputText>;
  74612. /** BABYLON.Observable raised when cut event is triggered */
  74613. onTextCutObservable: BABYLON.Observable<InputText>;
  74614. /** BABYLON.Observable raised when paste event is triggered */
  74615. onTextPasteObservable: BABYLON.Observable<InputText>;
  74616. /** BABYLON.Observable raised when a key event was processed */
  74617. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  74618. /** Gets or sets the maximum width allowed by the control */
  74619. get maxWidth(): string | number;
  74620. /** Gets the maximum width allowed by the control in pixels */
  74621. get maxWidthInPixels(): number;
  74622. set maxWidth(value: string | number);
  74623. /** Gets or sets the text highlighter transparency; default: 0.4 */
  74624. get highligherOpacity(): number;
  74625. set highligherOpacity(value: number);
  74626. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  74627. get onFocusSelectAll(): boolean;
  74628. set onFocusSelectAll(value: boolean);
  74629. /** Gets or sets the text hightlight color */
  74630. get textHighlightColor(): string;
  74631. set textHighlightColor(value: string);
  74632. /** Gets or sets control margin */
  74633. get margin(): string;
  74634. /** Gets control margin in pixels */
  74635. get marginInPixels(): number;
  74636. set margin(value: string);
  74637. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  74638. get autoStretchWidth(): boolean;
  74639. set autoStretchWidth(value: boolean);
  74640. /** Gets or sets border thickness */
  74641. get thickness(): number;
  74642. set thickness(value: number);
  74643. /** Gets or sets the background color when focused */
  74644. get focusedBackground(): string;
  74645. set focusedBackground(value: string);
  74646. /** Gets or sets the background color when focused */
  74647. get focusedColor(): string;
  74648. set focusedColor(value: string);
  74649. /** Gets or sets the background color */
  74650. get background(): string;
  74651. set background(value: string);
  74652. /** Gets or sets the placeholder color */
  74653. get placeholderColor(): string;
  74654. set placeholderColor(value: string);
  74655. /** Gets or sets the text displayed when the control is empty */
  74656. get placeholderText(): string;
  74657. set placeholderText(value: string);
  74658. /** Gets or sets the dead key flag */
  74659. get deadKey(): boolean;
  74660. set deadKey(flag: boolean);
  74661. /** Gets or sets the highlight text */
  74662. get highlightedText(): string;
  74663. set highlightedText(text: string);
  74664. /** Gets or sets if the current key should be added */
  74665. get addKey(): boolean;
  74666. set addKey(flag: boolean);
  74667. /** Gets or sets the value of the current key being entered */
  74668. get currentKey(): string;
  74669. set currentKey(key: string);
  74670. /** Gets or sets the text displayed in the control */
  74671. get text(): string;
  74672. set text(value: string);
  74673. /** Gets or sets control width */
  74674. get width(): string | number;
  74675. set width(value: string | number);
  74676. /**
  74677. * Creates a new InputText
  74678. * @param name defines the control name
  74679. * @param text defines the text of the control
  74680. */
  74681. constructor(name?: string | undefined, text?: string);
  74682. /** @hidden */
  74683. onBlur(): void;
  74684. /** @hidden */
  74685. onFocus(): void;
  74686. protected _getTypeName(): string;
  74687. /**
  74688. * Function called to get the list of controls that should not steal the focus from this control
  74689. * @returns an array of controls
  74690. */
  74691. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74692. /** @hidden */
  74693. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  74694. /** @hidden */
  74695. private _updateValueFromCursorIndex;
  74696. /** @hidden */
  74697. private _processDblClick;
  74698. /** @hidden */
  74699. private _selectAllText;
  74700. /**
  74701. * Handles the keyboard event
  74702. * @param evt Defines the KeyboardEvent
  74703. */
  74704. processKeyboard(evt: KeyboardEvent): void;
  74705. /** @hidden */
  74706. private _onCopyText;
  74707. /** @hidden */
  74708. private _onCutText;
  74709. /** @hidden */
  74710. private _onPasteText;
  74711. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74712. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74713. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74714. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74715. protected _beforeRenderText(text: string): string;
  74716. dispose(): void;
  74717. }
  74718. }
  74719. declare module BABYLON.GUI {
  74720. /**
  74721. * Class used to create a 2D grid container
  74722. */
  74723. export class Grid extends Container {
  74724. name?: string | undefined;
  74725. private _rowDefinitions;
  74726. private _columnDefinitions;
  74727. private _cells;
  74728. private _childControls;
  74729. /**
  74730. * Gets the number of columns
  74731. */
  74732. get columnCount(): number;
  74733. /**
  74734. * Gets the number of rows
  74735. */
  74736. get rowCount(): number;
  74737. /** Gets the list of children */
  74738. get children(): Control[];
  74739. /** Gets the list of cells (e.g. the containers) */
  74740. get cells(): {
  74741. [key: string]: Container;
  74742. };
  74743. /**
  74744. * Gets the definition of a specific row
  74745. * @param index defines the index of the row
  74746. * @returns the row definition
  74747. */
  74748. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74749. /**
  74750. * Gets the definition of a specific column
  74751. * @param index defines the index of the column
  74752. * @returns the column definition
  74753. */
  74754. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74755. /**
  74756. * Adds a new row to the grid
  74757. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74758. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  74759. * @returns the current grid
  74760. */
  74761. addRowDefinition(height: number, isPixel?: boolean): Grid;
  74762. /**
  74763. * Adds a new column to the grid
  74764. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74765. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74766. * @returns the current grid
  74767. */
  74768. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  74769. /**
  74770. * Update a row definition
  74771. * @param index defines the index of the row to update
  74772. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74773. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  74774. * @returns the current grid
  74775. */
  74776. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  74777. /**
  74778. * Update a column definition
  74779. * @param index defines the index of the column to update
  74780. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74781. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74782. * @returns the current grid
  74783. */
  74784. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  74785. /**
  74786. * Gets the list of children stored in a specific cell
  74787. * @param row defines the row to check
  74788. * @param column defines the column to check
  74789. * @returns the list of controls
  74790. */
  74791. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  74792. /**
  74793. * Gets a string representing the child cell info (row x column)
  74794. * @param child defines the control to get info from
  74795. * @returns a string containing the child cell info (row x column)
  74796. */
  74797. getChildCellInfo(child: Control): string;
  74798. private _removeCell;
  74799. private _offsetCell;
  74800. /**
  74801. * Remove a column definition at specified index
  74802. * @param index defines the index of the column to remove
  74803. * @returns the current grid
  74804. */
  74805. removeColumnDefinition(index: number): Grid;
  74806. /**
  74807. * Remove a row definition at specified index
  74808. * @param index defines the index of the row to remove
  74809. * @returns the current grid
  74810. */
  74811. removeRowDefinition(index: number): Grid;
  74812. /**
  74813. * Adds a new control to the current grid
  74814. * @param control defines the control to add
  74815. * @param row defines the row where to add the control (0 by default)
  74816. * @param column defines the column where to add the control (0 by default)
  74817. * @returns the current grid
  74818. */
  74819. addControl(control: Control, row?: number, column?: number): Grid;
  74820. /**
  74821. * Removes a control from the current container
  74822. * @param control defines the control to remove
  74823. * @returns the current container
  74824. */
  74825. removeControl(control: Control): Container;
  74826. /**
  74827. * Creates a new Grid
  74828. * @param name defines control name
  74829. */
  74830. constructor(name?: string | undefined);
  74831. protected _getTypeName(): string;
  74832. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  74833. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74834. _flagDescendantsAsMatrixDirty(): void;
  74835. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74836. /** Releases associated resources */
  74837. dispose(): void;
  74838. }
  74839. }
  74840. declare module BABYLON.GUI {
  74841. /** Class used to create color pickers */
  74842. export class ColorPicker extends Control {
  74843. name?: string | undefined;
  74844. private static _Epsilon;
  74845. private _colorWheelCanvas;
  74846. private _value;
  74847. private _tmpColor;
  74848. private _pointerStartedOnSquare;
  74849. private _pointerStartedOnWheel;
  74850. private _squareLeft;
  74851. private _squareTop;
  74852. private _squareSize;
  74853. private _h;
  74854. private _s;
  74855. private _v;
  74856. private _lastPointerDownID;
  74857. /**
  74858. * BABYLON.Observable raised when the value changes
  74859. */
  74860. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  74861. /** Gets or sets the color of the color picker */
  74862. get value(): BABYLON.Color3;
  74863. set value(value: BABYLON.Color3);
  74864. /**
  74865. * Gets or sets control width
  74866. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74867. */
  74868. get width(): string | number;
  74869. set width(value: string | number);
  74870. /**
  74871. * Gets or sets control height
  74872. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74873. */
  74874. get height(): string | number;
  74875. /** Gets or sets control height */
  74876. set height(value: string | number);
  74877. /** Gets or sets control size */
  74878. get size(): string | number;
  74879. set size(value: string | number);
  74880. /**
  74881. * Creates a new ColorPicker
  74882. * @param name defines the control name
  74883. */
  74884. constructor(name?: string | undefined);
  74885. protected _getTypeName(): string;
  74886. /** @hidden */
  74887. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74888. private _updateSquareProps;
  74889. private _drawGradientSquare;
  74890. private _drawCircle;
  74891. private _createColorWheelCanvas;
  74892. /** @hidden */
  74893. _draw(context: CanvasRenderingContext2D): void;
  74894. private _pointerIsDown;
  74895. private _updateValueFromPointer;
  74896. private _isPointOnSquare;
  74897. private _isPointOnWheel;
  74898. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74899. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74900. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74901. /**
  74902. * This function expands the color picker by creating a color picker dialog with manual
  74903. * color value input and the ability to save colors into an array to be used later in
  74904. * subsequent launches of the dialogue.
  74905. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  74906. * @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.
  74907. * @returns picked color as a hex string and the saved colors array as hex strings.
  74908. */
  74909. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  74910. pickerWidth?: string;
  74911. pickerHeight?: string;
  74912. headerHeight?: string;
  74913. lastColor?: string;
  74914. swatchLimit?: number;
  74915. numSwatchesPerLine?: number;
  74916. savedColors?: Array<string>;
  74917. }): Promise<{
  74918. savedColors?: string[];
  74919. pickedColor: string;
  74920. }>;
  74921. }
  74922. }
  74923. declare module BABYLON.GUI {
  74924. /** Class used to create 2D ellipse containers */
  74925. export class Ellipse extends Container {
  74926. name?: string | undefined;
  74927. private _thickness;
  74928. /** Gets or sets border thickness */
  74929. get thickness(): number;
  74930. set thickness(value: number);
  74931. /**
  74932. * Creates a new Ellipse
  74933. * @param name defines the control name
  74934. */
  74935. constructor(name?: string | undefined);
  74936. protected _getTypeName(): string;
  74937. protected _localDraw(context: CanvasRenderingContext2D): void;
  74938. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74939. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74940. }
  74941. }
  74942. declare module BABYLON.GUI {
  74943. /**
  74944. * Class used to create a password control
  74945. */
  74946. export class InputPassword extends InputText {
  74947. protected _beforeRenderText(text: string): string;
  74948. }
  74949. }
  74950. declare module BABYLON.GUI {
  74951. /** Class used to render 2D lines */
  74952. export class Line extends Control {
  74953. name?: string | undefined;
  74954. private _lineWidth;
  74955. private _x1;
  74956. private _y1;
  74957. private _x2;
  74958. private _y2;
  74959. private _dash;
  74960. private _connectedControl;
  74961. private _connectedControlDirtyObserver;
  74962. /** Gets or sets the dash pattern */
  74963. get dash(): Array<number>;
  74964. set dash(value: Array<number>);
  74965. /** Gets or sets the control connected with the line end */
  74966. get connectedControl(): Control;
  74967. set connectedControl(value: Control);
  74968. /** Gets or sets start coordinates on X axis */
  74969. get x1(): string | number;
  74970. set x1(value: string | number);
  74971. /** Gets or sets start coordinates on Y axis */
  74972. get y1(): string | number;
  74973. set y1(value: string | number);
  74974. /** Gets or sets end coordinates on X axis */
  74975. get x2(): string | number;
  74976. set x2(value: string | number);
  74977. /** Gets or sets end coordinates on Y axis */
  74978. get y2(): string | number;
  74979. set y2(value: string | number);
  74980. /** Gets or sets line width */
  74981. get lineWidth(): number;
  74982. set lineWidth(value: number);
  74983. /** Gets or sets horizontal alignment */
  74984. set horizontalAlignment(value: number);
  74985. /** Gets or sets vertical alignment */
  74986. set verticalAlignment(value: number);
  74987. private get _effectiveX2();
  74988. private get _effectiveY2();
  74989. /**
  74990. * Creates a new Line
  74991. * @param name defines the control name
  74992. */
  74993. constructor(name?: string | undefined);
  74994. protected _getTypeName(): string;
  74995. _draw(context: CanvasRenderingContext2D): void;
  74996. _measure(): void;
  74997. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74998. /**
  74999. * Move one end of the line given 3D cartesian coordinates.
  75000. * @param position Targeted world position
  75001. * @param scene BABYLON.Scene
  75002. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75003. */
  75004. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75005. /**
  75006. * Move one end of the line to a position in screen absolute space.
  75007. * @param projectedPosition Position in screen absolute space (X, Y)
  75008. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75009. */
  75010. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75011. }
  75012. }
  75013. declare module BABYLON.GUI {
  75014. /**
  75015. * Class used to store a point for a MultiLine object.
  75016. * The point can be pure 2D coordinates, a mesh or a control
  75017. */
  75018. export class MultiLinePoint {
  75019. private _multiLine;
  75020. private _x;
  75021. private _y;
  75022. private _control;
  75023. private _mesh;
  75024. private _controlObserver;
  75025. private _meshObserver;
  75026. /** @hidden */
  75027. _point: BABYLON.Vector2;
  75028. /**
  75029. * Creates a new MultiLinePoint
  75030. * @param multiLine defines the source MultiLine object
  75031. */
  75032. constructor(multiLine: MultiLine);
  75033. /** Gets or sets x coordinate */
  75034. get x(): string | number;
  75035. set x(value: string | number);
  75036. /** Gets or sets y coordinate */
  75037. get y(): string | number;
  75038. set y(value: string | number);
  75039. /** Gets or sets the control associated with this point */
  75040. get control(): BABYLON.Nullable<Control>;
  75041. set control(value: BABYLON.Nullable<Control>);
  75042. /** Gets or sets the mesh associated with this point */
  75043. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75044. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75045. /** Resets links */
  75046. resetLinks(): void;
  75047. /**
  75048. * Gets a translation vector
  75049. * @returns the translation vector
  75050. */
  75051. translate(): BABYLON.Vector2;
  75052. private _translatePoint;
  75053. /** Release associated resources */
  75054. dispose(): void;
  75055. }
  75056. }
  75057. declare module BABYLON.GUI {
  75058. /**
  75059. * Class used to create multi line control
  75060. */
  75061. export class MultiLine extends Control {
  75062. name?: string | undefined;
  75063. private _lineWidth;
  75064. private _dash;
  75065. private _points;
  75066. private _minX;
  75067. private _minY;
  75068. private _maxX;
  75069. private _maxY;
  75070. /**
  75071. * Creates a new MultiLine
  75072. * @param name defines the control name
  75073. */
  75074. constructor(name?: string | undefined);
  75075. /** Gets or sets dash pattern */
  75076. get dash(): Array<number>;
  75077. set dash(value: Array<number>);
  75078. /**
  75079. * Gets point stored at specified index
  75080. * @param index defines the index to look for
  75081. * @returns the requested point if found
  75082. */
  75083. getAt(index: number): MultiLinePoint;
  75084. /** Function called when a point is updated */
  75085. onPointUpdate: () => void;
  75086. /**
  75087. * Adds new points to the point collection
  75088. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75089. * @returns the list of created MultiLinePoint
  75090. */
  75091. add(...items: (AbstractMesh | Control | {
  75092. x: string | number;
  75093. y: string | number;
  75094. })[]): MultiLinePoint[];
  75095. /**
  75096. * Adds a new point to the point collection
  75097. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75098. * @returns the created MultiLinePoint
  75099. */
  75100. push(item?: (AbstractMesh | Control | {
  75101. x: string | number;
  75102. y: string | number;
  75103. })): MultiLinePoint;
  75104. /**
  75105. * Remove a specific value or point from the active point collection
  75106. * @param value defines the value or point to remove
  75107. */
  75108. remove(value: number | MultiLinePoint): void;
  75109. /**
  75110. * Resets this object to initial state (no point)
  75111. */
  75112. reset(): void;
  75113. /**
  75114. * Resets all links
  75115. */
  75116. resetLinks(): void;
  75117. /** Gets or sets line width */
  75118. get lineWidth(): number;
  75119. set lineWidth(value: number);
  75120. set horizontalAlignment(value: number);
  75121. set verticalAlignment(value: number);
  75122. protected _getTypeName(): string;
  75123. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75124. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75125. _measure(): void;
  75126. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75127. dispose(): void;
  75128. }
  75129. }
  75130. declare module BABYLON.GUI {
  75131. /**
  75132. * Class used to create radio button controls
  75133. */
  75134. export class RadioButton extends Control {
  75135. name?: string | undefined;
  75136. private _isChecked;
  75137. private _background;
  75138. private _checkSizeRatio;
  75139. private _thickness;
  75140. /** Gets or sets border thickness */
  75141. get thickness(): number;
  75142. set thickness(value: number);
  75143. /** Gets or sets group name */
  75144. group: string;
  75145. /** BABYLON.Observable raised when isChecked is changed */
  75146. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75147. /** Gets or sets a value indicating the ratio between overall size and check size */
  75148. get checkSizeRatio(): number;
  75149. set checkSizeRatio(value: number);
  75150. /** Gets or sets background color */
  75151. get background(): string;
  75152. set background(value: string);
  75153. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75154. get isChecked(): boolean;
  75155. set isChecked(value: boolean);
  75156. /**
  75157. * Creates a new RadioButton
  75158. * @param name defines the control name
  75159. */
  75160. constructor(name?: string | undefined);
  75161. protected _getTypeName(): string;
  75162. _draw(context: CanvasRenderingContext2D): void;
  75163. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75164. /**
  75165. * Utility function to easily create a radio button with a header
  75166. * @param title defines the label to use for the header
  75167. * @param group defines the group to use for the radio button
  75168. * @param isChecked defines the initial state of the radio button
  75169. * @param onValueChanged defines the callback to call when value changes
  75170. * @returns a StackPanel containing the radio button and a textBlock
  75171. */
  75172. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  75173. }
  75174. }
  75175. declare module BABYLON.GUI {
  75176. /**
  75177. * Class used to create slider controls
  75178. */
  75179. export class BaseSlider extends Control {
  75180. name?: string | undefined;
  75181. protected _thumbWidth: ValueAndUnit;
  75182. private _minimum;
  75183. private _maximum;
  75184. private _value;
  75185. private _isVertical;
  75186. protected _barOffset: ValueAndUnit;
  75187. private _isThumbClamped;
  75188. protected _displayThumb: boolean;
  75189. private _step;
  75190. private _lastPointerDownID;
  75191. protected _effectiveBarOffset: number;
  75192. protected _renderLeft: number;
  75193. protected _renderTop: number;
  75194. protected _renderWidth: number;
  75195. protected _renderHeight: number;
  75196. protected _backgroundBoxLength: number;
  75197. protected _backgroundBoxThickness: number;
  75198. protected _effectiveThumbThickness: number;
  75199. /** BABYLON.Observable raised when the sldier value changes */
  75200. onValueChangedObservable: BABYLON.Observable<number>;
  75201. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75202. get displayThumb(): boolean;
  75203. set displayThumb(value: boolean);
  75204. /** Gets or sets a step to apply to values (0 by default) */
  75205. get step(): number;
  75206. set step(value: number);
  75207. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75208. get barOffset(): string | number;
  75209. /** Gets main bar offset in pixels*/
  75210. get barOffsetInPixels(): number;
  75211. set barOffset(value: string | number);
  75212. /** Gets or sets thumb width */
  75213. get thumbWidth(): string | number;
  75214. /** Gets thumb width in pixels */
  75215. get thumbWidthInPixels(): number;
  75216. set thumbWidth(value: string | number);
  75217. /** Gets or sets minimum value */
  75218. get minimum(): number;
  75219. set minimum(value: number);
  75220. /** Gets or sets maximum value */
  75221. get maximum(): number;
  75222. set maximum(value: number);
  75223. /** Gets or sets current value */
  75224. get value(): number;
  75225. set value(value: number);
  75226. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75227. get isVertical(): boolean;
  75228. set isVertical(value: boolean);
  75229. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75230. get isThumbClamped(): boolean;
  75231. set isThumbClamped(value: boolean);
  75232. /**
  75233. * Creates a new BaseSlider
  75234. * @param name defines the control name
  75235. */
  75236. constructor(name?: string | undefined);
  75237. protected _getTypeName(): string;
  75238. protected _getThumbPosition(): number;
  75239. protected _getThumbThickness(type: string): number;
  75240. protected _prepareRenderingData(type: string): void;
  75241. private _pointerIsDown;
  75242. /** @hidden */
  75243. protected _updateValueFromPointer(x: number, y: number): void;
  75244. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75245. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75246. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75247. }
  75248. }
  75249. declare module BABYLON.GUI {
  75250. /**
  75251. * Class used to create slider controls
  75252. */
  75253. export class Slider extends BaseSlider {
  75254. name?: string | undefined;
  75255. private _background;
  75256. private _borderColor;
  75257. private _isThumbCircle;
  75258. protected _displayValueBar: boolean;
  75259. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75260. get displayValueBar(): boolean;
  75261. set displayValueBar(value: boolean);
  75262. /** Gets or sets border color */
  75263. get borderColor(): string;
  75264. set borderColor(value: string);
  75265. /** Gets or sets background color */
  75266. get background(): string;
  75267. set background(value: string);
  75268. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75269. get isThumbCircle(): boolean;
  75270. set isThumbCircle(value: boolean);
  75271. /**
  75272. * Creates a new Slider
  75273. * @param name defines the control name
  75274. */
  75275. constructor(name?: string | undefined);
  75276. protected _getTypeName(): string;
  75277. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75278. }
  75279. }
  75280. declare module BABYLON.GUI {
  75281. /** Class used to create a RadioGroup
  75282. * which contains groups of radio buttons
  75283. */
  75284. export class SelectorGroup {
  75285. /** name of SelectorGroup */
  75286. name: string;
  75287. private _groupPanel;
  75288. private _selectors;
  75289. private _groupHeader;
  75290. /**
  75291. * Creates a new SelectorGroup
  75292. * @param name of group, used as a group heading
  75293. */
  75294. constructor(
  75295. /** name of SelectorGroup */
  75296. name: string);
  75297. /** Gets the groupPanel of the SelectorGroup */
  75298. get groupPanel(): StackPanel;
  75299. /** Gets the selectors array */
  75300. get selectors(): StackPanel[];
  75301. /** Gets and sets the group header */
  75302. get header(): string;
  75303. set header(label: string);
  75304. /** @hidden */
  75305. private _addGroupHeader;
  75306. /** @hidden*/
  75307. _getSelector(selectorNb: number): StackPanel | undefined;
  75308. /** Removes the selector at the given position
  75309. * @param selectorNb the position of the selector within the group
  75310. */
  75311. removeSelector(selectorNb: number): void;
  75312. }
  75313. /** Class used to create a CheckboxGroup
  75314. * which contains groups of checkbox buttons
  75315. */
  75316. export class CheckboxGroup extends SelectorGroup {
  75317. /** Adds a checkbox as a control
  75318. * @param text is the label for the selector
  75319. * @param func is the function called when the Selector is checked
  75320. * @param checked is true when Selector is checked
  75321. */
  75322. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  75323. /** @hidden */
  75324. _setSelectorLabel(selectorNb: number, label: string): void;
  75325. /** @hidden */
  75326. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75327. /** @hidden */
  75328. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75329. /** @hidden */
  75330. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75331. }
  75332. /** Class used to create a RadioGroup
  75333. * which contains groups of radio buttons
  75334. */
  75335. export class RadioGroup extends SelectorGroup {
  75336. private _selectNb;
  75337. /** Adds a radio button as a control
  75338. * @param label is the label for the selector
  75339. * @param func is the function called when the Selector is checked
  75340. * @param checked is true when Selector is checked
  75341. */
  75342. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75343. /** @hidden */
  75344. _setSelectorLabel(selectorNb: number, label: string): void;
  75345. /** @hidden */
  75346. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75347. /** @hidden */
  75348. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75349. /** @hidden */
  75350. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75351. }
  75352. /** Class used to create a SliderGroup
  75353. * which contains groups of slider buttons
  75354. */
  75355. export class SliderGroup extends SelectorGroup {
  75356. /**
  75357. * Adds a slider to the SelectorGroup
  75358. * @param label is the label for the SliderBar
  75359. * @param func is the function called when the Slider moves
  75360. * @param unit is a string describing the units used, eg degrees or metres
  75361. * @param min is the minimum value for the Slider
  75362. * @param max is the maximum value for the Slider
  75363. * @param value is the start value for the Slider between min and max
  75364. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75365. */
  75366. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75367. /** @hidden */
  75368. _setSelectorLabel(selectorNb: number, label: string): void;
  75369. /** @hidden */
  75370. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75371. /** @hidden */
  75372. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75373. /** @hidden */
  75374. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75375. }
  75376. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75377. * @see http://doc.babylonjs.com/how_to/selector
  75378. */
  75379. export class SelectionPanel extends Rectangle {
  75380. /** name of SelectionPanel */
  75381. name: string;
  75382. /** an array of SelectionGroups */
  75383. groups: SelectorGroup[];
  75384. private _panel;
  75385. private _buttonColor;
  75386. private _buttonBackground;
  75387. private _headerColor;
  75388. private _barColor;
  75389. private _barHeight;
  75390. private _spacerHeight;
  75391. private _labelColor;
  75392. private _groups;
  75393. private _bars;
  75394. /**
  75395. * Creates a new SelectionPanel
  75396. * @param name of SelectionPanel
  75397. * @param groups is an array of SelectionGroups
  75398. */
  75399. constructor(
  75400. /** name of SelectionPanel */
  75401. name: string,
  75402. /** an array of SelectionGroups */
  75403. groups?: SelectorGroup[]);
  75404. protected _getTypeName(): string;
  75405. /** Gets or sets the headerColor */
  75406. get headerColor(): string;
  75407. set headerColor(color: string);
  75408. private _setHeaderColor;
  75409. /** Gets or sets the button color */
  75410. get buttonColor(): string;
  75411. set buttonColor(color: string);
  75412. private _setbuttonColor;
  75413. /** Gets or sets the label color */
  75414. get labelColor(): string;
  75415. set labelColor(color: string);
  75416. private _setLabelColor;
  75417. /** Gets or sets the button background */
  75418. get buttonBackground(): string;
  75419. set buttonBackground(color: string);
  75420. private _setButtonBackground;
  75421. /** Gets or sets the color of separator bar */
  75422. get barColor(): string;
  75423. set barColor(color: string);
  75424. private _setBarColor;
  75425. /** Gets or sets the height of separator bar */
  75426. get barHeight(): string;
  75427. set barHeight(value: string);
  75428. private _setBarHeight;
  75429. /** Gets or sets the height of spacers*/
  75430. get spacerHeight(): string;
  75431. set spacerHeight(value: string);
  75432. private _setSpacerHeight;
  75433. /** Adds a bar between groups */
  75434. private _addSpacer;
  75435. /** Add a group to the selection panel
  75436. * @param group is the selector group to add
  75437. */
  75438. addGroup(group: SelectorGroup): void;
  75439. /** Remove the group from the given position
  75440. * @param groupNb is the position of the group in the list
  75441. */
  75442. removeGroup(groupNb: number): void;
  75443. /** Change a group header label
  75444. * @param label is the new group header label
  75445. * @param groupNb is the number of the group to relabel
  75446. * */
  75447. setHeaderName(label: string, groupNb: number): void;
  75448. /** Change selector label to the one given
  75449. * @param label is the new selector label
  75450. * @param groupNb is the number of the groupcontaining the selector
  75451. * @param selectorNb is the number of the selector within a group to relabel
  75452. * */
  75453. relabel(label: string, groupNb: number, selectorNb: number): void;
  75454. /** For a given group position remove the selector at the given position
  75455. * @param groupNb is the number of the group to remove the selector from
  75456. * @param selectorNb is the number of the selector within the group
  75457. */
  75458. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75459. /** For a given group position of correct type add a checkbox button
  75460. * @param groupNb is the number of the group to remove the selector from
  75461. * @param label is the label for the selector
  75462. * @param func is the function called when the Selector is checked
  75463. * @param checked is true when Selector is checked
  75464. */
  75465. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75466. /** For a given group position of correct type add a radio button
  75467. * @param groupNb is the number of the group to remove the selector from
  75468. * @param label is the label for the selector
  75469. * @param func is the function called when the Selector is checked
  75470. * @param checked is true when Selector is checked
  75471. */
  75472. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75473. /**
  75474. * For a given slider group add a slider
  75475. * @param groupNb is the number of the group to add the slider to
  75476. * @param label is the label for the Slider
  75477. * @param func is the function called when the Slider moves
  75478. * @param unit is a string describing the units used, eg degrees or metres
  75479. * @param min is the minimum value for the Slider
  75480. * @param max is the maximum value for the Slider
  75481. * @param value is the start value for the Slider between min and max
  75482. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75483. */
  75484. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75485. }
  75486. }
  75487. declare module BABYLON.GUI {
  75488. /**
  75489. * Class used to hold a the container for ScrollViewer
  75490. * @hidden
  75491. */
  75492. export class _ScrollViewerWindow extends Container {
  75493. parentClientWidth: number;
  75494. parentClientHeight: number;
  75495. private _freezeControls;
  75496. private _parentMeasure;
  75497. private _oldLeft;
  75498. private _oldTop;
  75499. get freezeControls(): boolean;
  75500. set freezeControls(value: boolean);
  75501. private _bucketWidth;
  75502. private _bucketHeight;
  75503. private _buckets;
  75504. private _bucketLen;
  75505. get bucketWidth(): number;
  75506. get bucketHeight(): number;
  75507. setBucketSizes(width: number, height: number): void;
  75508. private _useBuckets;
  75509. private _makeBuckets;
  75510. private _dispatchInBuckets;
  75511. private _updateMeasures;
  75512. private _updateChildrenMeasures;
  75513. private _restoreMeasures;
  75514. /**
  75515. * Creates a new ScrollViewerWindow
  75516. * @param name of ScrollViewerWindow
  75517. */
  75518. constructor(name?: string);
  75519. protected _getTypeName(): string;
  75520. /** @hidden */
  75521. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75522. /** @hidden */
  75523. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75524. private _scrollChildren;
  75525. private _scrollChildrenWithBuckets;
  75526. /** @hidden */
  75527. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75528. protected _postMeasure(): void;
  75529. }
  75530. }
  75531. declare module BABYLON.GUI {
  75532. /**
  75533. * Class used to create slider controls
  75534. */
  75535. export class ScrollBar extends BaseSlider {
  75536. name?: string | undefined;
  75537. private _background;
  75538. private _borderColor;
  75539. private _tempMeasure;
  75540. /** Gets or sets border color */
  75541. get borderColor(): string;
  75542. set borderColor(value: string);
  75543. /** Gets or sets background color */
  75544. get background(): string;
  75545. set background(value: string);
  75546. /**
  75547. * Creates a new Slider
  75548. * @param name defines the control name
  75549. */
  75550. constructor(name?: string | undefined);
  75551. protected _getTypeName(): string;
  75552. protected _getThumbThickness(): number;
  75553. _draw(context: CanvasRenderingContext2D): void;
  75554. private _first;
  75555. private _originX;
  75556. private _originY;
  75557. /** @hidden */
  75558. protected _updateValueFromPointer(x: number, y: number): void;
  75559. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75560. }
  75561. }
  75562. declare module BABYLON.GUI {
  75563. /**
  75564. * Class used to create slider controls
  75565. */
  75566. export class ImageScrollBar extends BaseSlider {
  75567. name?: string | undefined;
  75568. private _backgroundBaseImage;
  75569. private _backgroundImage;
  75570. private _thumbImage;
  75571. private _thumbBaseImage;
  75572. private _thumbLength;
  75573. private _thumbHeight;
  75574. private _barImageHeight;
  75575. private _tempMeasure;
  75576. /** Number of 90° rotation to apply on the images when in vertical mode */
  75577. num90RotationInVerticalMode: number;
  75578. /**
  75579. * Gets or sets the image used to render the background for horizontal bar
  75580. */
  75581. get backgroundImage(): Image;
  75582. set backgroundImage(value: Image);
  75583. /**
  75584. * Gets or sets the image used to render the thumb
  75585. */
  75586. get thumbImage(): Image;
  75587. set thumbImage(value: Image);
  75588. /**
  75589. * Gets or sets the length of the thumb
  75590. */
  75591. get thumbLength(): number;
  75592. set thumbLength(value: number);
  75593. /**
  75594. * Gets or sets the height of the thumb
  75595. */
  75596. get thumbHeight(): number;
  75597. set thumbHeight(value: number);
  75598. /**
  75599. * Gets or sets the height of the bar image
  75600. */
  75601. get barImageHeight(): number;
  75602. set barImageHeight(value: number);
  75603. /**
  75604. * Creates a new ImageScrollBar
  75605. * @param name defines the control name
  75606. */
  75607. constructor(name?: string | undefined);
  75608. protected _getTypeName(): string;
  75609. protected _getThumbThickness(): number;
  75610. _draw(context: CanvasRenderingContext2D): void;
  75611. private _first;
  75612. private _originX;
  75613. private _originY;
  75614. /** @hidden */
  75615. protected _updateValueFromPointer(x: number, y: number): void;
  75616. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75617. }
  75618. }
  75619. declare module BABYLON.GUI {
  75620. /**
  75621. * Class used to hold a viewer window and sliders in a grid
  75622. */
  75623. export class ScrollViewer extends Rectangle {
  75624. private _grid;
  75625. private _horizontalBarSpace;
  75626. private _verticalBarSpace;
  75627. private _dragSpace;
  75628. private _horizontalBar;
  75629. private _verticalBar;
  75630. private _barColor;
  75631. private _barBackground;
  75632. private _barImage;
  75633. private _horizontalBarImage;
  75634. private _verticalBarImage;
  75635. private _barBackgroundImage;
  75636. private _horizontalBarBackgroundImage;
  75637. private _verticalBarBackgroundImage;
  75638. private _barSize;
  75639. private _window;
  75640. private _pointerIsOver;
  75641. private _wheelPrecision;
  75642. private _onWheelObserver;
  75643. private _clientWidth;
  75644. private _clientHeight;
  75645. private _useImageBar;
  75646. private _thumbLength;
  75647. private _thumbHeight;
  75648. private _barImageHeight;
  75649. private _horizontalBarImageHeight;
  75650. private _verticalBarImageHeight;
  75651. private _oldWindowContentsWidth;
  75652. private _oldWindowContentsHeight;
  75653. /**
  75654. * Gets the horizontal scrollbar
  75655. */
  75656. get horizontalBar(): ScrollBar | ImageScrollBar;
  75657. /**
  75658. * Gets the vertical scrollbar
  75659. */
  75660. get verticalBar(): ScrollBar | ImageScrollBar;
  75661. /**
  75662. * Adds a new control to the current container
  75663. * @param control defines the control to add
  75664. * @returns the current container
  75665. */
  75666. addControl(control: BABYLON.Nullable<Control>): Container;
  75667. /**
  75668. * Removes a control from the current container
  75669. * @param control defines the control to remove
  75670. * @returns the current container
  75671. */
  75672. removeControl(control: Control): Container;
  75673. /** Gets the list of children */
  75674. get children(): Control[];
  75675. _flagDescendantsAsMatrixDirty(): void;
  75676. /**
  75677. * Freezes or unfreezes the controls in the window.
  75678. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  75679. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  75680. */
  75681. get freezeControls(): boolean;
  75682. set freezeControls(value: boolean);
  75683. /** Gets the bucket width */
  75684. get bucketWidth(): number;
  75685. /** Gets the bucket height */
  75686. get bucketHeight(): number;
  75687. /**
  75688. * Sets the bucket sizes.
  75689. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  75690. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  75691. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  75692. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  75693. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  75694. * used), that's why it is not enabled by default.
  75695. * @param width width of the bucket
  75696. * @param height height of the bucket
  75697. */
  75698. setBucketSizes(width: number, height: number): void;
  75699. private _forceHorizontalBar;
  75700. private _forceVerticalBar;
  75701. /**
  75702. * Forces the horizontal scroll bar to be displayed
  75703. */
  75704. get forceHorizontalBar(): boolean;
  75705. set forceHorizontalBar(value: boolean);
  75706. /**
  75707. * Forces the vertical scroll bar to be displayed
  75708. */
  75709. get forceVerticalBar(): boolean;
  75710. set forceVerticalBar(value: boolean);
  75711. /**
  75712. * Creates a new ScrollViewer
  75713. * @param name of ScrollViewer
  75714. */
  75715. constructor(name?: string, isImageBased?: boolean);
  75716. /** Reset the scroll viewer window to initial size */
  75717. resetWindow(): void;
  75718. protected _getTypeName(): string;
  75719. private _buildClientSizes;
  75720. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75721. protected _postMeasure(): void;
  75722. /**
  75723. * Gets or sets the mouse wheel precision
  75724. * from 0 to 1 with a default value of 0.05
  75725. * */
  75726. get wheelPrecision(): number;
  75727. set wheelPrecision(value: number);
  75728. /** Gets or sets the scroll bar container background color */
  75729. get scrollBackground(): string;
  75730. set scrollBackground(color: string);
  75731. /** Gets or sets the bar color */
  75732. get barColor(): string;
  75733. set barColor(color: string);
  75734. /** Gets or sets the bar image */
  75735. get thumbImage(): Image;
  75736. set thumbImage(value: Image);
  75737. /** Gets or sets the horizontal bar image */
  75738. get horizontalThumbImage(): Image;
  75739. set horizontalThumbImage(value: Image);
  75740. /** Gets or sets the vertical bar image */
  75741. get verticalThumbImage(): Image;
  75742. set verticalThumbImage(value: Image);
  75743. /** Gets or sets the size of the bar */
  75744. get barSize(): number;
  75745. set barSize(value: number);
  75746. /** Gets or sets the length of the thumb */
  75747. get thumbLength(): number;
  75748. set thumbLength(value: number);
  75749. /** Gets or sets the height of the thumb */
  75750. get thumbHeight(): number;
  75751. set thumbHeight(value: number);
  75752. /** Gets or sets the height of the bar image */
  75753. get barImageHeight(): number;
  75754. set barImageHeight(value: number);
  75755. /** Gets or sets the height of the horizontal bar image */
  75756. get horizontalBarImageHeight(): number;
  75757. set horizontalBarImageHeight(value: number);
  75758. /** Gets or sets the height of the vertical bar image */
  75759. get verticalBarImageHeight(): number;
  75760. set verticalBarImageHeight(value: number);
  75761. /** Gets or sets the bar background */
  75762. get barBackground(): string;
  75763. set barBackground(color: string);
  75764. /** Gets or sets the bar background image */
  75765. get barImage(): Image;
  75766. set barImage(value: Image);
  75767. /** Gets or sets the horizontal bar background image */
  75768. get horizontalBarImage(): Image;
  75769. set horizontalBarImage(value: Image);
  75770. /** Gets or sets the vertical bar background image */
  75771. get verticalBarImage(): Image;
  75772. set verticalBarImage(value: Image);
  75773. private _setWindowPosition;
  75774. /** @hidden */
  75775. private _updateScroller;
  75776. _link(host: AdvancedDynamicTexture): void;
  75777. /** @hidden */
  75778. private _addBar;
  75779. /** @hidden */
  75780. private _attachWheel;
  75781. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75782. /** Releases associated resources */
  75783. dispose(): void;
  75784. }
  75785. }
  75786. declare module BABYLON.GUI {
  75787. /** Class used to render a grid */
  75788. export class DisplayGrid extends Control {
  75789. name?: string | undefined;
  75790. private _cellWidth;
  75791. private _cellHeight;
  75792. private _minorLineTickness;
  75793. private _minorLineColor;
  75794. private _majorLineTickness;
  75795. private _majorLineColor;
  75796. private _majorLineFrequency;
  75797. private _background;
  75798. private _displayMajorLines;
  75799. private _displayMinorLines;
  75800. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  75801. get displayMinorLines(): boolean;
  75802. set displayMinorLines(value: boolean);
  75803. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  75804. get displayMajorLines(): boolean;
  75805. set displayMajorLines(value: boolean);
  75806. /** Gets or sets background color (Black by default) */
  75807. get background(): string;
  75808. set background(value: string);
  75809. /** Gets or sets the width of each cell (20 by default) */
  75810. get cellWidth(): number;
  75811. set cellWidth(value: number);
  75812. /** Gets or sets the height of each cell (20 by default) */
  75813. get cellHeight(): number;
  75814. set cellHeight(value: number);
  75815. /** Gets or sets the tickness of minor lines (1 by default) */
  75816. get minorLineTickness(): number;
  75817. set minorLineTickness(value: number);
  75818. /** Gets or sets the color of minor lines (DarkGray by default) */
  75819. get minorLineColor(): string;
  75820. set minorLineColor(value: string);
  75821. /** Gets or sets the tickness of major lines (2 by default) */
  75822. get majorLineTickness(): number;
  75823. set majorLineTickness(value: number);
  75824. /** Gets or sets the color of major lines (White by default) */
  75825. get majorLineColor(): string;
  75826. set majorLineColor(value: string);
  75827. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  75828. get majorLineFrequency(): number;
  75829. set majorLineFrequency(value: number);
  75830. /**
  75831. * Creates a new GridDisplayRectangle
  75832. * @param name defines the control name
  75833. */
  75834. constructor(name?: string | undefined);
  75835. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75836. protected _getTypeName(): string;
  75837. }
  75838. }
  75839. declare module BABYLON.GUI {
  75840. /**
  75841. * Class used to create slider controls based on images
  75842. */
  75843. export class ImageBasedSlider extends BaseSlider {
  75844. name?: string | undefined;
  75845. private _backgroundImage;
  75846. private _thumbImage;
  75847. private _valueBarImage;
  75848. private _tempMeasure;
  75849. get displayThumb(): boolean;
  75850. set displayThumb(value: boolean);
  75851. /**
  75852. * Gets or sets the image used to render the background
  75853. */
  75854. get backgroundImage(): Image;
  75855. set backgroundImage(value: Image);
  75856. /**
  75857. * Gets or sets the image used to render the value bar
  75858. */
  75859. get valueBarImage(): Image;
  75860. set valueBarImage(value: Image);
  75861. /**
  75862. * Gets or sets the image used to render the thumb
  75863. */
  75864. get thumbImage(): Image;
  75865. set thumbImage(value: Image);
  75866. /**
  75867. * Creates a new ImageBasedSlider
  75868. * @param name defines the control name
  75869. */
  75870. constructor(name?: string | undefined);
  75871. protected _getTypeName(): string;
  75872. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75873. }
  75874. }
  75875. declare module BABYLON.GUI {
  75876. /**
  75877. * Forcing an export so that this code will execute
  75878. * @hidden
  75879. */
  75880. const name = "Statics";
  75881. }
  75882. declare module BABYLON.GUI {
  75883. /**
  75884. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  75885. */
  75886. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  75887. /**
  75888. * Define the instrumented AdvancedDynamicTexture.
  75889. */
  75890. texture: AdvancedDynamicTexture;
  75891. private _captureRenderTime;
  75892. private _renderTime;
  75893. private _captureLayoutTime;
  75894. private _layoutTime;
  75895. private _onBeginRenderObserver;
  75896. private _onEndRenderObserver;
  75897. private _onBeginLayoutObserver;
  75898. private _onEndLayoutObserver;
  75899. /**
  75900. * Gets the perf counter used to capture render time
  75901. */
  75902. get renderTimeCounter(): BABYLON.PerfCounter;
  75903. /**
  75904. * Gets the perf counter used to capture layout time
  75905. */
  75906. get layoutTimeCounter(): BABYLON.PerfCounter;
  75907. /**
  75908. * Enable or disable the render time capture
  75909. */
  75910. get captureRenderTime(): boolean;
  75911. set captureRenderTime(value: boolean);
  75912. /**
  75913. * Enable or disable the layout time capture
  75914. */
  75915. get captureLayoutTime(): boolean;
  75916. set captureLayoutTime(value: boolean);
  75917. /**
  75918. * Instantiates a new advanced dynamic texture instrumentation.
  75919. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  75920. * @param texture Defines the AdvancedDynamicTexture to instrument
  75921. */
  75922. constructor(
  75923. /**
  75924. * Define the instrumented AdvancedDynamicTexture.
  75925. */
  75926. texture: AdvancedDynamicTexture);
  75927. /**
  75928. * Dispose and release associated resources.
  75929. */
  75930. dispose(): void;
  75931. }
  75932. }
  75933. declare module BABYLON.GUI {
  75934. /**
  75935. * Class used to load GUI via XML.
  75936. */
  75937. export class XmlLoader {
  75938. private _nodes;
  75939. private _nodeTypes;
  75940. private _isLoaded;
  75941. private _objectAttributes;
  75942. private _parentClass;
  75943. /**
  75944. * Create a new xml loader
  75945. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  75946. */
  75947. constructor(parentClass?: null);
  75948. private _getChainElement;
  75949. private _getClassAttribute;
  75950. private _createGuiElement;
  75951. private _parseGrid;
  75952. private _parseElement;
  75953. private _prepareSourceElement;
  75954. private _parseElementsFromSource;
  75955. private _parseXml;
  75956. /**
  75957. * Gets if the loading has finished.
  75958. * @returns whether the loading has finished or not
  75959. */
  75960. isLoaded(): boolean;
  75961. /**
  75962. * Gets a loaded node / control by id.
  75963. * @param id the Controls id set in the xml
  75964. * @returns element of type Control
  75965. */
  75966. getNodeById(id: string): any;
  75967. /**
  75968. * Gets all loaded nodes / controls
  75969. * @returns Array of controls
  75970. */
  75971. getNodes(): any;
  75972. /**
  75973. * Initiates the xml layout loading
  75974. * @param xmlFile defines the xml layout to load
  75975. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  75976. * @param callback defines the callback called on layout load.
  75977. */
  75978. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  75979. }
  75980. }
  75981. declare module BABYLON.GUI {
  75982. /**
  75983. * Class used to create containers for controls
  75984. */
  75985. export class Container3D extends Control3D {
  75986. private _blockLayout;
  75987. /**
  75988. * Gets the list of child controls
  75989. */
  75990. protected _children: Control3D[];
  75991. /**
  75992. * Gets the list of child controls
  75993. */
  75994. get children(): Array<Control3D>;
  75995. /**
  75996. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  75997. * This is helpful to optimize layout operation when adding multiple children in a row
  75998. */
  75999. get blockLayout(): boolean;
  76000. set blockLayout(value: boolean);
  76001. /**
  76002. * Creates a new container
  76003. * @param name defines the container name
  76004. */
  76005. constructor(name?: string);
  76006. /**
  76007. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76008. * @returns the current container
  76009. */
  76010. updateLayout(): Container3D;
  76011. /**
  76012. * Gets a boolean indicating if the given control is in the children of this control
  76013. * @param control defines the control to check
  76014. * @returns true if the control is in the child list
  76015. */
  76016. containsControl(control: Control3D): boolean;
  76017. /**
  76018. * Adds a control to the children of this control
  76019. * @param control defines the control to add
  76020. * @returns the current container
  76021. */
  76022. addControl(control: Control3D): Container3D;
  76023. /**
  76024. * This function will be called everytime a new control is added
  76025. */
  76026. protected _arrangeChildren(): void;
  76027. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76028. /**
  76029. * Removes a control from the children of this control
  76030. * @param control defines the control to remove
  76031. * @returns the current container
  76032. */
  76033. removeControl(control: Control3D): Container3D;
  76034. protected _getTypeName(): string;
  76035. /**
  76036. * Releases all associated resources
  76037. */
  76038. dispose(): void;
  76039. /** Control rotation will remain unchanged */
  76040. static readonly UNSET_ORIENTATION: number;
  76041. /** Control will rotate to make it look at sphere central axis */
  76042. static readonly FACEORIGIN_ORIENTATION: number;
  76043. /** Control will rotate to make it look back at sphere central axis */
  76044. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76045. /** Control will rotate to look at z axis (0, 0, 1) */
  76046. static readonly FACEFORWARD_ORIENTATION: number;
  76047. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76048. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76049. }
  76050. }
  76051. declare module BABYLON.GUI {
  76052. /**
  76053. * Class used to manage 3D user interface
  76054. * @see http://doc.babylonjs.com/how_to/gui3d
  76055. */
  76056. export class GUI3DManager implements BABYLON.IDisposable {
  76057. private _scene;
  76058. private _sceneDisposeObserver;
  76059. private _utilityLayer;
  76060. private _rootContainer;
  76061. private _pointerObserver;
  76062. private _pointerOutObserver;
  76063. /** @hidden */
  76064. _lastPickedControl: Control3D;
  76065. /** @hidden */
  76066. _lastControlOver: {
  76067. [pointerId: number]: Control3D;
  76068. };
  76069. /** @hidden */
  76070. _lastControlDown: {
  76071. [pointerId: number]: Control3D;
  76072. };
  76073. /**
  76074. * BABYLON.Observable raised when the point picked by the pointer events changed
  76075. */
  76076. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76077. /** @hidden */
  76078. _sharedMaterials: {
  76079. [key: string]: BABYLON.Material;
  76080. };
  76081. /** Gets the hosting scene */
  76082. get scene(): BABYLON.Scene;
  76083. /** Gets associated utility layer */
  76084. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76085. /**
  76086. * Creates a new GUI3DManager
  76087. * @param scene
  76088. */
  76089. constructor(scene?: BABYLON.Scene);
  76090. private _handlePointerOut;
  76091. private _doPicking;
  76092. /**
  76093. * Gets the root container
  76094. */
  76095. get rootContainer(): Container3D;
  76096. /**
  76097. * Gets a boolean indicating if the given control is in the root child list
  76098. * @param control defines the control to check
  76099. * @returns true if the control is in the root child list
  76100. */
  76101. containsControl(control: Control3D): boolean;
  76102. /**
  76103. * Adds a control to the root child list
  76104. * @param control defines the control to add
  76105. * @returns the current manager
  76106. */
  76107. addControl(control: Control3D): GUI3DManager;
  76108. /**
  76109. * Removes a control from the root child list
  76110. * @param control defines the control to remove
  76111. * @returns the current container
  76112. */
  76113. removeControl(control: Control3D): GUI3DManager;
  76114. /**
  76115. * Releases all associated resources
  76116. */
  76117. dispose(): void;
  76118. }
  76119. }
  76120. declare module BABYLON.GUI {
  76121. /**
  76122. * Class used to transport BABYLON.Vector3 information for pointer events
  76123. */
  76124. export class Vector3WithInfo extends BABYLON.Vector3 {
  76125. /** defines the current mouse button index */
  76126. buttonIndex: number;
  76127. /**
  76128. * Creates a new Vector3WithInfo
  76129. * @param source defines the vector3 data to transport
  76130. * @param buttonIndex defines the current mouse button index
  76131. */
  76132. constructor(source: BABYLON.Vector3,
  76133. /** defines the current mouse button index */
  76134. buttonIndex?: number);
  76135. }
  76136. }
  76137. declare module BABYLON.GUI {
  76138. /**
  76139. * Class used as base class for controls
  76140. */
  76141. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76142. /** Defines the control name */
  76143. name?: string | undefined;
  76144. /** @hidden */
  76145. _host: GUI3DManager;
  76146. private _node;
  76147. private _downCount;
  76148. private _enterCount;
  76149. private _downPointerIds;
  76150. private _isVisible;
  76151. /** Gets or sets the control position in world space */
  76152. get position(): BABYLON.Vector3;
  76153. set position(value: BABYLON.Vector3);
  76154. /** Gets or sets the control scaling in world space */
  76155. get scaling(): BABYLON.Vector3;
  76156. set scaling(value: BABYLON.Vector3);
  76157. /** Callback used to start pointer enter animation */
  76158. pointerEnterAnimation: () => void;
  76159. /** Callback used to start pointer out animation */
  76160. pointerOutAnimation: () => void;
  76161. /** Callback used to start pointer down animation */
  76162. pointerDownAnimation: () => void;
  76163. /** Callback used to start pointer up animation */
  76164. pointerUpAnimation: () => void;
  76165. /**
  76166. * An event triggered when the pointer move over the control
  76167. */
  76168. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  76169. /**
  76170. * An event triggered when the pointer move out of the control
  76171. */
  76172. onPointerOutObservable: BABYLON.Observable<Control3D>;
  76173. /**
  76174. * An event triggered when the pointer taps the control
  76175. */
  76176. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  76177. /**
  76178. * An event triggered when pointer is up
  76179. */
  76180. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76181. /**
  76182. * An event triggered when a control is clicked on (with a mouse)
  76183. */
  76184. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76185. /**
  76186. * An event triggered when pointer enters the control
  76187. */
  76188. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76189. /**
  76190. * Gets or sets the parent container
  76191. */
  76192. parent: BABYLON.Nullable<Container3D>;
  76193. private _behaviors;
  76194. /**
  76195. * Gets the list of attached behaviors
  76196. * @see http://doc.babylonjs.com/features/behaviour
  76197. */
  76198. get behaviors(): BABYLON.Behavior<Control3D>[];
  76199. /**
  76200. * Attach a behavior to the control
  76201. * @see http://doc.babylonjs.com/features/behaviour
  76202. * @param behavior defines the behavior to attach
  76203. * @returns the current control
  76204. */
  76205. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76206. /**
  76207. * Remove an attached behavior
  76208. * @see http://doc.babylonjs.com/features/behaviour
  76209. * @param behavior defines the behavior to attach
  76210. * @returns the current control
  76211. */
  76212. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76213. /**
  76214. * Gets an attached behavior by name
  76215. * @param name defines the name of the behavior to look for
  76216. * @see http://doc.babylonjs.com/features/behaviour
  76217. * @returns null if behavior was not found else the requested behavior
  76218. */
  76219. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76220. /** Gets or sets a boolean indicating if the control is visible */
  76221. get isVisible(): boolean;
  76222. set isVisible(value: boolean);
  76223. /**
  76224. * Creates a new control
  76225. * @param name defines the control name
  76226. */
  76227. constructor(
  76228. /** Defines the control name */
  76229. name?: string | undefined);
  76230. /**
  76231. * Gets a string representing the class name
  76232. */
  76233. get typeName(): string;
  76234. /**
  76235. * Get the current class name of the control.
  76236. * @returns current class name
  76237. */
  76238. getClassName(): string;
  76239. protected _getTypeName(): string;
  76240. /**
  76241. * Gets the transform node used by this control
  76242. */
  76243. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76244. /**
  76245. * Gets the mesh used to render this control
  76246. */
  76247. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76248. /**
  76249. * Link the control as child of the given node
  76250. * @param node defines the node to link to. Use null to unlink the control
  76251. * @returns the current control
  76252. */
  76253. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76254. /** @hidden **/
  76255. _prepareNode(scene: BABYLON.Scene): void;
  76256. /**
  76257. * Node creation.
  76258. * Can be overriden by children
  76259. * @param scene defines the scene where the node must be attached
  76260. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76261. */
  76262. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76263. /**
  76264. * Affect a material to the given mesh
  76265. * @param mesh defines the mesh which will represent the control
  76266. */
  76267. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76268. /** @hidden */
  76269. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76270. /** @hidden */
  76271. _onPointerEnter(target: Control3D): boolean;
  76272. /** @hidden */
  76273. _onPointerOut(target: Control3D): void;
  76274. /** @hidden */
  76275. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76276. /** @hidden */
  76277. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76278. /** @hidden */
  76279. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76280. /** @hidden */
  76281. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76282. /** @hidden */
  76283. _disposeNode(): void;
  76284. /**
  76285. * Releases all associated resources
  76286. */
  76287. dispose(): void;
  76288. }
  76289. }
  76290. declare module BABYLON.GUI {
  76291. /**
  76292. * Class used as a root to all buttons
  76293. */
  76294. export class AbstractButton3D extends Control3D {
  76295. /**
  76296. * Creates a new button
  76297. * @param name defines the control name
  76298. */
  76299. constructor(name?: string);
  76300. protected _getTypeName(): string;
  76301. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76302. }
  76303. }
  76304. declare module BABYLON.GUI {
  76305. /**
  76306. * Class used to create a button in 3D
  76307. */
  76308. export class Button3D extends AbstractButton3D {
  76309. /** @hidden */
  76310. protected _currentMaterial: BABYLON.Material;
  76311. private _facadeTexture;
  76312. private _content;
  76313. private _contentResolution;
  76314. private _contentScaleRatio;
  76315. /**
  76316. * Gets or sets the texture resolution used to render content (512 by default)
  76317. */
  76318. get contentResolution(): BABYLON.int;
  76319. set contentResolution(value: BABYLON.int);
  76320. /**
  76321. * Gets or sets the texture scale ratio used to render content (2 by default)
  76322. */
  76323. get contentScaleRatio(): number;
  76324. set contentScaleRatio(value: number);
  76325. protected _disposeFacadeTexture(): void;
  76326. protected _resetContent(): void;
  76327. /**
  76328. * Creates a new button
  76329. * @param name defines the control name
  76330. */
  76331. constructor(name?: string);
  76332. /**
  76333. * Gets or sets the GUI 2D content used to display the button's facade
  76334. */
  76335. get content(): Control;
  76336. set content(value: Control);
  76337. /**
  76338. * Apply the facade texture (created from the content property).
  76339. * This function can be overloaded by child classes
  76340. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76341. */
  76342. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76343. protected _getTypeName(): string;
  76344. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76345. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76346. /**
  76347. * Releases all associated resources
  76348. */
  76349. dispose(): void;
  76350. }
  76351. }
  76352. declare module BABYLON.GUI {
  76353. /**
  76354. * Abstract class used to create a container panel deployed on the surface of a volume
  76355. */
  76356. export abstract class VolumeBasedPanel extends Container3D {
  76357. private _columns;
  76358. private _rows;
  76359. private _rowThenColum;
  76360. private _orientation;
  76361. protected _cellWidth: number;
  76362. protected _cellHeight: number;
  76363. /**
  76364. * Gets or sets the distance between elements
  76365. */
  76366. margin: number;
  76367. /**
  76368. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76369. * | Value | Type | Description |
  76370. * | ----- | ----------------------------------- | ----------- |
  76371. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76372. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76373. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76374. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76375. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76376. */
  76377. get orientation(): number;
  76378. set orientation(value: number);
  76379. /**
  76380. * Gets or sets the number of columns requested (10 by default).
  76381. * The panel will automatically compute the number of rows based on number of child controls.
  76382. */
  76383. get columns(): BABYLON.int;
  76384. set columns(value: BABYLON.int);
  76385. /**
  76386. * Gets or sets a the number of rows requested.
  76387. * The panel will automatically compute the number of columns based on number of child controls.
  76388. */
  76389. get rows(): BABYLON.int;
  76390. set rows(value: BABYLON.int);
  76391. /**
  76392. * Creates new VolumeBasedPanel
  76393. */
  76394. constructor();
  76395. protected _arrangeChildren(): void;
  76396. /** Child classes must implement this function to provide correct control positioning */
  76397. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76398. /** Child classes can implement this function to provide additional processing */
  76399. protected _finalProcessing(): void;
  76400. }
  76401. }
  76402. declare module BABYLON.GUI {
  76403. /**
  76404. * Class used to create a container panel deployed on the surface of a cylinder
  76405. */
  76406. export class CylinderPanel extends VolumeBasedPanel {
  76407. private _radius;
  76408. /**
  76409. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76410. */
  76411. get radius(): BABYLON.float;
  76412. set radius(value: BABYLON.float);
  76413. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76414. private _cylindricalMapping;
  76415. }
  76416. }
  76417. declare module BABYLON.GUI {
  76418. /** @hidden */
  76419. export var fluentVertexShader: {
  76420. name: string;
  76421. shader: string;
  76422. };
  76423. }
  76424. declare module BABYLON.GUI {
  76425. /** @hidden */
  76426. export var fluentPixelShader: {
  76427. name: string;
  76428. shader: string;
  76429. };
  76430. }
  76431. declare module BABYLON.GUI {
  76432. /** @hidden */
  76433. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76434. INNERGLOW: boolean;
  76435. BORDER: boolean;
  76436. HOVERLIGHT: boolean;
  76437. TEXTURE: boolean;
  76438. constructor();
  76439. }
  76440. /**
  76441. * Class used to render controls with fluent desgin
  76442. */
  76443. export class FluentMaterial extends BABYLON.PushMaterial {
  76444. /**
  76445. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76446. */
  76447. innerGlowColorIntensity: number;
  76448. /**
  76449. * Gets or sets the inner glow color (white by default)
  76450. */
  76451. innerGlowColor: BABYLON.Color3;
  76452. /**
  76453. * Gets or sets alpha value (default is 1.0)
  76454. */
  76455. alpha: number;
  76456. /**
  76457. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76458. */
  76459. albedoColor: BABYLON.Color3;
  76460. /**
  76461. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76462. */
  76463. renderBorders: boolean;
  76464. /**
  76465. * Gets or sets border width (default is 0.5)
  76466. */
  76467. borderWidth: number;
  76468. /**
  76469. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76470. */
  76471. edgeSmoothingValue: number;
  76472. /**
  76473. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76474. */
  76475. borderMinValue: number;
  76476. /**
  76477. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76478. */
  76479. renderHoverLight: boolean;
  76480. /**
  76481. * Gets or sets the radius used to render the hover light (default is 1.0)
  76482. */
  76483. hoverRadius: number;
  76484. /**
  76485. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76486. */
  76487. hoverColor: BABYLON.Color4;
  76488. /**
  76489. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76490. */
  76491. hoverPosition: BABYLON.Vector3;
  76492. private _albedoTexture;
  76493. /** Gets or sets the texture to use for albedo color */
  76494. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76495. /**
  76496. * Creates a new Fluent material
  76497. * @param name defines the name of the material
  76498. * @param scene defines the hosting scene
  76499. */
  76500. constructor(name: string, scene: BABYLON.Scene);
  76501. needAlphaBlending(): boolean;
  76502. needAlphaTesting(): boolean;
  76503. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76504. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76505. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76506. getActiveTextures(): BABYLON.BaseTexture[];
  76507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76508. dispose(forceDisposeEffect?: boolean): void;
  76509. clone(name: string): FluentMaterial;
  76510. serialize(): any;
  76511. getClassName(): string;
  76512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  76513. }
  76514. }
  76515. declare module BABYLON.GUI {
  76516. /**
  76517. * Class used to create a holographic button in 3D
  76518. */
  76519. export class HolographicButton extends Button3D {
  76520. private _backPlate;
  76521. private _textPlate;
  76522. private _frontPlate;
  76523. private _text;
  76524. private _imageUrl;
  76525. private _shareMaterials;
  76526. private _frontMaterial;
  76527. private _backMaterial;
  76528. private _plateMaterial;
  76529. private _pickedPointObserver;
  76530. private _tooltipFade;
  76531. private _tooltipTextBlock;
  76532. private _tooltipTexture;
  76533. private _tooltipMesh;
  76534. private _tooltipHoverObserver;
  76535. private _tooltipOutObserver;
  76536. private _disposeTooltip;
  76537. /**
  76538. * Rendering ground id of all the mesh in the button
  76539. */
  76540. set renderingGroupId(id: number);
  76541. get renderingGroupId(): number;
  76542. /**
  76543. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  76544. */
  76545. set tooltipText(text: BABYLON.Nullable<string>);
  76546. get tooltipText(): BABYLON.Nullable<string>;
  76547. /**
  76548. * Gets or sets text for the button
  76549. */
  76550. get text(): string;
  76551. set text(value: string);
  76552. /**
  76553. * Gets or sets the image url for the button
  76554. */
  76555. get imageUrl(): string;
  76556. set imageUrl(value: string);
  76557. /**
  76558. * Gets the back material used by this button
  76559. */
  76560. get backMaterial(): FluentMaterial;
  76561. /**
  76562. * Gets the front material used by this button
  76563. */
  76564. get frontMaterial(): FluentMaterial;
  76565. /**
  76566. * Gets the plate material used by this button
  76567. */
  76568. get plateMaterial(): BABYLON.StandardMaterial;
  76569. /**
  76570. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  76571. */
  76572. get shareMaterials(): boolean;
  76573. /**
  76574. * Creates a new button
  76575. * @param name defines the control name
  76576. */
  76577. constructor(name?: string, shareMaterials?: boolean);
  76578. protected _getTypeName(): string;
  76579. private _rebuildContent;
  76580. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76581. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76582. private _createBackMaterial;
  76583. private _createFrontMaterial;
  76584. private _createPlateMaterial;
  76585. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  76586. /**
  76587. * Releases all associated resources
  76588. */
  76589. dispose(): void;
  76590. }
  76591. }
  76592. declare module BABYLON.GUI {
  76593. /**
  76594. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  76595. */
  76596. export class MeshButton3D extends Button3D {
  76597. /** @hidden */
  76598. protected _currentMesh: BABYLON.Mesh;
  76599. /**
  76600. * Creates a new 3D button based on a mesh
  76601. * @param mesh mesh to become a 3D button
  76602. * @param name defines the control name
  76603. */
  76604. constructor(mesh: BABYLON.Mesh, name?: string);
  76605. protected _getTypeName(): string;
  76606. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76607. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76608. }
  76609. }
  76610. declare module BABYLON.GUI {
  76611. /**
  76612. * Class used to create a container panel deployed on the surface of a plane
  76613. */
  76614. export class PlanePanel extends VolumeBasedPanel {
  76615. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76616. }
  76617. }
  76618. declare module BABYLON.GUI {
  76619. /**
  76620. * Class used to create a container panel where items get randomized planar mapping
  76621. */
  76622. export class ScatterPanel extends VolumeBasedPanel {
  76623. private _iteration;
  76624. /**
  76625. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  76626. */
  76627. get iteration(): BABYLON.float;
  76628. set iteration(value: BABYLON.float);
  76629. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76630. private _scatterMapping;
  76631. protected _finalProcessing(): void;
  76632. }
  76633. }
  76634. declare module BABYLON.GUI {
  76635. /**
  76636. * Class used to create a container panel deployed on the surface of a sphere
  76637. */
  76638. export class SpherePanel extends VolumeBasedPanel {
  76639. private _radius;
  76640. /**
  76641. * Gets or sets the radius of the sphere where to project controls (5 by default)
  76642. */
  76643. get radius(): BABYLON.float;
  76644. set radius(value: BABYLON.float);
  76645. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76646. private _sphericalMapping;
  76647. }
  76648. }
  76649. declare module BABYLON.GUI {
  76650. /**
  76651. * Class used to create a stack panel in 3D on XY plane
  76652. */
  76653. export class StackPanel3D extends Container3D {
  76654. private _isVertical;
  76655. /**
  76656. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  76657. */
  76658. get isVertical(): boolean;
  76659. set isVertical(value: boolean);
  76660. /**
  76661. * Gets or sets the distance between elements
  76662. */
  76663. margin: number;
  76664. /**
  76665. * Creates new StackPanel
  76666. * @param isVertical
  76667. */
  76668. constructor(isVertical?: boolean);
  76669. protected _arrangeChildren(): void;
  76670. }
  76671. }
  76672. declare module BABYLON {
  76673. /**
  76674. * Configuration for glTF validation
  76675. */
  76676. export interface IGLTFValidationConfiguration {
  76677. /**
  76678. * The url of the glTF validator.
  76679. */
  76680. url: string;
  76681. }
  76682. /**
  76683. * glTF validation
  76684. */
  76685. export class GLTFValidation {
  76686. /**
  76687. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  76688. */
  76689. static Configuration: IGLTFValidationConfiguration;
  76690. private static _LoadScriptPromise;
  76691. /**
  76692. * Validate a glTF asset using the glTF-Validator.
  76693. * @param data The JSON of a glTF or the array buffer of a binary glTF
  76694. * @param rootUrl The root url for the glTF
  76695. * @param fileName The file name for the glTF
  76696. * @param getExternalResource The callback to get external resources for the glTF validator
  76697. * @returns A promise that resolves with the glTF validation results once complete
  76698. */
  76699. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  76700. }
  76701. }
  76702. declare module BABYLON {
  76703. /**
  76704. * Mode that determines the coordinate system to use.
  76705. */
  76706. export enum GLTFLoaderCoordinateSystemMode {
  76707. /**
  76708. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  76709. */
  76710. AUTO = 0,
  76711. /**
  76712. * Sets the useRightHandedSystem flag on the scene.
  76713. */
  76714. FORCE_RIGHT_HANDED = 1
  76715. }
  76716. /**
  76717. * Mode that determines what animations will start.
  76718. */
  76719. export enum GLTFLoaderAnimationStartMode {
  76720. /**
  76721. * No animation will start.
  76722. */
  76723. NONE = 0,
  76724. /**
  76725. * The first animation will start.
  76726. */
  76727. FIRST = 1,
  76728. /**
  76729. * All animations will start.
  76730. */
  76731. ALL = 2
  76732. }
  76733. /**
  76734. * Interface that contains the data for the glTF asset.
  76735. */
  76736. export interface IGLTFLoaderData {
  76737. /**
  76738. * The object that represents the glTF JSON.
  76739. */
  76740. json: Object;
  76741. /**
  76742. * The BIN chunk of a binary glTF.
  76743. */
  76744. bin: Nullable<IDataBuffer>;
  76745. }
  76746. /**
  76747. * Interface for extending the loader.
  76748. */
  76749. export interface IGLTFLoaderExtension {
  76750. /**
  76751. * The name of this extension.
  76752. */
  76753. readonly name: string;
  76754. /**
  76755. * Defines whether this extension is enabled.
  76756. */
  76757. enabled: boolean;
  76758. /**
  76759. * Defines the order of this extension.
  76760. * The loader sorts the extensions using these values when loading.
  76761. */
  76762. order?: number;
  76763. }
  76764. /**
  76765. * Loader state.
  76766. */
  76767. export enum GLTFLoaderState {
  76768. /**
  76769. * The asset is loading.
  76770. */
  76771. LOADING = 0,
  76772. /**
  76773. * The asset is ready for rendering.
  76774. */
  76775. READY = 1,
  76776. /**
  76777. * The asset is completely loaded.
  76778. */
  76779. COMPLETE = 2
  76780. }
  76781. /** @hidden */
  76782. export interface IImportMeshAsyncOutput {
  76783. meshes: AbstractMesh[];
  76784. particleSystems: IParticleSystem[];
  76785. skeletons: Skeleton[];
  76786. animationGroups: AnimationGroup[];
  76787. lights: Light[];
  76788. transformNodes: TransformNode[];
  76789. }
  76790. /** @hidden */
  76791. export interface IGLTFLoader extends IDisposable {
  76792. readonly state: Nullable<GLTFLoaderState>;
  76793. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  76794. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  76795. }
  76796. /**
  76797. * File loader for loading glTF files into a scene.
  76798. */
  76799. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76800. /** @hidden */
  76801. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76802. /** @hidden */
  76803. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76804. /**
  76805. * Raised when the asset has been parsed
  76806. */
  76807. onParsedObservable: Observable<IGLTFLoaderData>;
  76808. private _onParsedObserver;
  76809. /**
  76810. * Raised when the asset has been parsed
  76811. */
  76812. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  76813. /**
  76814. * 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.
  76815. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  76816. * Defaults to true.
  76817. * @hidden
  76818. */
  76819. static IncrementalLoading: boolean;
  76820. /**
  76821. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  76822. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  76823. * @hidden
  76824. */
  76825. static HomogeneousCoordinates: boolean;
  76826. /**
  76827. * The coordinate system mode. Defaults to AUTO.
  76828. */
  76829. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  76830. /**
  76831. * The animation start mode. Defaults to FIRST.
  76832. */
  76833. animationStartMode: GLTFLoaderAnimationStartMode;
  76834. /**
  76835. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  76836. */
  76837. compileMaterials: boolean;
  76838. /**
  76839. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  76840. */
  76841. useClipPlane: boolean;
  76842. /**
  76843. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  76844. */
  76845. compileShadowGenerators: boolean;
  76846. /**
  76847. * Defines if the Alpha blended materials are only applied as coverage.
  76848. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  76849. * If true, no extra effects are applied to transparent pixels.
  76850. */
  76851. transparencyAsCoverage: boolean;
  76852. /**
  76853. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  76854. * Enabling will disable offline support and glTF validator.
  76855. * Defaults to false.
  76856. */
  76857. useRangeRequests: boolean;
  76858. /**
  76859. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  76860. */
  76861. createInstances: boolean;
  76862. /**
  76863. * Function called before loading a url referenced by the asset.
  76864. */
  76865. preprocessUrlAsync: (url: string) => Promise<string>;
  76866. /**
  76867. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76868. */
  76869. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  76870. private _onMeshLoadedObserver;
  76871. /**
  76872. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76873. */
  76874. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  76875. /**
  76876. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  76877. */
  76878. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  76879. private _onTextureLoadedObserver;
  76880. /**
  76881. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  76882. */
  76883. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  76884. /**
  76885. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  76886. */
  76887. readonly onMaterialLoadedObservable: Observable<Material>;
  76888. private _onMaterialLoadedObserver;
  76889. /**
  76890. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  76891. */
  76892. set onMaterialLoaded(callback: (material: Material) => void);
  76893. /**
  76894. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  76895. */
  76896. readonly onCameraLoadedObservable: Observable<Camera>;
  76897. private _onCameraLoadedObserver;
  76898. /**
  76899. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  76900. */
  76901. set onCameraLoaded(callback: (camera: Camera) => void);
  76902. /**
  76903. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  76904. * For assets with LODs, raised when all of the LODs are complete.
  76905. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76906. */
  76907. readonly onCompleteObservable: Observable<void>;
  76908. private _onCompleteObserver;
  76909. /**
  76910. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  76911. * For assets with LODs, raised when all of the LODs are complete.
  76912. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76913. */
  76914. set onComplete(callback: () => void);
  76915. /**
  76916. * Observable raised when an error occurs.
  76917. */
  76918. readonly onErrorObservable: Observable<any>;
  76919. private _onErrorObserver;
  76920. /**
  76921. * Callback raised when an error occurs.
  76922. */
  76923. set onError(callback: (reason: any) => void);
  76924. /**
  76925. * Observable raised after the loader is disposed.
  76926. */
  76927. readonly onDisposeObservable: Observable<void>;
  76928. private _onDisposeObserver;
  76929. /**
  76930. * Callback raised after the loader is disposed.
  76931. */
  76932. set onDispose(callback: () => void);
  76933. /**
  76934. * Observable raised after a loader extension is created.
  76935. * Set additional options for a loader extension in this event.
  76936. */
  76937. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  76938. private _onExtensionLoadedObserver;
  76939. /**
  76940. * Callback raised after a loader extension is created.
  76941. */
  76942. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  76943. /**
  76944. * Defines if the loader logging is enabled.
  76945. */
  76946. get loggingEnabled(): boolean;
  76947. set loggingEnabled(value: boolean);
  76948. /**
  76949. * Defines if the loader should capture performance counters.
  76950. */
  76951. get capturePerformanceCounters(): boolean;
  76952. set capturePerformanceCounters(value: boolean);
  76953. /**
  76954. * Defines if the loader should validate the asset.
  76955. */
  76956. validate: boolean;
  76957. /**
  76958. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  76959. */
  76960. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  76961. private _onValidatedObserver;
  76962. /**
  76963. * Callback raised after a loader extension is created.
  76964. */
  76965. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  76966. private _loader;
  76967. /**
  76968. * Name of the loader ("gltf")
  76969. */
  76970. name: string;
  76971. /** @hidden */
  76972. extensions: ISceneLoaderPluginExtensions;
  76973. /**
  76974. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  76975. */
  76976. dispose(): void;
  76977. /** @hidden */
  76978. _clear(): void;
  76979. /** @hidden */
  76980. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76981. /** @hidden */
  76982. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76983. /** @hidden */
  76984. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76985. meshes: AbstractMesh[];
  76986. particleSystems: IParticleSystem[];
  76987. skeletons: Skeleton[];
  76988. animationGroups: AnimationGroup[];
  76989. }>;
  76990. /** @hidden */
  76991. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76992. /** @hidden */
  76993. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76994. /** @hidden */
  76995. canDirectLoad(data: string): boolean;
  76996. /** @hidden */
  76997. directLoad(scene: Scene, data: string): any;
  76998. /**
  76999. * The callback that allows custom handling of the root url based on the response url.
  77000. * @param rootUrl the original root url
  77001. * @param responseURL the response url if available
  77002. * @returns the new root url
  77003. */
  77004. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77005. /** @hidden */
  77006. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77007. /**
  77008. * The loader state or null if the loader is not active.
  77009. */
  77010. get loaderState(): Nullable<GLTFLoaderState>;
  77011. /**
  77012. * Returns a promise that resolves when the asset is completely loaded.
  77013. * @returns a promise that resolves when the asset is completely loaded.
  77014. */
  77015. whenCompleteAsync(): Promise<void>;
  77016. private _validate;
  77017. private _getLoader;
  77018. private _parseJson;
  77019. private _unpackBinaryAsync;
  77020. private _unpackBinaryV1Async;
  77021. private _unpackBinaryV2Async;
  77022. private static _parseVersion;
  77023. private static _compareVersion;
  77024. private static readonly _logSpaces;
  77025. private _logIndentLevel;
  77026. private _loggingEnabled;
  77027. /** @hidden */
  77028. _log: (message: string) => void;
  77029. /** @hidden */
  77030. _logOpen(message: string): void;
  77031. /** @hidden */
  77032. _logClose(): void;
  77033. private _logEnabled;
  77034. private _logDisabled;
  77035. private _capturePerformanceCounters;
  77036. /** @hidden */
  77037. _startPerformanceCounter: (counterName: string) => void;
  77038. /** @hidden */
  77039. _endPerformanceCounter: (counterName: string) => void;
  77040. private _startPerformanceCounterEnabled;
  77041. private _startPerformanceCounterDisabled;
  77042. private _endPerformanceCounterEnabled;
  77043. private _endPerformanceCounterDisabled;
  77044. }
  77045. }
  77046. declare module BABYLON.GLTF1 {
  77047. /**
  77048. * Enums
  77049. * @hidden
  77050. */
  77051. export enum EComponentType {
  77052. BYTE = 5120,
  77053. UNSIGNED_BYTE = 5121,
  77054. SHORT = 5122,
  77055. UNSIGNED_SHORT = 5123,
  77056. FLOAT = 5126
  77057. }
  77058. /** @hidden */
  77059. export enum EShaderType {
  77060. FRAGMENT = 35632,
  77061. VERTEX = 35633
  77062. }
  77063. /** @hidden */
  77064. export enum EParameterType {
  77065. BYTE = 5120,
  77066. UNSIGNED_BYTE = 5121,
  77067. SHORT = 5122,
  77068. UNSIGNED_SHORT = 5123,
  77069. INT = 5124,
  77070. UNSIGNED_INT = 5125,
  77071. FLOAT = 5126,
  77072. FLOAT_VEC2 = 35664,
  77073. FLOAT_VEC3 = 35665,
  77074. FLOAT_VEC4 = 35666,
  77075. INT_VEC2 = 35667,
  77076. INT_VEC3 = 35668,
  77077. INT_VEC4 = 35669,
  77078. BOOL = 35670,
  77079. BOOL_VEC2 = 35671,
  77080. BOOL_VEC3 = 35672,
  77081. BOOL_VEC4 = 35673,
  77082. FLOAT_MAT2 = 35674,
  77083. FLOAT_MAT3 = 35675,
  77084. FLOAT_MAT4 = 35676,
  77085. SAMPLER_2D = 35678
  77086. }
  77087. /** @hidden */
  77088. export enum ETextureWrapMode {
  77089. CLAMP_TO_EDGE = 33071,
  77090. MIRRORED_REPEAT = 33648,
  77091. REPEAT = 10497
  77092. }
  77093. /** @hidden */
  77094. export enum ETextureFilterType {
  77095. NEAREST = 9728,
  77096. LINEAR = 9728,
  77097. NEAREST_MIPMAP_NEAREST = 9984,
  77098. LINEAR_MIPMAP_NEAREST = 9985,
  77099. NEAREST_MIPMAP_LINEAR = 9986,
  77100. LINEAR_MIPMAP_LINEAR = 9987
  77101. }
  77102. /** @hidden */
  77103. export enum ETextureFormat {
  77104. ALPHA = 6406,
  77105. RGB = 6407,
  77106. RGBA = 6408,
  77107. LUMINANCE = 6409,
  77108. LUMINANCE_ALPHA = 6410
  77109. }
  77110. /** @hidden */
  77111. export enum ECullingType {
  77112. FRONT = 1028,
  77113. BACK = 1029,
  77114. FRONT_AND_BACK = 1032
  77115. }
  77116. /** @hidden */
  77117. export enum EBlendingFunction {
  77118. ZERO = 0,
  77119. ONE = 1,
  77120. SRC_COLOR = 768,
  77121. ONE_MINUS_SRC_COLOR = 769,
  77122. DST_COLOR = 774,
  77123. ONE_MINUS_DST_COLOR = 775,
  77124. SRC_ALPHA = 770,
  77125. ONE_MINUS_SRC_ALPHA = 771,
  77126. DST_ALPHA = 772,
  77127. ONE_MINUS_DST_ALPHA = 773,
  77128. CONSTANT_COLOR = 32769,
  77129. ONE_MINUS_CONSTANT_COLOR = 32770,
  77130. CONSTANT_ALPHA = 32771,
  77131. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77132. SRC_ALPHA_SATURATE = 776
  77133. }
  77134. /** @hidden */
  77135. export interface IGLTFProperty {
  77136. extensions?: {
  77137. [key: string]: any;
  77138. };
  77139. extras?: Object;
  77140. }
  77141. /** @hidden */
  77142. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77143. name?: string;
  77144. }
  77145. /** @hidden */
  77146. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77147. bufferView: string;
  77148. byteOffset: number;
  77149. byteStride: number;
  77150. count: number;
  77151. type: string;
  77152. componentType: EComponentType;
  77153. max?: number[];
  77154. min?: number[];
  77155. name?: string;
  77156. }
  77157. /** @hidden */
  77158. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  77159. buffer: string;
  77160. byteOffset: number;
  77161. byteLength: number;
  77162. byteStride: number;
  77163. target?: number;
  77164. }
  77165. /** @hidden */
  77166. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  77167. uri: string;
  77168. byteLength?: number;
  77169. type?: string;
  77170. }
  77171. /** @hidden */
  77172. export interface IGLTFShader extends IGLTFChildRootProperty {
  77173. uri: string;
  77174. type: EShaderType;
  77175. }
  77176. /** @hidden */
  77177. export interface IGLTFProgram extends IGLTFChildRootProperty {
  77178. attributes: string[];
  77179. fragmentShader: string;
  77180. vertexShader: string;
  77181. }
  77182. /** @hidden */
  77183. export interface IGLTFTechniqueParameter {
  77184. type: number;
  77185. count?: number;
  77186. semantic?: string;
  77187. node?: string;
  77188. value?: number | boolean | string | Array<any>;
  77189. source?: string;
  77190. babylonValue?: any;
  77191. }
  77192. /** @hidden */
  77193. export interface IGLTFTechniqueCommonProfile {
  77194. lightingModel: string;
  77195. texcoordBindings: Object;
  77196. parameters?: Array<any>;
  77197. }
  77198. /** @hidden */
  77199. export interface IGLTFTechniqueStatesFunctions {
  77200. blendColor?: number[];
  77201. blendEquationSeparate?: number[];
  77202. blendFuncSeparate?: number[];
  77203. colorMask: boolean[];
  77204. cullFace: number[];
  77205. }
  77206. /** @hidden */
  77207. export interface IGLTFTechniqueStates {
  77208. enable: number[];
  77209. functions: IGLTFTechniqueStatesFunctions;
  77210. }
  77211. /** @hidden */
  77212. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77213. parameters: {
  77214. [key: string]: IGLTFTechniqueParameter;
  77215. };
  77216. program: string;
  77217. attributes: {
  77218. [key: string]: string;
  77219. };
  77220. uniforms: {
  77221. [key: string]: string;
  77222. };
  77223. states: IGLTFTechniqueStates;
  77224. }
  77225. /** @hidden */
  77226. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77227. technique?: string;
  77228. values: string[];
  77229. }
  77230. /** @hidden */
  77231. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77232. attributes: {
  77233. [key: string]: string;
  77234. };
  77235. indices: string;
  77236. material: string;
  77237. mode?: number;
  77238. }
  77239. /** @hidden */
  77240. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77241. primitives: IGLTFMeshPrimitive[];
  77242. }
  77243. /** @hidden */
  77244. export interface IGLTFImage extends IGLTFChildRootProperty {
  77245. uri: string;
  77246. }
  77247. /** @hidden */
  77248. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77249. magFilter?: number;
  77250. minFilter?: number;
  77251. wrapS?: number;
  77252. wrapT?: number;
  77253. }
  77254. /** @hidden */
  77255. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77256. sampler: string;
  77257. source: string;
  77258. format?: ETextureFormat;
  77259. internalFormat?: ETextureFormat;
  77260. target?: number;
  77261. type?: number;
  77262. babylonTexture?: Texture;
  77263. }
  77264. /** @hidden */
  77265. export interface IGLTFAmbienLight {
  77266. color?: number[];
  77267. }
  77268. /** @hidden */
  77269. export interface IGLTFDirectionalLight {
  77270. color?: number[];
  77271. }
  77272. /** @hidden */
  77273. export interface IGLTFPointLight {
  77274. color?: number[];
  77275. constantAttenuation?: number;
  77276. linearAttenuation?: number;
  77277. quadraticAttenuation?: number;
  77278. }
  77279. /** @hidden */
  77280. export interface IGLTFSpotLight {
  77281. color?: number[];
  77282. constantAttenuation?: number;
  77283. fallOfAngle?: number;
  77284. fallOffExponent?: number;
  77285. linearAttenuation?: number;
  77286. quadraticAttenuation?: number;
  77287. }
  77288. /** @hidden */
  77289. export interface IGLTFLight extends IGLTFChildRootProperty {
  77290. type: string;
  77291. }
  77292. /** @hidden */
  77293. export interface IGLTFCameraOrthographic {
  77294. xmag: number;
  77295. ymag: number;
  77296. zfar: number;
  77297. znear: number;
  77298. }
  77299. /** @hidden */
  77300. export interface IGLTFCameraPerspective {
  77301. aspectRatio: number;
  77302. yfov: number;
  77303. zfar: number;
  77304. znear: number;
  77305. }
  77306. /** @hidden */
  77307. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77308. type: string;
  77309. }
  77310. /** @hidden */
  77311. export interface IGLTFAnimationChannelTarget {
  77312. id: string;
  77313. path: string;
  77314. }
  77315. /** @hidden */
  77316. export interface IGLTFAnimationChannel {
  77317. sampler: string;
  77318. target: IGLTFAnimationChannelTarget;
  77319. }
  77320. /** @hidden */
  77321. export interface IGLTFAnimationSampler {
  77322. input: string;
  77323. output: string;
  77324. interpolation?: string;
  77325. }
  77326. /** @hidden */
  77327. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77328. channels?: IGLTFAnimationChannel[];
  77329. parameters?: {
  77330. [key: string]: string;
  77331. };
  77332. samplers?: {
  77333. [key: string]: IGLTFAnimationSampler;
  77334. };
  77335. }
  77336. /** @hidden */
  77337. export interface IGLTFNodeInstanceSkin {
  77338. skeletons: string[];
  77339. skin: string;
  77340. meshes: string[];
  77341. }
  77342. /** @hidden */
  77343. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77344. bindShapeMatrix: number[];
  77345. inverseBindMatrices: string;
  77346. jointNames: string[];
  77347. babylonSkeleton?: Skeleton;
  77348. }
  77349. /** @hidden */
  77350. export interface IGLTFNode extends IGLTFChildRootProperty {
  77351. camera?: string;
  77352. children: string[];
  77353. skin?: string;
  77354. jointName?: string;
  77355. light?: string;
  77356. matrix: number[];
  77357. mesh?: string;
  77358. meshes?: string[];
  77359. rotation?: number[];
  77360. scale?: number[];
  77361. translation?: number[];
  77362. babylonNode?: Node;
  77363. }
  77364. /** @hidden */
  77365. export interface IGLTFScene extends IGLTFChildRootProperty {
  77366. nodes: string[];
  77367. }
  77368. /** @hidden */
  77369. export interface IGLTFRuntime {
  77370. extensions: {
  77371. [key: string]: any;
  77372. };
  77373. accessors: {
  77374. [key: string]: IGLTFAccessor;
  77375. };
  77376. buffers: {
  77377. [key: string]: IGLTFBuffer;
  77378. };
  77379. bufferViews: {
  77380. [key: string]: IGLTFBufferView;
  77381. };
  77382. meshes: {
  77383. [key: string]: IGLTFMesh;
  77384. };
  77385. lights: {
  77386. [key: string]: IGLTFLight;
  77387. };
  77388. cameras: {
  77389. [key: string]: IGLTFCamera;
  77390. };
  77391. nodes: {
  77392. [key: string]: IGLTFNode;
  77393. };
  77394. images: {
  77395. [key: string]: IGLTFImage;
  77396. };
  77397. textures: {
  77398. [key: string]: IGLTFTexture;
  77399. };
  77400. shaders: {
  77401. [key: string]: IGLTFShader;
  77402. };
  77403. programs: {
  77404. [key: string]: IGLTFProgram;
  77405. };
  77406. samplers: {
  77407. [key: string]: IGLTFSampler;
  77408. };
  77409. techniques: {
  77410. [key: string]: IGLTFTechnique;
  77411. };
  77412. materials: {
  77413. [key: string]: IGLTFMaterial;
  77414. };
  77415. animations: {
  77416. [key: string]: IGLTFAnimation;
  77417. };
  77418. skins: {
  77419. [key: string]: IGLTFSkins;
  77420. };
  77421. currentScene?: Object;
  77422. scenes: {
  77423. [key: string]: IGLTFScene;
  77424. };
  77425. extensionsUsed: string[];
  77426. extensionsRequired?: string[];
  77427. buffersCount: number;
  77428. shaderscount: number;
  77429. scene: Scene;
  77430. rootUrl: string;
  77431. loadedBufferCount: number;
  77432. loadedBufferViews: {
  77433. [name: string]: ArrayBufferView;
  77434. };
  77435. loadedShaderCount: number;
  77436. importOnlyMeshes: boolean;
  77437. importMeshesNames?: string[];
  77438. dummyNodes: Node[];
  77439. forAssetContainer: boolean;
  77440. }
  77441. /** @hidden */
  77442. export interface INodeToRoot {
  77443. bone: Bone;
  77444. node: IGLTFNode;
  77445. id: string;
  77446. }
  77447. /** @hidden */
  77448. export interface IJointNode {
  77449. node: IGLTFNode;
  77450. id: string;
  77451. }
  77452. }
  77453. declare module BABYLON.GLTF1 {
  77454. /**
  77455. * Utils functions for GLTF
  77456. * @hidden
  77457. */
  77458. export class GLTFUtils {
  77459. /**
  77460. * Sets the given "parameter" matrix
  77461. * @param scene: the Scene object
  77462. * @param source: the source node where to pick the matrix
  77463. * @param parameter: the GLTF technique parameter
  77464. * @param uniformName: the name of the shader's uniform
  77465. * @param shaderMaterial: the shader material
  77466. */
  77467. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77468. /**
  77469. * Sets the given "parameter" matrix
  77470. * @param shaderMaterial: the shader material
  77471. * @param uniform: the name of the shader's uniform
  77472. * @param value: the value of the uniform
  77473. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77474. */
  77475. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77476. /**
  77477. * Returns the wrap mode of the texture
  77478. * @param mode: the mode value
  77479. */
  77480. static GetWrapMode(mode: number): number;
  77481. /**
  77482. * Returns the byte stride giving an accessor
  77483. * @param accessor: the GLTF accessor objet
  77484. */
  77485. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77486. /**
  77487. * Returns the texture filter mode giving a mode value
  77488. * @param mode: the filter mode value
  77489. */
  77490. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77491. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77492. /**
  77493. * Returns a buffer from its accessor
  77494. * @param gltfRuntime: the GLTF runtime
  77495. * @param accessor: the GLTF accessor
  77496. */
  77497. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77498. /**
  77499. * Decodes a buffer view into a string
  77500. * @param view: the buffer view
  77501. */
  77502. static DecodeBufferToText(view: ArrayBufferView): string;
  77503. /**
  77504. * Returns the default material of gltf. Related to
  77505. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77506. * @param scene: the Babylon.js scene
  77507. */
  77508. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77509. private static _DefaultMaterial;
  77510. }
  77511. }
  77512. declare module BABYLON.GLTF1 {
  77513. /**
  77514. * Implementation of the base glTF spec
  77515. * @hidden
  77516. */
  77517. export class GLTFLoaderBase {
  77518. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  77519. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77520. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  77521. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77522. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  77523. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77524. }
  77525. /**
  77526. * glTF V1 Loader
  77527. * @hidden
  77528. */
  77529. export class GLTFLoader implements IGLTFLoader {
  77530. static Extensions: {
  77531. [name: string]: GLTFLoaderExtension;
  77532. };
  77533. static RegisterExtension(extension: GLTFLoaderExtension): void;
  77534. state: Nullable<GLTFLoaderState>;
  77535. dispose(): void;
  77536. private _importMeshAsync;
  77537. /**
  77538. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  77539. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77540. * @param scene the scene the meshes should be added to
  77541. * @param forAssetContainer defines if the entities must be stored in the scene
  77542. * @param data gltf data containing information of the meshes in a loaded file
  77543. * @param rootUrl root url to load from
  77544. * @param onProgress event that fires when loading progress has occured
  77545. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77546. */
  77547. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  77548. private _loadAsync;
  77549. /**
  77550. * Imports all objects from a loaded gltf file and adds them to the scene
  77551. * @param scene the scene the objects should be added to
  77552. * @param data gltf data containing information of the meshes in a loaded file
  77553. * @param rootUrl root url to load from
  77554. * @param onProgress event that fires when loading progress has occured
  77555. * @returns a promise which completes when objects have been loaded to the scene
  77556. */
  77557. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  77558. private _loadShadersAsync;
  77559. private _loadBuffersAsync;
  77560. private _createNodes;
  77561. }
  77562. /** @hidden */
  77563. export abstract class GLTFLoaderExtension {
  77564. private _name;
  77565. constructor(name: string);
  77566. get name(): string;
  77567. /**
  77568. * Defines an override for loading the runtime
  77569. * Return true to stop further extensions from loading the runtime
  77570. */
  77571. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  77572. /**
  77573. * Defines an onverride for creating gltf runtime
  77574. * Return true to stop further extensions from creating the runtime
  77575. */
  77576. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  77577. /**
  77578. * Defines an override for loading buffers
  77579. * Return true to stop further extensions from loading this buffer
  77580. */
  77581. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  77582. /**
  77583. * Defines an override for loading texture buffers
  77584. * Return true to stop further extensions from loading this texture data
  77585. */
  77586. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77587. /**
  77588. * Defines an override for creating textures
  77589. * Return true to stop further extensions from loading this texture
  77590. */
  77591. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  77592. /**
  77593. * Defines an override for loading shader strings
  77594. * Return true to stop further extensions from loading this shader data
  77595. */
  77596. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77597. /**
  77598. * Defines an override for loading materials
  77599. * Return true to stop further extensions from loading this material
  77600. */
  77601. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77602. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  77603. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  77604. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77605. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77606. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  77607. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77608. private static LoadTextureBufferAsync;
  77609. private static CreateTextureAsync;
  77610. private static ApplyExtensions;
  77611. }
  77612. }
  77613. declare module BABYLON.GLTF1 {
  77614. /** @hidden */
  77615. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  77616. private _bin;
  77617. constructor();
  77618. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  77619. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77620. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77621. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77622. }
  77623. }
  77624. declare module BABYLON.GLTF1 {
  77625. /** @hidden */
  77626. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  77627. constructor();
  77628. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  77629. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77630. private _loadTexture;
  77631. }
  77632. }
  77633. declare module BABYLON.GLTF2.Loader {
  77634. /**
  77635. * Loader interface with an index field.
  77636. */
  77637. export interface IArrayItem {
  77638. /**
  77639. * The index of this item in the array.
  77640. */
  77641. index: number;
  77642. }
  77643. /**
  77644. * Loader interface with additional members.
  77645. */
  77646. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  77647. /** @hidden */
  77648. _data?: Promise<ArrayBufferView>;
  77649. /** @hidden */
  77650. _babylonVertexBuffer?: Promise<VertexBuffer>;
  77651. }
  77652. /**
  77653. * Loader interface with additional members.
  77654. */
  77655. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  77656. }
  77657. /** @hidden */
  77658. export interface _IAnimationSamplerData {
  77659. input: Float32Array;
  77660. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  77661. output: Float32Array;
  77662. }
  77663. /**
  77664. * Loader interface with additional members.
  77665. */
  77666. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  77667. /** @hidden */
  77668. _data?: Promise<_IAnimationSamplerData>;
  77669. }
  77670. /**
  77671. * Loader interface with additional members.
  77672. */
  77673. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  77674. channels: IAnimationChannel[];
  77675. samplers: IAnimationSampler[];
  77676. /** @hidden */
  77677. _babylonAnimationGroup?: AnimationGroup;
  77678. }
  77679. /**
  77680. * Loader interface with additional members.
  77681. */
  77682. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  77683. /** @hidden */
  77684. _data?: Promise<ArrayBufferView>;
  77685. }
  77686. /**
  77687. * Loader interface with additional members.
  77688. */
  77689. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  77690. /** @hidden */
  77691. _data?: Promise<ArrayBufferView>;
  77692. /** @hidden */
  77693. _babylonBuffer?: Promise<Buffer>;
  77694. }
  77695. /**
  77696. * Loader interface with additional members.
  77697. */
  77698. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  77699. }
  77700. /**
  77701. * Loader interface with additional members.
  77702. */
  77703. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  77704. /** @hidden */
  77705. _data?: Promise<ArrayBufferView>;
  77706. }
  77707. /**
  77708. * Loader interface with additional members.
  77709. */
  77710. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  77711. }
  77712. /**
  77713. * Loader interface with additional members.
  77714. */
  77715. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  77716. }
  77717. /**
  77718. * Loader interface with additional members.
  77719. */
  77720. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  77721. baseColorTexture?: ITextureInfo;
  77722. metallicRoughnessTexture?: ITextureInfo;
  77723. }
  77724. /**
  77725. * Loader interface with additional members.
  77726. */
  77727. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  77728. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77729. normalTexture?: IMaterialNormalTextureInfo;
  77730. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77731. emissiveTexture?: ITextureInfo;
  77732. /** @hidden */
  77733. _data?: {
  77734. [babylonDrawMode: number]: {
  77735. babylonMaterial: Material;
  77736. babylonMeshes: AbstractMesh[];
  77737. promise: Promise<void>;
  77738. };
  77739. };
  77740. }
  77741. /**
  77742. * Loader interface with additional members.
  77743. */
  77744. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  77745. primitives: IMeshPrimitive[];
  77746. }
  77747. /**
  77748. * Loader interface with additional members.
  77749. */
  77750. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  77751. /** @hidden */
  77752. _instanceData?: {
  77753. babylonSourceMesh: Mesh;
  77754. promise: Promise<any>;
  77755. };
  77756. }
  77757. /**
  77758. * Loader interface with additional members.
  77759. */
  77760. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  77761. /**
  77762. * The parent glTF node.
  77763. */
  77764. parent?: INode;
  77765. /** @hidden */
  77766. _babylonTransformNode?: TransformNode;
  77767. /** @hidden */
  77768. _primitiveBabylonMeshes?: AbstractMesh[];
  77769. /** @hidden */
  77770. _babylonBones?: Bone[];
  77771. /** @hidden */
  77772. _numMorphTargets?: number;
  77773. }
  77774. /** @hidden */
  77775. export interface _ISamplerData {
  77776. noMipMaps: boolean;
  77777. samplingMode: number;
  77778. wrapU: number;
  77779. wrapV: number;
  77780. }
  77781. /**
  77782. * Loader interface with additional members.
  77783. */
  77784. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  77785. /** @hidden */
  77786. _data?: _ISamplerData;
  77787. }
  77788. /**
  77789. * Loader interface with additional members.
  77790. */
  77791. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  77792. }
  77793. /**
  77794. * Loader interface with additional members.
  77795. */
  77796. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  77797. /** @hidden */
  77798. _data?: {
  77799. babylonSkeleton: Skeleton;
  77800. promise: Promise<void>;
  77801. };
  77802. }
  77803. /**
  77804. * Loader interface with additional members.
  77805. */
  77806. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  77807. }
  77808. /**
  77809. * Loader interface with additional members.
  77810. */
  77811. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  77812. }
  77813. /**
  77814. * Loader interface with additional members.
  77815. */
  77816. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  77817. accessors?: IAccessor[];
  77818. animations?: IAnimation[];
  77819. buffers?: IBuffer[];
  77820. bufferViews?: IBufferView[];
  77821. cameras?: ICamera[];
  77822. images?: IImage[];
  77823. materials?: IMaterial[];
  77824. meshes?: IMesh[];
  77825. nodes?: INode[];
  77826. samplers?: ISampler[];
  77827. scenes?: IScene[];
  77828. skins?: ISkin[];
  77829. textures?: ITexture[];
  77830. }
  77831. }
  77832. declare module BABYLON.GLTF2 {
  77833. /**
  77834. * Interface for a glTF loader extension.
  77835. */
  77836. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  77837. /**
  77838. * Called after the loader state changes to LOADING.
  77839. */
  77840. onLoading?(): void;
  77841. /**
  77842. * Called after the loader state changes to READY.
  77843. */
  77844. onReady?(): void;
  77845. /**
  77846. * Define this method to modify the default behavior when loading scenes.
  77847. * @param context The context when loading the asset
  77848. * @param scene The glTF scene property
  77849. * @returns A promise that resolves when the load is complete or null if not handled
  77850. */
  77851. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  77852. /**
  77853. * Define this method to modify the default behavior when loading nodes.
  77854. * @param context The context when loading the asset
  77855. * @param node The glTF node property
  77856. * @param assign A function called synchronously after parsing the glTF properties
  77857. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  77858. */
  77859. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77860. /**
  77861. * Define this method to modify the default behavior when loading cameras.
  77862. * @param context The context when loading the asset
  77863. * @param camera The glTF camera property
  77864. * @param assign A function called synchronously after parsing the glTF properties
  77865. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  77866. */
  77867. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77868. /**
  77869. * @hidden
  77870. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  77871. * @param context The context when loading the asset
  77872. * @param primitive The glTF mesh primitive property
  77873. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  77874. */
  77875. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77876. /**
  77877. * @hidden
  77878. * Define this method to modify the default behavior when loading data for mesh primitives.
  77879. * @param context The context when loading the asset
  77880. * @param name The mesh name when loading the asset
  77881. * @param node The glTF node when loading the asset
  77882. * @param mesh The glTF mesh when loading the asset
  77883. * @param primitive The glTF mesh primitive property
  77884. * @param assign A function called synchronously after parsing the glTF properties
  77885. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77886. */
  77887. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77888. /**
  77889. * @hidden
  77890. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  77891. * @param context The context when loading the asset
  77892. * @param material The glTF material property
  77893. * @param assign A function called synchronously after parsing the glTF properties
  77894. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  77895. */
  77896. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77897. /**
  77898. * Define this method to modify the default behavior when creating materials.
  77899. * @param context The context when loading the asset
  77900. * @param material The glTF material property
  77901. * @param babylonDrawMode The draw mode for the Babylon material
  77902. * @returns The Babylon material or null if not handled
  77903. */
  77904. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77905. /**
  77906. * Define this method to modify the default behavior when loading material properties.
  77907. * @param context The context when loading the asset
  77908. * @param material The glTF material property
  77909. * @param babylonMaterial The Babylon material
  77910. * @returns A promise that resolves when the load is complete or null if not handled
  77911. */
  77912. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77913. /**
  77914. * Define this method to modify the default behavior when loading texture infos.
  77915. * @param context The context when loading the asset
  77916. * @param textureInfo The glTF texture info property
  77917. * @param assign A function called synchronously after parsing the glTF properties
  77918. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77919. */
  77920. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77921. /**
  77922. * @hidden
  77923. * Define this method to modify the default behavior when loading textures.
  77924. * @param context The context when loading the asset
  77925. * @param texture The glTF texture property
  77926. * @param assign A function called synchronously after parsing the glTF properties
  77927. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77928. */
  77929. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77930. /**
  77931. * Define this method to modify the default behavior when loading animations.
  77932. * @param context The context when loading the asset
  77933. * @param animation The glTF animation property
  77934. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  77935. */
  77936. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77937. /**
  77938. * @hidden
  77939. * Define this method to modify the default behavior when loading skins.
  77940. * @param context The context when loading the asset
  77941. * @param node The glTF node property
  77942. * @param skin The glTF skin property
  77943. * @returns A promise that resolves when the load is complete or null if not handled
  77944. */
  77945. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  77946. /**
  77947. * @hidden
  77948. * Define this method to modify the default behavior when loading uris.
  77949. * @param context The context when loading the asset
  77950. * @param property The glTF property associated with the uri
  77951. * @param uri The uri to load
  77952. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77953. */
  77954. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77955. /**
  77956. * Define this method to modify the default behavior when loading buffer views.
  77957. * @param context The context when loading the asset
  77958. * @param bufferView The glTF buffer view property
  77959. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77960. */
  77961. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  77962. /**
  77963. * Define this method to modify the default behavior when loading buffers.
  77964. * @param context The context when loading the asset
  77965. * @param buffer The glTF buffer property
  77966. * @param byteOffset The byte offset to load
  77967. * @param byteLength The byte length to load
  77968. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77969. */
  77970. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77971. }
  77972. }
  77973. declare module BABYLON.GLTF2 {
  77974. /**
  77975. * Helper class for working with arrays when loading the glTF asset
  77976. */
  77977. export class ArrayItem {
  77978. /**
  77979. * Gets an item from the given array.
  77980. * @param context The context when loading the asset
  77981. * @param array The array to get the item from
  77982. * @param index The index to the array
  77983. * @returns The array item
  77984. */
  77985. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  77986. /**
  77987. * Assign an `index` field to each item of the given array.
  77988. * @param array The array of items
  77989. */
  77990. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  77991. }
  77992. /**
  77993. * The glTF 2.0 loader
  77994. */
  77995. export class GLTFLoader implements IGLTFLoader {
  77996. /** @hidden */
  77997. _completePromises: Promise<any>[];
  77998. /** @hidden */
  77999. _forAssetContainer: boolean;
  78000. /** Storage */
  78001. _babylonLights: Light[];
  78002. private _disposed;
  78003. private _parent;
  78004. private _state;
  78005. private _extensions;
  78006. private _rootUrl;
  78007. private _fileName;
  78008. private _uniqueRootUrl;
  78009. private _gltf;
  78010. private _bin;
  78011. private _babylonScene;
  78012. private _rootBabylonMesh;
  78013. private _defaultBabylonMaterialData;
  78014. private _progressCallback?;
  78015. private _requests;
  78016. private static _RegisteredExtensions;
  78017. /**
  78018. * The default glTF sampler.
  78019. */
  78020. static readonly DefaultSampler: ISampler;
  78021. /**
  78022. * Registers a loader extension.
  78023. * @param name The name of the loader extension.
  78024. * @param factory The factory function that creates the loader extension.
  78025. */
  78026. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78027. /**
  78028. * Unregisters a loader extension.
  78029. * @param name The name of the loader extension.
  78030. * @returns A boolean indicating whether the extension has been unregistered
  78031. */
  78032. static UnregisterExtension(name: string): boolean;
  78033. /**
  78034. * The loader state.
  78035. */
  78036. get state(): Nullable<GLTFLoaderState>;
  78037. /**
  78038. * The object that represents the glTF JSON.
  78039. */
  78040. get gltf(): IGLTF;
  78041. /**
  78042. * The BIN chunk of a binary glTF.
  78043. */
  78044. get bin(): Nullable<IDataBuffer>;
  78045. /**
  78046. * The parent file loader.
  78047. */
  78048. get parent(): GLTFFileLoader;
  78049. /**
  78050. * The Babylon scene when loading the asset.
  78051. */
  78052. get babylonScene(): Scene;
  78053. /**
  78054. * The root Babylon mesh when loading the asset.
  78055. */
  78056. get rootBabylonMesh(): Mesh;
  78057. /** @hidden */
  78058. constructor(parent: GLTFFileLoader);
  78059. /** @hidden */
  78060. dispose(): void;
  78061. /** @hidden */
  78062. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78063. /** @hidden */
  78064. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78065. private _loadAsync;
  78066. private _loadData;
  78067. private _setupData;
  78068. private _loadExtensions;
  78069. private _checkExtensions;
  78070. private _setState;
  78071. private _createRootNode;
  78072. /**
  78073. * Loads a glTF scene.
  78074. * @param context The context when loading the asset
  78075. * @param scene The glTF scene property
  78076. * @returns A promise that resolves when the load is complete
  78077. */
  78078. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78079. private _forEachPrimitive;
  78080. private _getMeshes;
  78081. private _getTransformNodes;
  78082. private _getSkeletons;
  78083. private _getAnimationGroups;
  78084. private _startAnimations;
  78085. /**
  78086. * Loads a glTF node.
  78087. * @param context The context when loading the asset
  78088. * @param node The glTF node property
  78089. * @param assign A function called synchronously after parsing the glTF properties
  78090. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78091. */
  78092. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78093. private _loadMeshAsync;
  78094. /**
  78095. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78096. * @param context The context when loading the asset
  78097. * @param name The mesh name when loading the asset
  78098. * @param node The glTF node when loading the asset
  78099. * @param mesh The glTF mesh when loading the asset
  78100. * @param primitive The glTF mesh primitive property
  78101. * @param assign A function called synchronously after parsing the glTF properties
  78102. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78103. */
  78104. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78105. private _loadVertexDataAsync;
  78106. private _createMorphTargets;
  78107. private _loadMorphTargetsAsync;
  78108. private _loadMorphTargetVertexDataAsync;
  78109. private static _LoadTransform;
  78110. private _loadSkinAsync;
  78111. private _loadBones;
  78112. private _loadBone;
  78113. private _loadSkinInverseBindMatricesDataAsync;
  78114. private _updateBoneMatrices;
  78115. private _getNodeMatrix;
  78116. /**
  78117. * Loads a glTF camera.
  78118. * @param context The context when loading the asset
  78119. * @param camera The glTF camera property
  78120. * @param assign A function called synchronously after parsing the glTF properties
  78121. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78122. */
  78123. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78124. private _loadAnimationsAsync;
  78125. /**
  78126. * Loads a glTF animation.
  78127. * @param context The context when loading the asset
  78128. * @param animation The glTF animation property
  78129. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78130. */
  78131. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78132. /**
  78133. * @hidden Loads a glTF animation channel.
  78134. * @param context The context when loading the asset
  78135. * @param animationContext The context of the animation when loading the asset
  78136. * @param animation The glTF animation property
  78137. * @param channel The glTF animation channel property
  78138. * @param babylonAnimationGroup The babylon animation group property
  78139. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78140. * @returns A void promise when the channel load is complete
  78141. */
  78142. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78143. private _loadAnimationSamplerAsync;
  78144. private _loadBufferAsync;
  78145. /**
  78146. * Loads a glTF buffer view.
  78147. * @param context The context when loading the asset
  78148. * @param bufferView The glTF buffer view property
  78149. * @returns A promise that resolves with the loaded data when the load is complete
  78150. */
  78151. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78152. private _loadAccessorAsync;
  78153. /** @hidden */
  78154. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78155. private _loadIndicesAccessorAsync;
  78156. private _loadVertexBufferViewAsync;
  78157. private _loadVertexAccessorAsync;
  78158. private _loadMaterialMetallicRoughnessPropertiesAsync;
  78159. /** @hidden */
  78160. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  78161. private _createDefaultMaterial;
  78162. /**
  78163. * Creates a Babylon material from a glTF material.
  78164. * @param context The context when loading the asset
  78165. * @param material The glTF material property
  78166. * @param babylonDrawMode The draw mode for the Babylon material
  78167. * @returns The Babylon material
  78168. */
  78169. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  78170. /**
  78171. * Loads properties from a glTF material into a Babylon material.
  78172. * @param context The context when loading the asset
  78173. * @param material The glTF material property
  78174. * @param babylonMaterial The Babylon material
  78175. * @returns A promise that resolves when the load is complete
  78176. */
  78177. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78178. /**
  78179. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78180. * @param context The context when loading the asset
  78181. * @param material The glTF material property
  78182. * @param babylonMaterial The Babylon material
  78183. * @returns A promise that resolves when the load is complete
  78184. */
  78185. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78186. /**
  78187. * Loads the alpha properties from a glTF material into a Babylon material.
  78188. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78189. * @param context The context when loading the asset
  78190. * @param material The glTF material property
  78191. * @param babylonMaterial The Babylon material
  78192. */
  78193. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78194. /**
  78195. * Loads a glTF texture info.
  78196. * @param context The context when loading the asset
  78197. * @param textureInfo The glTF texture info property
  78198. * @param assign A function called synchronously after parsing the glTF properties
  78199. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78200. */
  78201. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78202. /** @hidden */
  78203. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78204. /** @hidden */
  78205. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78206. private _loadSampler;
  78207. /**
  78208. * Loads a glTF image.
  78209. * @param context The context when loading the asset
  78210. * @param image The glTF image property
  78211. * @returns A promise that resolves with the loaded data when the load is complete
  78212. */
  78213. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78214. /**
  78215. * Loads a glTF uri.
  78216. * @param context The context when loading the asset
  78217. * @param property The glTF property associated with the uri
  78218. * @param uri The base64 or relative uri
  78219. * @returns A promise that resolves with the loaded data when the load is complete
  78220. */
  78221. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78222. private _onProgress;
  78223. /**
  78224. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78225. * @param babylonObject the Babylon object with metadata
  78226. * @param pointer the JSON pointer
  78227. */
  78228. static AddPointerMetadata(babylonObject: {
  78229. metadata: any;
  78230. }, pointer: string): void;
  78231. private static _GetTextureWrapMode;
  78232. private static _GetTextureSamplingMode;
  78233. private static _GetTypedArrayConstructor;
  78234. private static _GetTypedArray;
  78235. private static _GetNumComponents;
  78236. private static _ValidateUri;
  78237. private static _GetDrawMode;
  78238. private _compileMaterialsAsync;
  78239. private _compileShadowGeneratorsAsync;
  78240. private _forEachExtensions;
  78241. private _applyExtensions;
  78242. private _extensionsOnLoading;
  78243. private _extensionsOnReady;
  78244. private _extensionsLoadSceneAsync;
  78245. private _extensionsLoadNodeAsync;
  78246. private _extensionsLoadCameraAsync;
  78247. private _extensionsLoadVertexDataAsync;
  78248. private _extensionsLoadMeshPrimitiveAsync;
  78249. private _extensionsLoadMaterialAsync;
  78250. private _extensionsCreateMaterial;
  78251. private _extensionsLoadMaterialPropertiesAsync;
  78252. private _extensionsLoadTextureInfoAsync;
  78253. private _extensionsLoadTextureAsync;
  78254. private _extensionsLoadAnimationAsync;
  78255. private _extensionsLoadSkinAsync;
  78256. private _extensionsLoadUriAsync;
  78257. private _extensionsLoadBufferViewAsync;
  78258. private _extensionsLoadBufferAsync;
  78259. /**
  78260. * Helper method called by a loader extension to load an glTF extension.
  78261. * @param context The context when loading the asset
  78262. * @param property The glTF property to load the extension from
  78263. * @param extensionName The name of the extension to load
  78264. * @param actionAsync The action to run
  78265. * @returns The promise returned by actionAsync or null if the extension does not exist
  78266. */
  78267. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78268. /**
  78269. * Helper method called by a loader extension to load a glTF extra.
  78270. * @param context The context when loading the asset
  78271. * @param property The glTF property to load the extra from
  78272. * @param extensionName The name of the extension to load
  78273. * @param actionAsync The action to run
  78274. * @returns The promise returned by actionAsync or null if the extra does not exist
  78275. */
  78276. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78277. /**
  78278. * Checks for presence of an extension.
  78279. * @param name The name of the extension to check
  78280. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78281. */
  78282. isExtensionUsed(name: string): boolean;
  78283. /**
  78284. * Increments the indentation level and logs a message.
  78285. * @param message The message to log
  78286. */
  78287. logOpen(message: string): void;
  78288. /**
  78289. * Decrements the indentation level.
  78290. */
  78291. logClose(): void;
  78292. /**
  78293. * Logs a message
  78294. * @param message The message to log
  78295. */
  78296. log(message: string): void;
  78297. /**
  78298. * Starts a performance counter.
  78299. * @param counterName The name of the performance counter
  78300. */
  78301. startPerformanceCounter(counterName: string): void;
  78302. /**
  78303. * Ends a performance counter.
  78304. * @param counterName The name of the performance counter
  78305. */
  78306. endPerformanceCounter(counterName: string): void;
  78307. }
  78308. }
  78309. declare module BABYLON.GLTF2.Loader.Extensions {
  78310. /**
  78311. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78312. */
  78313. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78314. /**
  78315. * The name of this extension.
  78316. */
  78317. readonly name: string;
  78318. /**
  78319. * Defines whether this extension is enabled.
  78320. */
  78321. enabled: boolean;
  78322. private _loader;
  78323. private _lights?;
  78324. /** @hidden */
  78325. constructor(loader: GLTFLoader);
  78326. /** @hidden */
  78327. dispose(): void;
  78328. /** @hidden */
  78329. onLoading(): void;
  78330. /** @hidden */
  78331. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78332. private _loadLightAsync;
  78333. }
  78334. }
  78335. declare module BABYLON.GLTF2.Loader.Extensions {
  78336. /**
  78337. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78338. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78339. * !!! Experimental Extension Subject to Changes !!!
  78340. */
  78341. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78342. /**
  78343. * The name of this extension.
  78344. */
  78345. readonly name: string;
  78346. /**
  78347. * Defines whether this extension is enabled.
  78348. */
  78349. enabled: boolean;
  78350. private _loader;
  78351. /** @hidden */
  78352. constructor(loader: GLTFLoader);
  78353. /** @hidden */
  78354. dispose(): void;
  78355. /** @hidden */
  78356. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78357. }
  78358. }
  78359. declare module BABYLON.GLTF2.Loader.Extensions {
  78360. /**
  78361. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78362. */
  78363. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78364. /**
  78365. * The name of this extension.
  78366. */
  78367. readonly name: string;
  78368. /**
  78369. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78370. */
  78371. dracoCompression?: DracoCompression;
  78372. /**
  78373. * Defines whether this extension is enabled.
  78374. */
  78375. enabled: boolean;
  78376. private _loader;
  78377. /** @hidden */
  78378. constructor(loader: GLTFLoader);
  78379. /** @hidden */
  78380. dispose(): void;
  78381. /** @hidden */
  78382. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78383. }
  78384. }
  78385. declare module BABYLON.GLTF2.Loader.Extensions {
  78386. /**
  78387. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78388. */
  78389. export class KHR_lights implements IGLTFLoaderExtension {
  78390. /**
  78391. * The name of this extension.
  78392. */
  78393. readonly name: string;
  78394. /**
  78395. * Defines whether this extension is enabled.
  78396. */
  78397. enabled: boolean;
  78398. private _loader;
  78399. private _lights?;
  78400. /** @hidden */
  78401. constructor(loader: GLTFLoader);
  78402. /** @hidden */
  78403. dispose(): void;
  78404. /** @hidden */
  78405. onLoading(): void;
  78406. /** @hidden */
  78407. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78408. }
  78409. }
  78410. declare module BABYLON.GLTF2.Loader.Extensions {
  78411. /**
  78412. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78413. */
  78414. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78415. /**
  78416. * The name of this extension.
  78417. */
  78418. readonly name: string;
  78419. /**
  78420. * Defines whether this extension is enabled.
  78421. */
  78422. enabled: boolean;
  78423. /**
  78424. * Defines a number that determines the order the extensions are applied.
  78425. */
  78426. order: number;
  78427. private _loader;
  78428. /** @hidden */
  78429. constructor(loader: GLTFLoader);
  78430. /** @hidden */
  78431. dispose(): void;
  78432. /** @hidden */
  78433. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78434. private _loadSpecularGlossinessPropertiesAsync;
  78435. }
  78436. }
  78437. declare module BABYLON.GLTF2.Loader.Extensions {
  78438. /**
  78439. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78440. */
  78441. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78442. /**
  78443. * The name of this extension.
  78444. */
  78445. readonly name: string;
  78446. /**
  78447. * Defines whether this extension is enabled.
  78448. */
  78449. enabled: boolean;
  78450. /**
  78451. * Defines a number that determines the order the extensions are applied.
  78452. */
  78453. order: number;
  78454. private _loader;
  78455. /** @hidden */
  78456. constructor(loader: GLTFLoader);
  78457. /** @hidden */
  78458. dispose(): void;
  78459. /** @hidden */
  78460. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78461. private _loadUnlitPropertiesAsync;
  78462. }
  78463. }
  78464. declare module BABYLON.GLTF2.Loader.Extensions {
  78465. /**
  78466. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78467. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78468. * !!! Experimental Extension Subject to Changes !!!
  78469. */
  78470. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78471. /**
  78472. * The name of this extension.
  78473. */
  78474. readonly name: string;
  78475. /**
  78476. * Defines whether this extension is enabled.
  78477. */
  78478. enabled: boolean;
  78479. /**
  78480. * Defines a number that determines the order the extensions are applied.
  78481. */
  78482. order: number;
  78483. private _loader;
  78484. /** @hidden */
  78485. constructor(loader: GLTFLoader);
  78486. /** @hidden */
  78487. dispose(): void;
  78488. /** @hidden */
  78489. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78490. private _loadClearCoatPropertiesAsync;
  78491. }
  78492. }
  78493. declare module BABYLON.GLTF2.Loader.Extensions {
  78494. /**
  78495. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78496. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78497. * !!! Experimental Extension Subject to Changes !!!
  78498. */
  78499. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78500. /**
  78501. * The name of this extension.
  78502. */
  78503. readonly name: string;
  78504. /**
  78505. * Defines whether this extension is enabled.
  78506. */
  78507. enabled: boolean;
  78508. /**
  78509. * Defines a number that determines the order the extensions are applied.
  78510. */
  78511. order: number;
  78512. private _loader;
  78513. /** @hidden */
  78514. constructor(loader: GLTFLoader);
  78515. /** @hidden */
  78516. dispose(): void;
  78517. /** @hidden */
  78518. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78519. private _loadSheenPropertiesAsync;
  78520. }
  78521. }
  78522. declare module BABYLON.GLTF2.Loader.Extensions {
  78523. /**
  78524. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78525. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78526. * !!! Experimental Extension Subject to Changes !!!
  78527. */
  78528. export class KHR_materials_specular implements IGLTFLoaderExtension {
  78529. /**
  78530. * The name of this extension.
  78531. */
  78532. readonly name: string;
  78533. /**
  78534. * Defines whether this extension is enabled.
  78535. */
  78536. enabled: boolean;
  78537. /**
  78538. * Defines a number that determines the order the extensions are applied.
  78539. */
  78540. order: number;
  78541. private _loader;
  78542. /** @hidden */
  78543. constructor(loader: GLTFLoader);
  78544. /** @hidden */
  78545. dispose(): void;
  78546. /** @hidden */
  78547. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78548. private _loadSpecularPropertiesAsync;
  78549. }
  78550. }
  78551. declare module BABYLON.GLTF2.Loader.Extensions {
  78552. /**
  78553. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  78554. */
  78555. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  78556. /**
  78557. * The name of this extension.
  78558. */
  78559. readonly name: string;
  78560. /**
  78561. * Defines whether this extension is enabled.
  78562. */
  78563. enabled: boolean;
  78564. /** @hidden */
  78565. constructor(loader: GLTFLoader);
  78566. /** @hidden */
  78567. dispose(): void;
  78568. }
  78569. }
  78570. declare module BABYLON.GLTF2.Loader.Extensions {
  78571. /**
  78572. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  78573. * !!! Experimental Extension Subject to Changes !!!
  78574. */
  78575. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  78576. /** The name of this extension. */
  78577. readonly name: string;
  78578. /** Defines whether this extension is enabled. */
  78579. enabled: boolean;
  78580. private _loader;
  78581. /** @hidden */
  78582. constructor(loader: GLTFLoader);
  78583. /** @hidden */
  78584. dispose(): void;
  78585. /** @hidden */
  78586. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78587. }
  78588. }
  78589. declare module BABYLON.GLTF2.Loader.Extensions {
  78590. /**
  78591. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  78592. */
  78593. export class KHR_texture_transform implements IGLTFLoaderExtension {
  78594. /**
  78595. * The name of this extension.
  78596. */
  78597. readonly name: string;
  78598. /**
  78599. * Defines whether this extension is enabled.
  78600. */
  78601. enabled: boolean;
  78602. private _loader;
  78603. /** @hidden */
  78604. constructor(loader: GLTFLoader);
  78605. /** @hidden */
  78606. dispose(): void;
  78607. /** @hidden */
  78608. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78609. }
  78610. }
  78611. declare module BABYLON.GLTF2.Loader.Extensions {
  78612. /**
  78613. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  78614. */
  78615. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  78616. /**
  78617. * The name of this extension.
  78618. */
  78619. readonly name: string;
  78620. /**
  78621. * Defines whether this extension is enabled.
  78622. */
  78623. enabled: boolean;
  78624. private _loader;
  78625. private _clips;
  78626. private _emitters;
  78627. /** @hidden */
  78628. constructor(loader: GLTFLoader);
  78629. /** @hidden */
  78630. dispose(): void;
  78631. /** @hidden */
  78632. onLoading(): void;
  78633. /** @hidden */
  78634. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78635. /** @hidden */
  78636. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78637. /** @hidden */
  78638. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78639. private _loadClipAsync;
  78640. private _loadEmitterAsync;
  78641. private _getEventAction;
  78642. private _loadAnimationEventAsync;
  78643. }
  78644. }
  78645. declare module BABYLON.GLTF2.Loader.Extensions {
  78646. /**
  78647. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  78648. */
  78649. export class MSFT_lod implements IGLTFLoaderExtension {
  78650. /**
  78651. * The name of this extension.
  78652. */
  78653. readonly name: string;
  78654. /**
  78655. * Defines whether this extension is enabled.
  78656. */
  78657. enabled: boolean;
  78658. /**
  78659. * Defines a number that determines the order the extensions are applied.
  78660. */
  78661. order: number;
  78662. /**
  78663. * Maximum number of LODs to load, starting from the lowest LOD.
  78664. */
  78665. maxLODsToLoad: number;
  78666. /**
  78667. * Observable raised when all node LODs of one level are loaded.
  78668. * The event data is the index of the loaded LOD starting from zero.
  78669. * Dispose the loader to cancel the loading of the next level of LODs.
  78670. */
  78671. onNodeLODsLoadedObservable: Observable<number>;
  78672. /**
  78673. * Observable raised when all material LODs of one level are loaded.
  78674. * The event data is the index of the loaded LOD starting from zero.
  78675. * Dispose the loader to cancel the loading of the next level of LODs.
  78676. */
  78677. onMaterialLODsLoadedObservable: Observable<number>;
  78678. private _loader;
  78679. private _nodeIndexLOD;
  78680. private _nodeSignalLODs;
  78681. private _nodePromiseLODs;
  78682. private _materialIndexLOD;
  78683. private _materialSignalLODs;
  78684. private _materialPromiseLODs;
  78685. private _indexLOD;
  78686. private _bufferLODs;
  78687. /** @hidden */
  78688. constructor(loader: GLTFLoader);
  78689. /** @hidden */
  78690. dispose(): void;
  78691. /** @hidden */
  78692. onReady(): void;
  78693. /** @hidden */
  78694. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78695. /** @hidden */
  78696. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78697. /** @hidden */
  78698. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78699. /** @hidden */
  78700. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78701. /** @hidden */
  78702. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78703. private _loadBufferLOD;
  78704. /**
  78705. * Gets an array of LOD properties from lowest to highest.
  78706. */
  78707. private _getLODs;
  78708. private _disposeTransformNode;
  78709. private _disposeMaterials;
  78710. }
  78711. }
  78712. declare module BABYLON.GLTF2.Loader.Extensions {
  78713. /** @hidden */
  78714. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  78715. readonly name: string;
  78716. enabled: boolean;
  78717. private _loader;
  78718. constructor(loader: GLTFLoader);
  78719. dispose(): void;
  78720. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78721. }
  78722. }
  78723. declare module BABYLON.GLTF2.Loader.Extensions {
  78724. /** @hidden */
  78725. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  78726. readonly name: string;
  78727. enabled: boolean;
  78728. private _loader;
  78729. constructor(loader: GLTFLoader);
  78730. dispose(): void;
  78731. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78732. }
  78733. }
  78734. declare module BABYLON.GLTF2.Loader.Extensions {
  78735. /**
  78736. * Store glTF extras (if present) in BJS objects' metadata
  78737. */
  78738. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  78739. /**
  78740. * The name of this extension.
  78741. */
  78742. readonly name: string;
  78743. /**
  78744. * Defines whether this extension is enabled.
  78745. */
  78746. enabled: boolean;
  78747. private _loader;
  78748. private _assignExtras;
  78749. /** @hidden */
  78750. constructor(loader: GLTFLoader);
  78751. /** @hidden */
  78752. dispose(): void;
  78753. /** @hidden */
  78754. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78755. /** @hidden */
  78756. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78757. /** @hidden */
  78758. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78759. }
  78760. }
  78761. declare module BABYLON {
  78762. /**
  78763. * Class reading and parsing the MTL file bundled with the obj file.
  78764. */
  78765. export class MTLFileLoader {
  78766. /**
  78767. * Invert Y-Axis of referenced textures on load
  78768. */
  78769. static INVERT_TEXTURE_Y: boolean;
  78770. /**
  78771. * All material loaded from the mtl will be set here
  78772. */
  78773. materials: StandardMaterial[];
  78774. /**
  78775. * This function will read the mtl file and create each material described inside
  78776. * This function could be improve by adding :
  78777. * -some component missing (Ni, Tf...)
  78778. * -including the specific options available
  78779. *
  78780. * @param scene defines the scene the material will be created in
  78781. * @param data defines the mtl data to parse
  78782. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  78783. * @param forAssetContainer defines if the material should be registered in the scene
  78784. */
  78785. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  78786. /**
  78787. * Gets the texture for the material.
  78788. *
  78789. * If the material is imported from input file,
  78790. * We sanitize the url to ensure it takes the textre from aside the material.
  78791. *
  78792. * @param rootUrl The root url to load from
  78793. * @param value The value stored in the mtl
  78794. * @return The Texture
  78795. */
  78796. private static _getTexture;
  78797. }
  78798. }
  78799. declare module BABYLON {
  78800. /**
  78801. * Options for loading OBJ/MTL files
  78802. */
  78803. type MeshLoadOptions = {
  78804. /**
  78805. * Defines if UVs are optimized by default during load.
  78806. */
  78807. OptimizeWithUV: boolean;
  78808. /**
  78809. * Defines custom scaling of UV coordinates of loaded meshes.
  78810. */
  78811. UVScaling: Vector2;
  78812. /**
  78813. * Invert model on y-axis (does a model scaling inversion)
  78814. */
  78815. InvertY: boolean;
  78816. /**
  78817. * Invert Y-Axis of referenced textures on load
  78818. */
  78819. InvertTextureY: boolean;
  78820. /**
  78821. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78822. */
  78823. ImportVertexColors: boolean;
  78824. /**
  78825. * Compute the normals for the model, even if normals are present in the file.
  78826. */
  78827. ComputeNormals: boolean;
  78828. /**
  78829. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78830. */
  78831. SkipMaterials: boolean;
  78832. /**
  78833. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78834. */
  78835. MaterialLoadingFailsSilently: boolean;
  78836. };
  78837. /**
  78838. * OBJ file type loader.
  78839. * This is a babylon scene loader plugin.
  78840. */
  78841. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78842. /**
  78843. * Defines if UVs are optimized by default during load.
  78844. */
  78845. static OPTIMIZE_WITH_UV: boolean;
  78846. /**
  78847. * Invert model on y-axis (does a model scaling inversion)
  78848. */
  78849. static INVERT_Y: boolean;
  78850. /**
  78851. * Invert Y-Axis of referenced textures on load
  78852. */
  78853. static get INVERT_TEXTURE_Y(): boolean;
  78854. static set INVERT_TEXTURE_Y(value: boolean);
  78855. /**
  78856. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78857. */
  78858. static IMPORT_VERTEX_COLORS: boolean;
  78859. /**
  78860. * Compute the normals for the model, even if normals are present in the file.
  78861. */
  78862. static COMPUTE_NORMALS: boolean;
  78863. /**
  78864. * Defines custom scaling of UV coordinates of loaded meshes.
  78865. */
  78866. static UV_SCALING: Vector2;
  78867. /**
  78868. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78869. */
  78870. static SKIP_MATERIALS: boolean;
  78871. /**
  78872. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78873. *
  78874. * Defaults to true for backwards compatibility.
  78875. */
  78876. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  78877. /**
  78878. * Defines the name of the plugin.
  78879. */
  78880. name: string;
  78881. /**
  78882. * Defines the extension the plugin is able to load.
  78883. */
  78884. extensions: string;
  78885. /** @hidden */
  78886. obj: RegExp;
  78887. /** @hidden */
  78888. group: RegExp;
  78889. /** @hidden */
  78890. mtllib: RegExp;
  78891. /** @hidden */
  78892. usemtl: RegExp;
  78893. /** @hidden */
  78894. smooth: RegExp;
  78895. /** @hidden */
  78896. vertexPattern: RegExp;
  78897. /** @hidden */
  78898. normalPattern: RegExp;
  78899. /** @hidden */
  78900. uvPattern: RegExp;
  78901. /** @hidden */
  78902. facePattern1: RegExp;
  78903. /** @hidden */
  78904. facePattern2: RegExp;
  78905. /** @hidden */
  78906. facePattern3: RegExp;
  78907. /** @hidden */
  78908. facePattern4: RegExp;
  78909. /** @hidden */
  78910. facePattern5: RegExp;
  78911. private _forAssetContainer;
  78912. private _meshLoadOptions;
  78913. /**
  78914. * Creates loader for .OBJ files
  78915. *
  78916. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  78917. */
  78918. constructor(meshLoadOptions?: MeshLoadOptions);
  78919. private static get currentMeshLoadOptions();
  78920. /**
  78921. * Calls synchronously the MTL file attached to this obj.
  78922. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78923. * Without this function materials are not displayed in the first frame (but displayed after).
  78924. * In consequence it is impossible to get material information in your HTML file
  78925. *
  78926. * @param url The URL of the MTL file
  78927. * @param rootUrl
  78928. * @param onSuccess Callback function to be called when the MTL file is loaded
  78929. * @private
  78930. */
  78931. private _loadMTL;
  78932. /**
  78933. * Instantiates a OBJ file loader plugin.
  78934. * @returns the created plugin
  78935. */
  78936. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  78937. /**
  78938. * If the data string can be loaded directly.
  78939. *
  78940. * @param data string containing the file data
  78941. * @returns if the data can be loaded directly
  78942. */
  78943. canDirectLoad(data: string): boolean;
  78944. /**
  78945. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  78946. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78947. * @param scene the scene the meshes should be added to
  78948. * @param data the OBJ data to load
  78949. * @param rootUrl root url to load from
  78950. * @param onProgress event that fires when loading progress has occured
  78951. * @param fileName Defines the name of the file to load
  78952. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78953. */
  78954. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78955. meshes: AbstractMesh[];
  78956. particleSystems: IParticleSystem[];
  78957. skeletons: Skeleton[];
  78958. animationGroups: AnimationGroup[];
  78959. }>;
  78960. /**
  78961. * Imports all objects from the loaded OBJ data and adds them to the scene
  78962. * @param scene the scene the objects should be added to
  78963. * @param data the OBJ data to load
  78964. * @param rootUrl root url to load from
  78965. * @param onProgress event that fires when loading progress has occured
  78966. * @param fileName Defines the name of the file to load
  78967. * @returns a promise which completes when objects have been loaded to the scene
  78968. */
  78969. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78970. /**
  78971. * Load into an asset container.
  78972. * @param scene The scene to load into
  78973. * @param data The data to import
  78974. * @param rootUrl The root url for scene and resources
  78975. * @param onProgress The callback when the load progresses
  78976. * @param fileName Defines the name of the file to load
  78977. * @returns The loaded asset container
  78978. */
  78979. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78980. /**
  78981. * Read the OBJ file and create an Array of meshes.
  78982. * Each mesh contains all information given by the OBJ and the MTL file.
  78983. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  78984. *
  78985. * @param meshesNames
  78986. * @param scene Scene The scene where are displayed the data
  78987. * @param data String The content of the obj file
  78988. * @param rootUrl String The path to the folder
  78989. * @returns Array<AbstractMesh>
  78990. * @private
  78991. */
  78992. private _parseSolid;
  78993. }
  78994. }
  78995. declare module BABYLON {
  78996. /**
  78997. * STL file type loader.
  78998. * This is a babylon scene loader plugin.
  78999. */
  79000. export class STLFileLoader implements ISceneLoaderPlugin {
  79001. /** @hidden */
  79002. solidPattern: RegExp;
  79003. /** @hidden */
  79004. facetsPattern: RegExp;
  79005. /** @hidden */
  79006. normalPattern: RegExp;
  79007. /** @hidden */
  79008. vertexPattern: RegExp;
  79009. /**
  79010. * Defines the name of the plugin.
  79011. */
  79012. name: string;
  79013. /**
  79014. * Defines the extensions the stl loader is able to load.
  79015. * force data to come in as an ArrayBuffer
  79016. * we'll convert to string if it looks like it's an ASCII .stl
  79017. */
  79018. extensions: ISceneLoaderPluginExtensions;
  79019. /**
  79020. * Import meshes into a scene.
  79021. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79022. * @param scene The scene to import into
  79023. * @param data The data to import
  79024. * @param rootUrl The root url for scene and resources
  79025. * @param meshes The meshes array to import into
  79026. * @param particleSystems The particle systems array to import into
  79027. * @param skeletons The skeletons array to import into
  79028. * @param onError The callback when import fails
  79029. * @returns True if successful or false otherwise
  79030. */
  79031. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79032. /**
  79033. * Load into a scene.
  79034. * @param scene The scene to load into
  79035. * @param data The data to import
  79036. * @param rootUrl The root url for scene and resources
  79037. * @param onError The callback when import fails
  79038. * @returns true if successful or false otherwise
  79039. */
  79040. load(scene: Scene, data: any, rootUrl: string): boolean;
  79041. /**
  79042. * Load into an asset container.
  79043. * @param scene The scene to load into
  79044. * @param data The data to import
  79045. * @param rootUrl The root url for scene and resources
  79046. * @param onError The callback when import fails
  79047. * @returns The loaded asset container
  79048. */
  79049. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79050. private _isBinary;
  79051. private _parseBinary;
  79052. private _parseASCII;
  79053. }
  79054. }
  79055. declare module BABYLON {
  79056. /**
  79057. * Class for generating OBJ data from a Babylon scene.
  79058. */
  79059. export class OBJExport {
  79060. /**
  79061. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79062. * @param mesh defines the list of meshes to serialize
  79063. * @param materials defines if materials should be exported
  79064. * @param matlibname defines the name of the associated mtl file
  79065. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79066. * @returns the OBJ content
  79067. */
  79068. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79069. /**
  79070. * Exports the material(s) of a mesh in .MTL file format (text)
  79071. * @param mesh defines the mesh to extract the material from
  79072. * @returns the mtl content
  79073. */
  79074. static MTL(mesh: Mesh): string;
  79075. }
  79076. }
  79077. declare module BABYLON {
  79078. /** @hidden */
  79079. export var __IGLTFExporterExtension: number;
  79080. /**
  79081. * Interface for extending the exporter
  79082. * @hidden
  79083. */
  79084. export interface IGLTFExporterExtension {
  79085. /**
  79086. * The name of this extension
  79087. */
  79088. readonly name: string;
  79089. /**
  79090. * Defines whether this extension is enabled
  79091. */
  79092. enabled: boolean;
  79093. /**
  79094. * Defines whether this extension is required
  79095. */
  79096. required: boolean;
  79097. }
  79098. }
  79099. declare module BABYLON.GLTF2.Exporter {
  79100. /** @hidden */
  79101. export var __IGLTFExporterExtensionV2: number;
  79102. /**
  79103. * Interface for a glTF exporter extension
  79104. * @hidden
  79105. */
  79106. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79107. /**
  79108. * Define this method to modify the default behavior before exporting a texture
  79109. * @param context The context when loading the asset
  79110. * @param babylonTexture The Babylon.js texture
  79111. * @param mimeType The mime-type of the generated image
  79112. * @returns A promise that resolves with the exported texture
  79113. */
  79114. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79115. /**
  79116. * Define this method to get notified when a texture info is created
  79117. * @param context The context when loading the asset
  79118. * @param textureInfo The glTF texture info
  79119. * @param babylonTexture The Babylon.js texture
  79120. */
  79121. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79122. /**
  79123. * Define this method to modify the default behavior when exporting texture info
  79124. * @param context The context when loading the asset
  79125. * @param meshPrimitive glTF mesh primitive
  79126. * @param babylonSubMesh Babylon submesh
  79127. * @param binaryWriter glTF serializer binary writer instance
  79128. * @returns nullable IMeshPrimitive promise
  79129. */
  79130. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  79131. /**
  79132. * Define this method to modify the default behavior when exporting a node
  79133. * @param context The context when exporting the node
  79134. * @param node glTF node
  79135. * @param babylonNode BabylonJS node
  79136. * @returns nullable INode promise
  79137. */
  79138. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79139. [key: number]: number;
  79140. }): Promise<Nullable<INode>>;
  79141. /**
  79142. * Define this method to modify the default behavior when exporting a material
  79143. * @param material glTF material
  79144. * @param babylonMaterial BabylonJS material
  79145. * @returns nullable IMaterial promise
  79146. */
  79147. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  79148. /**
  79149. * Define this method to return additional textures to export from a material
  79150. * @param material glTF material
  79151. * @param babylonMaterial BabylonJS material
  79152. * @returns List of textures
  79153. */
  79154. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  79155. /** Gets a boolean indicating that this extension was used */
  79156. wasUsed: boolean;
  79157. /** Gets a boolean indicating that this extension is required for the file to work */
  79158. required: boolean;
  79159. /**
  79160. * Called after the exporter state changes to EXPORTING
  79161. */
  79162. onExporting?(): void;
  79163. }
  79164. }
  79165. declare module BABYLON.GLTF2.Exporter {
  79166. /**
  79167. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  79168. * @hidden
  79169. */
  79170. export class _GLTFMaterialExporter {
  79171. /**
  79172. * Represents the dielectric specular values for R, G and B
  79173. */
  79174. private static readonly _DielectricSpecular;
  79175. /**
  79176. * Allows the maximum specular power to be defined for material calculations
  79177. */
  79178. private static readonly _MaxSpecularPower;
  79179. /**
  79180. * Mapping to store textures
  79181. */
  79182. private _textureMap;
  79183. /**
  79184. * Numeric tolerance value
  79185. */
  79186. private static readonly _Epsilon;
  79187. /**
  79188. * Reference to the glTF Exporter
  79189. */
  79190. private _exporter;
  79191. constructor(exporter: _Exporter);
  79192. /**
  79193. * Specifies if two colors are approximately equal in value
  79194. * @param color1 first color to compare to
  79195. * @param color2 second color to compare to
  79196. * @param epsilon threshold value
  79197. */
  79198. private static FuzzyEquals;
  79199. /**
  79200. * Gets the materials from a Babylon scene and converts them to glTF materials
  79201. * @param scene babylonjs scene
  79202. * @param mimeType texture mime type
  79203. * @param images array of images
  79204. * @param textures array of textures
  79205. * @param materials array of materials
  79206. * @param imageData mapping of texture names to base64 textures
  79207. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79208. */
  79209. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79210. /**
  79211. * Makes a copy of the glTF material without the texture parameters
  79212. * @param originalMaterial original glTF material
  79213. * @returns glTF material without texture parameters
  79214. */
  79215. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79216. /**
  79217. * Specifies if the material has any texture parameters present
  79218. * @param material glTF Material
  79219. * @returns boolean specifying if texture parameters are present
  79220. */
  79221. _hasTexturesPresent(material: IMaterial): boolean;
  79222. /**
  79223. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79224. * @param babylonStandardMaterial
  79225. * @returns glTF Metallic Roughness Material representation
  79226. */
  79227. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79228. /**
  79229. * Computes the metallic factor
  79230. * @param diffuse diffused value
  79231. * @param specular specular value
  79232. * @param oneMinusSpecularStrength one minus the specular strength
  79233. * @returns metallic value
  79234. */
  79235. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79236. /**
  79237. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79238. * @param glTFMaterial glTF material
  79239. * @param babylonMaterial Babylon material
  79240. */
  79241. private static _SetAlphaMode;
  79242. /**
  79243. * Converts a Babylon Standard Material to a glTF Material
  79244. * @param babylonStandardMaterial BJS Standard Material
  79245. * @param mimeType mime type to use for the textures
  79246. * @param images array of glTF image interfaces
  79247. * @param textures array of glTF texture interfaces
  79248. * @param materials array of glTF material interfaces
  79249. * @param imageData map of image file name to data
  79250. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79251. */
  79252. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79253. private _finishMaterial;
  79254. /**
  79255. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79256. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79257. * @param mimeType mime type to use for the textures
  79258. * @param images array of glTF image interfaces
  79259. * @param textures array of glTF texture interfaces
  79260. * @param materials array of glTF material interfaces
  79261. * @param imageData map of image file name to data
  79262. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79263. */
  79264. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79265. /**
  79266. * Converts an image typed array buffer to a base64 image
  79267. * @param buffer typed array buffer
  79268. * @param width width of the image
  79269. * @param height height of the image
  79270. * @param mimeType mimetype of the image
  79271. * @returns base64 image string
  79272. */
  79273. private _createBase64FromCanvasAsync;
  79274. /**
  79275. * Generates a white texture based on the specified width and height
  79276. * @param width width of the texture in pixels
  79277. * @param height height of the texture in pixels
  79278. * @param scene babylonjs scene
  79279. * @returns white texture
  79280. */
  79281. private _createWhiteTexture;
  79282. /**
  79283. * 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
  79284. * @param texture1 first texture to resize
  79285. * @param texture2 second texture to resize
  79286. * @param scene babylonjs scene
  79287. * @returns resized textures or null
  79288. */
  79289. private _resizeTexturesToSameDimensions;
  79290. /**
  79291. * Converts an array of pixels to a Float32Array
  79292. * Throws an error if the pixel format is not supported
  79293. * @param pixels - array buffer containing pixel values
  79294. * @returns Float32 of pixels
  79295. */
  79296. private _convertPixelArrayToFloat32;
  79297. /**
  79298. * Convert Specular Glossiness Textures to Metallic Roughness
  79299. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79300. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79301. * @param diffuseTexture texture used to store diffuse information
  79302. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79303. * @param factors specular glossiness material factors
  79304. * @param mimeType the mime type to use for the texture
  79305. * @returns pbr metallic roughness interface or null
  79306. */
  79307. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79308. /**
  79309. * Converts specular glossiness material properties to metallic roughness
  79310. * @param specularGlossiness interface with specular glossiness material properties
  79311. * @returns interface with metallic roughness material properties
  79312. */
  79313. private _convertSpecularGlossinessToMetallicRoughness;
  79314. /**
  79315. * Calculates the surface reflectance, independent of lighting conditions
  79316. * @param color Color source to calculate brightness from
  79317. * @returns number representing the perceived brightness, or zero if color is undefined
  79318. */
  79319. private _getPerceivedBrightness;
  79320. /**
  79321. * Returns the maximum color component value
  79322. * @param color
  79323. * @returns maximum color component value, or zero if color is null or undefined
  79324. */
  79325. private _getMaxComponent;
  79326. /**
  79327. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79328. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79329. * @param mimeType mime type to use for the textures
  79330. * @param images array of glTF image interfaces
  79331. * @param textures array of glTF texture interfaces
  79332. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79333. * @param imageData map of image file name to data
  79334. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79335. * @returns glTF PBR Metallic Roughness factors
  79336. */
  79337. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79338. private _getGLTFTextureSampler;
  79339. private _getGLTFTextureWrapMode;
  79340. private _getGLTFTextureWrapModesSampler;
  79341. /**
  79342. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79343. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79344. * @param mimeType mime type to use for the textures
  79345. * @param images array of glTF image interfaces
  79346. * @param textures array of glTF texture interfaces
  79347. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79348. * @param imageData map of image file name to data
  79349. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79350. * @returns glTF PBR Metallic Roughness factors
  79351. */
  79352. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79353. /**
  79354. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79355. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79356. * @param mimeType mime type to use for the textures
  79357. * @param images array of glTF image interfaces
  79358. * @param textures array of glTF texture interfaces
  79359. * @param materials array of glTF material interfaces
  79360. * @param imageData map of image file name to data
  79361. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79362. */
  79363. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79364. private setMetallicRoughnessPbrMaterial;
  79365. private getPixelsFromTexture;
  79366. /**
  79367. * Extracts a texture from a Babylon texture into file data and glTF data
  79368. * @param babylonTexture Babylon texture to extract
  79369. * @param mimeType Mime Type of the babylonTexture
  79370. * @return glTF texture info, or null if the texture format is not supported
  79371. */
  79372. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79373. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79374. /**
  79375. * Builds a texture from base64 string
  79376. * @param base64Texture base64 texture string
  79377. * @param baseTextureName Name to use for the texture
  79378. * @param mimeType image mime type for the texture
  79379. * @param images array of images
  79380. * @param textures array of textures
  79381. * @param imageData map of image data
  79382. * @returns glTF texture info, or null if the texture format is not supported
  79383. */
  79384. private _getTextureInfoFromBase64;
  79385. }
  79386. }
  79387. declare module BABYLON {
  79388. /**
  79389. * Class for holding and downloading glTF file data
  79390. */
  79391. export class GLTFData {
  79392. /**
  79393. * Object which contains the file name as the key and its data as the value
  79394. */
  79395. glTFFiles: {
  79396. [fileName: string]: string | Blob;
  79397. };
  79398. /**
  79399. * Initializes the glTF file object
  79400. */
  79401. constructor();
  79402. /**
  79403. * Downloads the glTF data as files based on their names and data
  79404. */
  79405. downloadFiles(): void;
  79406. }
  79407. }
  79408. declare module BABYLON {
  79409. /**
  79410. * Holds a collection of exporter options and parameters
  79411. */
  79412. export interface IExportOptions {
  79413. /**
  79414. * Function which indicates whether a babylon node should be exported or not
  79415. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79416. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79417. */
  79418. shouldExportNode?(node: Node): boolean;
  79419. /**
  79420. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79421. * @param metadata source metadata to read from
  79422. * @returns the data to store to glTF node extras
  79423. */
  79424. metadataSelector?(metadata: any): any;
  79425. /**
  79426. * The sample rate to bake animation curves
  79427. */
  79428. animationSampleRate?: number;
  79429. /**
  79430. * Begin serialization without waiting for the scene to be ready
  79431. */
  79432. exportWithoutWaitingForScene?: boolean;
  79433. /**
  79434. * Indicates if coordinate system swapping root nodes should be included in export
  79435. */
  79436. includeCoordinateSystemConversionNodes?: boolean;
  79437. }
  79438. /**
  79439. * Class for generating glTF data from a Babylon scene.
  79440. */
  79441. export class GLTF2Export {
  79442. /**
  79443. * Exports the geometry of the scene to .gltf file format asynchronously
  79444. * @param scene Babylon scene with scene hierarchy information
  79445. * @param filePrefix File prefix to use when generating the glTF file
  79446. * @param options Exporter options
  79447. * @returns Returns an object with a .gltf file and associates texture names
  79448. * as keys and their data and paths as values
  79449. */
  79450. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79451. private static _PreExportAsync;
  79452. private static _PostExportAsync;
  79453. /**
  79454. * Exports the geometry of the scene to .glb file format asychronously
  79455. * @param scene Babylon scene with scene hierarchy information
  79456. * @param filePrefix File prefix to use when generating glb file
  79457. * @param options Exporter options
  79458. * @returns Returns an object with a .glb filename as key and data as value
  79459. */
  79460. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79461. }
  79462. }
  79463. declare module BABYLON.GLTF2.Exporter {
  79464. /**
  79465. * @hidden
  79466. */
  79467. export class _GLTFUtilities {
  79468. /**
  79469. * Creates a buffer view based on the supplied arguments
  79470. * @param bufferIndex index value of the specified buffer
  79471. * @param byteOffset byte offset value
  79472. * @param byteLength byte length of the bufferView
  79473. * @param byteStride byte distance between conequential elements
  79474. * @param name name of the buffer view
  79475. * @returns bufferView for glTF
  79476. */
  79477. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79478. /**
  79479. * Creates an accessor based on the supplied arguments
  79480. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  79481. * @param name The name of the accessor
  79482. * @param type The type of the accessor
  79483. * @param componentType The datatype of components in the attribute
  79484. * @param count The number of attributes referenced by this accessor
  79485. * @param byteOffset The offset relative to the start of the bufferView in bytes
  79486. * @param min Minimum value of each component in this attribute
  79487. * @param max Maximum value of each component in this attribute
  79488. * @returns accessor for glTF
  79489. */
  79490. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  79491. /**
  79492. * Calculates the minimum and maximum values of an array of position floats
  79493. * @param positions Positions array of a mesh
  79494. * @param vertexStart Starting vertex offset to calculate min and max values
  79495. * @param vertexCount Number of vertices to check for min and max values
  79496. * @returns min number array and max number array
  79497. */
  79498. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  79499. min: number[];
  79500. max: number[];
  79501. };
  79502. /**
  79503. * Converts a new right-handed Vector3
  79504. * @param vector vector3 array
  79505. * @returns right-handed Vector3
  79506. */
  79507. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  79508. /**
  79509. * Converts a Vector3 to right-handed
  79510. * @param vector Vector3 to convert to right-handed
  79511. */
  79512. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  79513. /**
  79514. * Converts a three element number array to right-handed
  79515. * @param vector number array to convert to right-handed
  79516. */
  79517. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  79518. /**
  79519. * Converts a new right-handed Vector3
  79520. * @param vector vector3 array
  79521. * @returns right-handed Vector3
  79522. */
  79523. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  79524. /**
  79525. * Converts a Vector3 to right-handed
  79526. * @param vector Vector3 to convert to right-handed
  79527. */
  79528. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  79529. /**
  79530. * Converts a three element number array to right-handed
  79531. * @param vector number array to convert to right-handed
  79532. */
  79533. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  79534. /**
  79535. * Converts a Vector4 to right-handed
  79536. * @param vector Vector4 to convert to right-handed
  79537. */
  79538. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  79539. /**
  79540. * Converts a Vector4 to right-handed
  79541. * @param vector Vector4 to convert to right-handed
  79542. */
  79543. static _GetRightHandedArray4FromRef(vector: number[]): void;
  79544. /**
  79545. * Converts a Quaternion to right-handed
  79546. * @param quaternion Source quaternion to convert to right-handed
  79547. */
  79548. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  79549. /**
  79550. * Converts a Quaternion to right-handed
  79551. * @param quaternion Source quaternion to convert to right-handed
  79552. */
  79553. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  79554. static _NormalizeTangentFromRef(tangent: Vector4): void;
  79555. }
  79556. }
  79557. declare module BABYLON.GLTF2.Exporter {
  79558. /**
  79559. * Converts Babylon Scene into glTF 2.0.
  79560. * @hidden
  79561. */
  79562. export class _Exporter {
  79563. /**
  79564. * Stores the glTF to export
  79565. */
  79566. _glTF: IGLTF;
  79567. /**
  79568. * Stores all generated buffer views, which represents views into the main glTF buffer data
  79569. */
  79570. _bufferViews: IBufferView[];
  79571. /**
  79572. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  79573. */
  79574. _accessors: IAccessor[];
  79575. /**
  79576. * Stores all the generated nodes, which contains transform and/or mesh information per node
  79577. */
  79578. _nodes: INode[];
  79579. /**
  79580. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  79581. */
  79582. private _scenes;
  79583. /**
  79584. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  79585. */
  79586. private _meshes;
  79587. /**
  79588. * Stores all the generated material information, which represents the appearance of each primitive
  79589. */
  79590. _materials: IMaterial[];
  79591. _materialMap: {
  79592. [materialID: number]: number;
  79593. };
  79594. /**
  79595. * Stores all the generated texture information, which is referenced by glTF materials
  79596. */
  79597. _textures: ITexture[];
  79598. /**
  79599. * Stores all the generated image information, which is referenced by glTF textures
  79600. */
  79601. _images: IImage[];
  79602. /**
  79603. * Stores all the texture samplers
  79604. */
  79605. _samplers: ISampler[];
  79606. /**
  79607. * Stores all the generated animation samplers, which is referenced by glTF animations
  79608. */
  79609. /**
  79610. * Stores the animations for glTF models
  79611. */
  79612. private _animations;
  79613. /**
  79614. * Stores the total amount of bytes stored in the glTF buffer
  79615. */
  79616. private _totalByteLength;
  79617. /**
  79618. * Stores a reference to the Babylon scene containing the source geometry and material information
  79619. */
  79620. _babylonScene: Scene;
  79621. /**
  79622. * Stores a map of the image data, where the key is the file name and the value
  79623. * is the image data
  79624. */
  79625. _imageData: {
  79626. [fileName: string]: {
  79627. data: Uint8Array;
  79628. mimeType: ImageMimeType;
  79629. };
  79630. };
  79631. /**
  79632. * Stores a map of the unique id of a node to its index in the node array
  79633. */
  79634. _nodeMap: {
  79635. [key: number]: number;
  79636. };
  79637. /**
  79638. * Specifies if the source Babylon scene was left handed, and needed conversion.
  79639. */
  79640. _convertToRightHandedSystem: boolean;
  79641. /**
  79642. * Specifies if a Babylon node should be converted to right-handed on export
  79643. */
  79644. _convertToRightHandedSystemMap: {
  79645. [nodeId: number]: boolean;
  79646. };
  79647. _includeCoordinateSystemConversionNodes: boolean;
  79648. /**
  79649. * Baked animation sample rate
  79650. */
  79651. private _animationSampleRate;
  79652. private _options;
  79653. private _localEngine;
  79654. _glTFMaterialExporter: _GLTFMaterialExporter;
  79655. private _extensions;
  79656. private static _ExtensionNames;
  79657. private static _ExtensionFactories;
  79658. private _applyExtension;
  79659. private _applyExtensions;
  79660. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  79661. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  79662. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79663. [key: number]: number;
  79664. }): Promise<Nullable<INode>>;
  79665. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  79666. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  79667. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79668. private _forEachExtensions;
  79669. private _extensionsOnExporting;
  79670. /**
  79671. * Load glTF serializer extensions
  79672. */
  79673. private _loadExtensions;
  79674. /**
  79675. * Creates a glTF Exporter instance, which can accept optional exporter options
  79676. * @param babylonScene Babylon scene object
  79677. * @param options Options to modify the behavior of the exporter
  79678. */
  79679. constructor(babylonScene: Scene, options?: IExportOptions);
  79680. dispose(): void;
  79681. /**
  79682. * Registers a glTF exporter extension
  79683. * @param name Name of the extension to export
  79684. * @param factory The factory function that creates the exporter extension
  79685. */
  79686. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  79687. /**
  79688. * Un-registers an exporter extension
  79689. * @param name The name fo the exporter extension
  79690. * @returns A boolean indicating whether the extension has been un-registered
  79691. */
  79692. static UnregisterExtension(name: string): boolean;
  79693. /**
  79694. * Lazy load a local engine
  79695. */
  79696. _getLocalEngine(): Engine;
  79697. private reorderIndicesBasedOnPrimitiveMode;
  79698. /**
  79699. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  79700. * clock-wise during export to glTF
  79701. * @param submesh BabylonJS submesh
  79702. * @param primitiveMode Primitive mode of the mesh
  79703. * @param sideOrientation the winding order of the submesh
  79704. * @param vertexBufferKind The type of vertex attribute
  79705. * @param meshAttributeArray The vertex attribute data
  79706. * @param byteOffset The offset to the binary data
  79707. * @param binaryWriter The binary data for the glTF file
  79708. * @param convertToRightHandedSystem Converts the values to right-handed
  79709. */
  79710. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  79711. /**
  79712. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  79713. * clock-wise during export to glTF
  79714. * @param submesh BabylonJS submesh
  79715. * @param primitiveMode Primitive mode of the mesh
  79716. * @param sideOrientation the winding order of the submesh
  79717. * @param vertexBufferKind The type of vertex attribute
  79718. * @param meshAttributeArray The vertex attribute data
  79719. * @param byteOffset The offset to the binary data
  79720. * @param binaryWriter The binary data for the glTF file
  79721. * @param convertToRightHandedSystem Converts the values to right-handed
  79722. */
  79723. private reorderTriangleFillMode;
  79724. /**
  79725. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  79726. * clock-wise during export to glTF
  79727. * @param submesh BabylonJS submesh
  79728. * @param primitiveMode Primitive mode of the mesh
  79729. * @param sideOrientation the winding order of the submesh
  79730. * @param vertexBufferKind The type of vertex attribute
  79731. * @param meshAttributeArray The vertex attribute data
  79732. * @param byteOffset The offset to the binary data
  79733. * @param binaryWriter The binary data for the glTF file
  79734. * @param convertToRightHandedSystem Converts the values to right-handed
  79735. */
  79736. private reorderTriangleStripDrawMode;
  79737. /**
  79738. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  79739. * clock-wise during export to glTF
  79740. * @param submesh BabylonJS submesh
  79741. * @param primitiveMode Primitive mode of the mesh
  79742. * @param sideOrientation the winding order of the submesh
  79743. * @param vertexBufferKind The type of vertex attribute
  79744. * @param meshAttributeArray The vertex attribute data
  79745. * @param byteOffset The offset to the binary data
  79746. * @param binaryWriter The binary data for the glTF file
  79747. * @param convertToRightHandedSystem Converts the values to right-handed
  79748. */
  79749. private reorderTriangleFanMode;
  79750. /**
  79751. * Writes the vertex attribute data to binary
  79752. * @param vertices The vertices to write to the binary writer
  79753. * @param byteOffset The offset into the binary writer to overwrite binary data
  79754. * @param vertexAttributeKind The vertex attribute type
  79755. * @param meshAttributeArray The vertex attribute data
  79756. * @param binaryWriter The writer containing the binary data
  79757. * @param convertToRightHandedSystem Converts the values to right-handed
  79758. */
  79759. private writeVertexAttributeData;
  79760. /**
  79761. * Writes mesh attribute data to a data buffer
  79762. * Returns the bytelength of the data
  79763. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  79764. * @param meshAttributeArray Array containing the attribute data
  79765. * @param binaryWriter The buffer to write the binary data to
  79766. * @param indices Used to specify the order of the vertex data
  79767. * @param convertToRightHandedSystem Converts the values to right-handed
  79768. */
  79769. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  79770. /**
  79771. * Generates glTF json data
  79772. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  79773. * @param glTFPrefix Text to use when prefixing a glTF file
  79774. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  79775. * @returns json data as string
  79776. */
  79777. private generateJSON;
  79778. /**
  79779. * Generates data for .gltf and .bin files based on the glTF prefix string
  79780. * @param glTFPrefix Text to use when prefixing a glTF file
  79781. * @param dispose Dispose the exporter
  79782. * @returns GLTFData with glTF file data
  79783. */
  79784. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79785. /**
  79786. * Creates a binary buffer for glTF
  79787. * @returns array buffer for binary data
  79788. */
  79789. private _generateBinaryAsync;
  79790. /**
  79791. * Pads the number to a multiple of 4
  79792. * @param num number to pad
  79793. * @returns padded number
  79794. */
  79795. private _getPadding;
  79796. /**
  79797. * @hidden
  79798. */
  79799. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79800. /**
  79801. * Sets the TRS for each node
  79802. * @param node glTF Node for storing the transformation data
  79803. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  79804. * @param convertToRightHandedSystem Converts the values to right-handed
  79805. */
  79806. private setNodeTransformation;
  79807. private getVertexBufferFromMesh;
  79808. /**
  79809. * Creates a bufferview based on the vertices type for the Babylon mesh
  79810. * @param kind Indicates the type of vertices data
  79811. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  79812. * @param binaryWriter The buffer to write the bufferview data to
  79813. * @param convertToRightHandedSystem Converts the values to right-handed
  79814. */
  79815. private createBufferViewKind;
  79816. /**
  79817. * The primitive mode of the Babylon mesh
  79818. * @param babylonMesh The BabylonJS mesh
  79819. */
  79820. private getMeshPrimitiveMode;
  79821. /**
  79822. * Sets the primitive mode of the glTF mesh primitive
  79823. * @param meshPrimitive glTF mesh primitive
  79824. * @param primitiveMode The primitive mode
  79825. */
  79826. private setPrimitiveMode;
  79827. /**
  79828. * Sets the vertex attribute accessor based of the glTF mesh primitive
  79829. * @param meshPrimitive glTF mesh primitive
  79830. * @param attributeKind vertex attribute
  79831. * @returns boolean specifying if uv coordinates are present
  79832. */
  79833. private setAttributeKind;
  79834. /**
  79835. * Sets data for the primitive attributes of each submesh
  79836. * @param mesh glTF Mesh object to store the primitive attribute information
  79837. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  79838. * @param binaryWriter Buffer to write the attribute data to
  79839. * @param convertToRightHandedSystem Converts the values to right-handed
  79840. */
  79841. private setPrimitiveAttributesAsync;
  79842. /**
  79843. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  79844. * @param node The node to check
  79845. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  79846. */
  79847. private isBabylonCoordinateSystemConvertingNode;
  79848. /**
  79849. * Creates a glTF scene based on the array of meshes
  79850. * Returns the the total byte offset
  79851. * @param babylonScene Babylon scene to get the mesh data from
  79852. * @param binaryWriter Buffer to write binary data to
  79853. */
  79854. private createSceneAsync;
  79855. /**
  79856. * Creates a mapping of Node unique id to node index and handles animations
  79857. * @param babylonScene Babylon Scene
  79858. * @param nodes Babylon transform nodes
  79859. * @param binaryWriter Buffer to write binary data to
  79860. * @returns Node mapping of unique id to index
  79861. */
  79862. private createNodeMapAndAnimationsAsync;
  79863. /**
  79864. * Creates a glTF node from a Babylon mesh
  79865. * @param babylonMesh Source Babylon mesh
  79866. * @param binaryWriter Buffer for storing geometry data
  79867. * @param convertToRightHandedSystem Converts the values to right-handed
  79868. * @param nodeMap Node mapping of unique id to glTF node index
  79869. * @returns glTF node
  79870. */
  79871. private createNodeAsync;
  79872. }
  79873. /**
  79874. * @hidden
  79875. *
  79876. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  79877. */
  79878. export class _BinaryWriter {
  79879. /**
  79880. * Array buffer which stores all binary data
  79881. */
  79882. private _arrayBuffer;
  79883. /**
  79884. * View of the array buffer
  79885. */
  79886. private _dataView;
  79887. /**
  79888. * byte offset of data in array buffer
  79889. */
  79890. private _byteOffset;
  79891. /**
  79892. * Initialize binary writer with an initial byte length
  79893. * @param byteLength Initial byte length of the array buffer
  79894. */
  79895. constructor(byteLength: number);
  79896. /**
  79897. * Resize the array buffer to the specified byte length
  79898. * @param byteLength
  79899. */
  79900. private resizeBuffer;
  79901. /**
  79902. * Get an array buffer with the length of the byte offset
  79903. * @returns ArrayBuffer resized to the byte offset
  79904. */
  79905. getArrayBuffer(): ArrayBuffer;
  79906. /**
  79907. * Get the byte offset of the array buffer
  79908. * @returns byte offset
  79909. */
  79910. getByteOffset(): number;
  79911. /**
  79912. * Stores an UInt8 in the array buffer
  79913. * @param entry
  79914. * @param byteOffset If defined, specifies where to set the value as an offset.
  79915. */
  79916. setUInt8(entry: number, byteOffset?: number): void;
  79917. /**
  79918. * Gets an UInt32 in the array buffer
  79919. * @param entry
  79920. * @param byteOffset If defined, specifies where to set the value as an offset.
  79921. */
  79922. getUInt32(byteOffset: number): number;
  79923. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79924. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79925. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79926. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79927. /**
  79928. * Stores a Float32 in the array buffer
  79929. * @param entry
  79930. */
  79931. setFloat32(entry: number, byteOffset?: number): void;
  79932. /**
  79933. * Stores an UInt32 in the array buffer
  79934. * @param entry
  79935. * @param byteOffset If defined, specifies where to set the value as an offset.
  79936. */
  79937. setUInt32(entry: number, byteOffset?: number): void;
  79938. }
  79939. }
  79940. declare module BABYLON.GLTF2.Exporter {
  79941. /**
  79942. * @hidden
  79943. * Interface to store animation data.
  79944. */
  79945. export interface _IAnimationData {
  79946. /**
  79947. * Keyframe data.
  79948. */
  79949. inputs: number[];
  79950. /**
  79951. * Value data.
  79952. */
  79953. outputs: number[][];
  79954. /**
  79955. * Animation interpolation data.
  79956. */
  79957. samplerInterpolation: AnimationSamplerInterpolation;
  79958. /**
  79959. * Minimum keyframe value.
  79960. */
  79961. inputsMin: number;
  79962. /**
  79963. * Maximum keyframe value.
  79964. */
  79965. inputsMax: number;
  79966. }
  79967. /**
  79968. * @hidden
  79969. */
  79970. export interface _IAnimationInfo {
  79971. /**
  79972. * The target channel for the animation
  79973. */
  79974. animationChannelTargetPath: AnimationChannelTargetPath;
  79975. /**
  79976. * The glTF accessor type for the data.
  79977. */
  79978. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  79979. /**
  79980. * Specifies if quaternions should be used.
  79981. */
  79982. useQuaternion: boolean;
  79983. }
  79984. /**
  79985. * @hidden
  79986. * Utility class for generating glTF animation data from BabylonJS.
  79987. */
  79988. export class _GLTFAnimation {
  79989. /**
  79990. * @ignore
  79991. *
  79992. * Creates glTF channel animation from BabylonJS animation.
  79993. * @param babylonTransformNode - BabylonJS mesh.
  79994. * @param animation - animation.
  79995. * @param animationChannelTargetPath - The target animation channel.
  79996. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  79997. * @param useQuaternion - Specifies if quaternions are used.
  79998. * @returns nullable IAnimationData
  79999. */
  80000. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80001. private static _DeduceAnimationInfo;
  80002. /**
  80003. * @ignore
  80004. * Create node animations from the transform node animations
  80005. * @param babylonNode
  80006. * @param runtimeGLTFAnimation
  80007. * @param idleGLTFAnimations
  80008. * @param nodeMap
  80009. * @param nodes
  80010. * @param binaryWriter
  80011. * @param bufferViews
  80012. * @param accessors
  80013. * @param convertToRightHandedSystem
  80014. * @param animationSampleRate
  80015. */
  80016. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80017. [key: number]: number;
  80018. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80019. /**
  80020. * @ignore
  80021. * Create node animations from the animation groups
  80022. * @param babylonScene
  80023. * @param glTFAnimations
  80024. * @param nodeMap
  80025. * @param nodes
  80026. * @param binaryWriter
  80027. * @param bufferViews
  80028. * @param accessors
  80029. * @param convertToRightHandedSystemMap
  80030. * @param animationSampleRate
  80031. */
  80032. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80033. [key: number]: number;
  80034. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80035. [nodeId: number]: boolean;
  80036. }, animationSampleRate: number): void;
  80037. private static AddAnimation;
  80038. /**
  80039. * Create a baked animation
  80040. * @param babylonTransformNode BabylonJS mesh
  80041. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80042. * @param animationChannelTargetPath animation target channel
  80043. * @param minFrame minimum animation frame
  80044. * @param maxFrame maximum animation frame
  80045. * @param fps frames per second of the animation
  80046. * @param inputs input key frames of the animation
  80047. * @param outputs output key frame data of the animation
  80048. * @param convertToRightHandedSystem converts the values to right-handed
  80049. * @param useQuaternion specifies if quaternions should be used
  80050. */
  80051. private static _CreateBakedAnimation;
  80052. private static _ConvertFactorToVector3OrQuaternion;
  80053. private static _SetInterpolatedValue;
  80054. /**
  80055. * Creates linear animation from the animation key frames
  80056. * @param babylonTransformNode BabylonJS mesh
  80057. * @param animation BabylonJS animation
  80058. * @param animationChannelTargetPath The target animation channel
  80059. * @param frameDelta The difference between the last and first frame of the animation
  80060. * @param inputs Array to store the key frame times
  80061. * @param outputs Array to store the key frame data
  80062. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80063. * @param useQuaternion Specifies if quaternions are used in the animation
  80064. */
  80065. private static _CreateLinearOrStepAnimation;
  80066. /**
  80067. * Creates cubic spline animation from the animation key frames
  80068. * @param babylonTransformNode BabylonJS mesh
  80069. * @param animation BabylonJS animation
  80070. * @param animationChannelTargetPath The target animation channel
  80071. * @param frameDelta The difference between the last and first frame of the animation
  80072. * @param inputs Array to store the key frame times
  80073. * @param outputs Array to store the key frame data
  80074. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80075. * @param useQuaternion Specifies if quaternions are used in the animation
  80076. */
  80077. private static _CreateCubicSplineAnimation;
  80078. private static _GetBasePositionRotationOrScale;
  80079. /**
  80080. * Adds a key frame value
  80081. * @param keyFrame
  80082. * @param animation
  80083. * @param outputs
  80084. * @param animationChannelTargetPath
  80085. * @param basePositionRotationOrScale
  80086. * @param convertToRightHandedSystem
  80087. * @param useQuaternion
  80088. */
  80089. private static _AddKeyframeValue;
  80090. /**
  80091. * Determine the interpolation based on the key frames
  80092. * @param keyFrames
  80093. * @param animationChannelTargetPath
  80094. * @param useQuaternion
  80095. */
  80096. private static _DeduceInterpolation;
  80097. /**
  80098. * Adds an input tangent or output tangent to the output data
  80099. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80100. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80101. * @param outputs The animation data by keyframe
  80102. * @param animationChannelTargetPath The target animation channel
  80103. * @param interpolation The interpolation type
  80104. * @param keyFrame The key frame with the animation data
  80105. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80106. * @param useQuaternion Specifies if quaternions are used
  80107. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80108. */
  80109. private static AddSplineTangent;
  80110. /**
  80111. * Get the minimum and maximum key frames' frame values
  80112. * @param keyFrames animation key frames
  80113. * @returns the minimum and maximum key frame value
  80114. */
  80115. private static calculateMinMaxKeyFrames;
  80116. }
  80117. }
  80118. declare module BABYLON.GLTF2.Exporter {
  80119. /** @hidden */
  80120. export var textureTransformPixelShader: {
  80121. name: string;
  80122. shader: string;
  80123. };
  80124. }
  80125. declare module BABYLON.GLTF2.Exporter.Extensions {
  80126. /**
  80127. * @hidden
  80128. */
  80129. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  80130. private _recordedTextures;
  80131. /** Name of this extension */
  80132. readonly name: string;
  80133. /** Defines whether this extension is enabled */
  80134. enabled: boolean;
  80135. /** Defines whether this extension is required */
  80136. required: boolean;
  80137. /** Reference to the glTF exporter */
  80138. private _wasUsed;
  80139. constructor(exporter: _Exporter);
  80140. dispose(): void;
  80141. /** @hidden */
  80142. get wasUsed(): boolean;
  80143. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80144. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  80145. /**
  80146. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  80147. * @param babylonTexture
  80148. * @param offset
  80149. * @param rotation
  80150. * @param scale
  80151. * @param scene
  80152. */
  80153. private _textureTransformTextureAsync;
  80154. }
  80155. }
  80156. declare module BABYLON.GLTF2.Exporter.Extensions {
  80157. /**
  80158. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  80159. */
  80160. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  80161. /** The name of this extension. */
  80162. readonly name: string;
  80163. /** Defines whether this extension is enabled. */
  80164. enabled: boolean;
  80165. /** Defines whether this extension is required */
  80166. required: boolean;
  80167. /** Reference to the glTF exporter */
  80168. private _exporter;
  80169. private _lights;
  80170. /** @hidden */
  80171. constructor(exporter: _Exporter);
  80172. /** @hidden */
  80173. dispose(): void;
  80174. /** @hidden */
  80175. get wasUsed(): boolean;
  80176. /** @hidden */
  80177. onExporting(): void;
  80178. /**
  80179. * Define this method to modify the default behavior when exporting a node
  80180. * @param context The context when exporting the node
  80181. * @param node glTF node
  80182. * @param babylonNode BabylonJS node
  80183. * @param nodeMap Node mapping of unique id to glTF node index
  80184. * @returns nullable INode promise
  80185. */
  80186. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80187. [key: number]: number;
  80188. }): Promise<Nullable<INode>>;
  80189. }
  80190. }
  80191. declare module BABYLON.GLTF2.Exporter.Extensions {
  80192. /**
  80193. * @hidden
  80194. */
  80195. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80196. /** Name of this extension */
  80197. readonly name: string;
  80198. /** Defines whether this extension is enabled */
  80199. enabled: boolean;
  80200. /** Defines whether this extension is required */
  80201. required: boolean;
  80202. /** Reference to the glTF exporter */
  80203. private _textureInfos;
  80204. private _exportedTextures;
  80205. private _wasUsed;
  80206. constructor(exporter: _Exporter);
  80207. dispose(): void;
  80208. /** @hidden */
  80209. get wasUsed(): boolean;
  80210. private _getTextureIndex;
  80211. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80212. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80213. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80214. }
  80215. }
  80216. declare module BABYLON {
  80217. /**
  80218. * Class for generating STL data from a Babylon scene.
  80219. */
  80220. export class STLExport {
  80221. /**
  80222. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80223. * @param meshes list defines the mesh to serialize
  80224. * @param download triggers the automatic download of the file.
  80225. * @param fileName changes the downloads fileName.
  80226. * @param binary changes the STL to a binary type.
  80227. * @param isLittleEndian toggle for binary type exporter.
  80228. * @returns the STL as UTF8 string
  80229. */
  80230. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80231. }
  80232. }
  80233. declare module "babylonjs-gltf2interface" {
  80234. export = BABYLON.GLTF2;
  80235. }
  80236. /**
  80237. * Module for glTF 2.0 Interface
  80238. */
  80239. declare module BABYLON.GLTF2 {
  80240. /**
  80241. * The datatype of the components in the attribute
  80242. */
  80243. const enum AccessorComponentType {
  80244. /**
  80245. * Byte
  80246. */
  80247. BYTE = 5120,
  80248. /**
  80249. * Unsigned Byte
  80250. */
  80251. UNSIGNED_BYTE = 5121,
  80252. /**
  80253. * Short
  80254. */
  80255. SHORT = 5122,
  80256. /**
  80257. * Unsigned Short
  80258. */
  80259. UNSIGNED_SHORT = 5123,
  80260. /**
  80261. * Unsigned Int
  80262. */
  80263. UNSIGNED_INT = 5125,
  80264. /**
  80265. * Float
  80266. */
  80267. FLOAT = 5126,
  80268. }
  80269. /**
  80270. * Specifies if the attirbute is a scalar, vector, or matrix
  80271. */
  80272. const enum AccessorType {
  80273. /**
  80274. * Scalar
  80275. */
  80276. SCALAR = "SCALAR",
  80277. /**
  80278. * Vector2
  80279. */
  80280. VEC2 = "VEC2",
  80281. /**
  80282. * Vector3
  80283. */
  80284. VEC3 = "VEC3",
  80285. /**
  80286. * Vector4
  80287. */
  80288. VEC4 = "VEC4",
  80289. /**
  80290. * Matrix2x2
  80291. */
  80292. MAT2 = "MAT2",
  80293. /**
  80294. * Matrix3x3
  80295. */
  80296. MAT3 = "MAT3",
  80297. /**
  80298. * Matrix4x4
  80299. */
  80300. MAT4 = "MAT4",
  80301. }
  80302. /**
  80303. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80304. */
  80305. const enum AnimationChannelTargetPath {
  80306. /**
  80307. * Translation
  80308. */
  80309. TRANSLATION = "translation",
  80310. /**
  80311. * Rotation
  80312. */
  80313. ROTATION = "rotation",
  80314. /**
  80315. * Scale
  80316. */
  80317. SCALE = "scale",
  80318. /**
  80319. * Weights
  80320. */
  80321. WEIGHTS = "weights",
  80322. }
  80323. /**
  80324. * Interpolation algorithm
  80325. */
  80326. const enum AnimationSamplerInterpolation {
  80327. /**
  80328. * The animated values are linearly interpolated between keyframes
  80329. */
  80330. LINEAR = "LINEAR",
  80331. /**
  80332. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80333. */
  80334. STEP = "STEP",
  80335. /**
  80336. * The animation's interpolation is computed using a cubic spline with specified tangents
  80337. */
  80338. CUBICSPLINE = "CUBICSPLINE",
  80339. }
  80340. /**
  80341. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80342. */
  80343. const enum CameraType {
  80344. /**
  80345. * A perspective camera containing properties to create a perspective projection matrix
  80346. */
  80347. PERSPECTIVE = "perspective",
  80348. /**
  80349. * An orthographic camera containing properties to create an orthographic projection matrix
  80350. */
  80351. ORTHOGRAPHIC = "orthographic",
  80352. }
  80353. /**
  80354. * The mime-type of the image
  80355. */
  80356. const enum ImageMimeType {
  80357. /**
  80358. * JPEG Mime-type
  80359. */
  80360. JPEG = "image/jpeg",
  80361. /**
  80362. * PNG Mime-type
  80363. */
  80364. PNG = "image/png",
  80365. }
  80366. /**
  80367. * The alpha rendering mode of the material
  80368. */
  80369. const enum MaterialAlphaMode {
  80370. /**
  80371. * The alpha value is ignored and the rendered output is fully opaque
  80372. */
  80373. OPAQUE = "OPAQUE",
  80374. /**
  80375. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80376. */
  80377. MASK = "MASK",
  80378. /**
  80379. * 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)
  80380. */
  80381. BLEND = "BLEND",
  80382. }
  80383. /**
  80384. * The type of the primitives to render
  80385. */
  80386. const enum MeshPrimitiveMode {
  80387. /**
  80388. * Points
  80389. */
  80390. POINTS = 0,
  80391. /**
  80392. * Lines
  80393. */
  80394. LINES = 1,
  80395. /**
  80396. * Line Loop
  80397. */
  80398. LINE_LOOP = 2,
  80399. /**
  80400. * Line Strip
  80401. */
  80402. LINE_STRIP = 3,
  80403. /**
  80404. * Triangles
  80405. */
  80406. TRIANGLES = 4,
  80407. /**
  80408. * Triangle Strip
  80409. */
  80410. TRIANGLE_STRIP = 5,
  80411. /**
  80412. * Triangle Fan
  80413. */
  80414. TRIANGLE_FAN = 6,
  80415. }
  80416. /**
  80417. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80418. */
  80419. const enum TextureMagFilter {
  80420. /**
  80421. * Nearest
  80422. */
  80423. NEAREST = 9728,
  80424. /**
  80425. * Linear
  80426. */
  80427. LINEAR = 9729,
  80428. }
  80429. /**
  80430. * Minification filter. All valid values correspond to WebGL enums
  80431. */
  80432. const enum TextureMinFilter {
  80433. /**
  80434. * Nearest
  80435. */
  80436. NEAREST = 9728,
  80437. /**
  80438. * Linear
  80439. */
  80440. LINEAR = 9729,
  80441. /**
  80442. * Nearest Mip-Map Nearest
  80443. */
  80444. NEAREST_MIPMAP_NEAREST = 9984,
  80445. /**
  80446. * Linear Mipmap Nearest
  80447. */
  80448. LINEAR_MIPMAP_NEAREST = 9985,
  80449. /**
  80450. * Nearest Mipmap Linear
  80451. */
  80452. NEAREST_MIPMAP_LINEAR = 9986,
  80453. /**
  80454. * Linear Mipmap Linear
  80455. */
  80456. LINEAR_MIPMAP_LINEAR = 9987,
  80457. }
  80458. /**
  80459. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80460. */
  80461. const enum TextureWrapMode {
  80462. /**
  80463. * Clamp to Edge
  80464. */
  80465. CLAMP_TO_EDGE = 33071,
  80466. /**
  80467. * Mirrored Repeat
  80468. */
  80469. MIRRORED_REPEAT = 33648,
  80470. /**
  80471. * Repeat
  80472. */
  80473. REPEAT = 10497,
  80474. }
  80475. /**
  80476. * glTF Property
  80477. */
  80478. interface IProperty {
  80479. /**
  80480. * Dictionary object with extension-specific objects
  80481. */
  80482. extensions?: {
  80483. [key: string]: any;
  80484. };
  80485. /**
  80486. * Application-Specific data
  80487. */
  80488. extras?: any;
  80489. }
  80490. /**
  80491. * glTF Child of Root Property
  80492. */
  80493. interface IChildRootProperty extends IProperty {
  80494. /**
  80495. * The user-defined name of this object
  80496. */
  80497. name?: string;
  80498. }
  80499. /**
  80500. * Indices of those attributes that deviate from their initialization value
  80501. */
  80502. interface IAccessorSparseIndices extends IProperty {
  80503. /**
  80504. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80505. */
  80506. bufferView: number;
  80507. /**
  80508. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80509. */
  80510. byteOffset?: number;
  80511. /**
  80512. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  80513. */
  80514. componentType: AccessorComponentType;
  80515. }
  80516. /**
  80517. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  80518. */
  80519. interface IAccessorSparseValues extends IProperty {
  80520. /**
  80521. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80522. */
  80523. bufferView: number;
  80524. /**
  80525. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80526. */
  80527. byteOffset?: number;
  80528. }
  80529. /**
  80530. * Sparse storage of attributes that deviate from their initialization value
  80531. */
  80532. interface IAccessorSparse extends IProperty {
  80533. /**
  80534. * The number of attributes encoded in this sparse accessor
  80535. */
  80536. count: number;
  80537. /**
  80538. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  80539. */
  80540. indices: IAccessorSparseIndices;
  80541. /**
  80542. * 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
  80543. */
  80544. values: IAccessorSparseValues;
  80545. }
  80546. /**
  80547. * 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
  80548. */
  80549. interface IAccessor extends IChildRootProperty {
  80550. /**
  80551. * The index of the bufferview
  80552. */
  80553. bufferView?: number;
  80554. /**
  80555. * The offset relative to the start of the bufferView in bytes
  80556. */
  80557. byteOffset?: number;
  80558. /**
  80559. * The datatype of components in the attribute
  80560. */
  80561. componentType: AccessorComponentType;
  80562. /**
  80563. * Specifies whether integer data values should be normalized
  80564. */
  80565. normalized?: boolean;
  80566. /**
  80567. * The number of attributes referenced by this accessor
  80568. */
  80569. count: number;
  80570. /**
  80571. * Specifies if the attribute is a scalar, vector, or matrix
  80572. */
  80573. type: AccessorType;
  80574. /**
  80575. * Maximum value of each component in this attribute
  80576. */
  80577. max?: number[];
  80578. /**
  80579. * Minimum value of each component in this attribute
  80580. */
  80581. min?: number[];
  80582. /**
  80583. * Sparse storage of attributes that deviate from their initialization value
  80584. */
  80585. sparse?: IAccessorSparse;
  80586. }
  80587. /**
  80588. * Targets an animation's sampler at a node's property
  80589. */
  80590. interface IAnimationChannel extends IProperty {
  80591. /**
  80592. * The index of a sampler in this animation used to compute the value for the target
  80593. */
  80594. sampler: number;
  80595. /**
  80596. * The index of the node and TRS property to target
  80597. */
  80598. target: IAnimationChannelTarget;
  80599. }
  80600. /**
  80601. * The index of the node and TRS property that an animation channel targets
  80602. */
  80603. interface IAnimationChannelTarget extends IProperty {
  80604. /**
  80605. * The index of the node to target
  80606. */
  80607. node: number;
  80608. /**
  80609. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80610. */
  80611. path: AnimationChannelTargetPath;
  80612. }
  80613. /**
  80614. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80615. */
  80616. interface IAnimationSampler extends IProperty {
  80617. /**
  80618. * The index of an accessor containing keyframe input values, e.g., time
  80619. */
  80620. input: number;
  80621. /**
  80622. * Interpolation algorithm
  80623. */
  80624. interpolation?: AnimationSamplerInterpolation;
  80625. /**
  80626. * The index of an accessor, containing keyframe output values
  80627. */
  80628. output: number;
  80629. }
  80630. /**
  80631. * A keyframe animation
  80632. */
  80633. interface IAnimation extends IChildRootProperty {
  80634. /**
  80635. * An array of channels, each of which targets an animation's sampler at a node's property
  80636. */
  80637. channels: IAnimationChannel[];
  80638. /**
  80639. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80640. */
  80641. samplers: IAnimationSampler[];
  80642. }
  80643. /**
  80644. * Metadata about the glTF asset
  80645. */
  80646. interface IAsset extends IChildRootProperty {
  80647. /**
  80648. * A copyright message suitable for display to credit the content creator
  80649. */
  80650. copyright?: string;
  80651. /**
  80652. * Tool that generated this glTF model. Useful for debugging
  80653. */
  80654. generator?: string;
  80655. /**
  80656. * The glTF version that this asset targets
  80657. */
  80658. version: string;
  80659. /**
  80660. * The minimum glTF version that this asset targets
  80661. */
  80662. minVersion?: string;
  80663. }
  80664. /**
  80665. * A buffer points to binary geometry, animation, or skins
  80666. */
  80667. interface IBuffer extends IChildRootProperty {
  80668. /**
  80669. * 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
  80670. */
  80671. uri?: string;
  80672. /**
  80673. * The length of the buffer in bytes
  80674. */
  80675. byteLength: number;
  80676. }
  80677. /**
  80678. * A view into a buffer generally representing a subset of the buffer
  80679. */
  80680. interface IBufferView extends IChildRootProperty {
  80681. /**
  80682. * The index of the buffer
  80683. */
  80684. buffer: number;
  80685. /**
  80686. * The offset into the buffer in bytes
  80687. */
  80688. byteOffset?: number;
  80689. /**
  80690. * The lenth of the bufferView in bytes
  80691. */
  80692. byteLength: number;
  80693. /**
  80694. * The stride, in bytes
  80695. */
  80696. byteStride?: number;
  80697. }
  80698. /**
  80699. * An orthographic camera containing properties to create an orthographic projection matrix
  80700. */
  80701. interface ICameraOrthographic extends IProperty {
  80702. /**
  80703. * The floating-point horizontal magnification of the view. Must not be zero
  80704. */
  80705. xmag: number;
  80706. /**
  80707. * The floating-point vertical magnification of the view. Must not be zero
  80708. */
  80709. ymag: number;
  80710. /**
  80711. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  80712. */
  80713. zfar: number;
  80714. /**
  80715. * The floating-point distance to the near clipping plane
  80716. */
  80717. znear: number;
  80718. }
  80719. /**
  80720. * A perspective camera containing properties to create a perspective projection matrix
  80721. */
  80722. interface ICameraPerspective extends IProperty {
  80723. /**
  80724. * The floating-point aspect ratio of the field of view
  80725. */
  80726. aspectRatio?: number;
  80727. /**
  80728. * The floating-point vertical field of view in radians
  80729. */
  80730. yfov: number;
  80731. /**
  80732. * The floating-point distance to the far clipping plane
  80733. */
  80734. zfar?: number;
  80735. /**
  80736. * The floating-point distance to the near clipping plane
  80737. */
  80738. znear: number;
  80739. }
  80740. /**
  80741. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80742. */
  80743. interface ICamera extends IChildRootProperty {
  80744. /**
  80745. * An orthographic camera containing properties to create an orthographic projection matrix
  80746. */
  80747. orthographic?: ICameraOrthographic;
  80748. /**
  80749. * A perspective camera containing properties to create a perspective projection matrix
  80750. */
  80751. perspective?: ICameraPerspective;
  80752. /**
  80753. * Specifies if the camera uses a perspective or orthographic projection
  80754. */
  80755. type: CameraType;
  80756. }
  80757. /**
  80758. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  80759. */
  80760. interface IImage extends IChildRootProperty {
  80761. /**
  80762. * 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
  80763. */
  80764. uri?: string;
  80765. /**
  80766. * The image's MIME type
  80767. */
  80768. mimeType?: ImageMimeType;
  80769. /**
  80770. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  80771. */
  80772. bufferView?: number;
  80773. }
  80774. /**
  80775. * Material Normal Texture Info
  80776. */
  80777. interface IMaterialNormalTextureInfo extends ITextureInfo {
  80778. /**
  80779. * The scalar multiplier applied to each normal vector of the normal texture
  80780. */
  80781. scale?: number;
  80782. }
  80783. /**
  80784. * Material Occlusion Texture Info
  80785. */
  80786. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  80787. /**
  80788. * A scalar multiplier controlling the amount of occlusion applied
  80789. */
  80790. strength?: number;
  80791. }
  80792. /**
  80793. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  80794. */
  80795. interface IMaterialPbrMetallicRoughness {
  80796. /**
  80797. * The material's base color factor
  80798. */
  80799. baseColorFactor?: number[];
  80800. /**
  80801. * The base color texture
  80802. */
  80803. baseColorTexture?: ITextureInfo;
  80804. /**
  80805. * The metalness of the material
  80806. */
  80807. metallicFactor?: number;
  80808. /**
  80809. * The roughness of the material
  80810. */
  80811. roughnessFactor?: number;
  80812. /**
  80813. * The metallic-roughness texture
  80814. */
  80815. metallicRoughnessTexture?: ITextureInfo;
  80816. }
  80817. /**
  80818. * The material appearance of a primitive
  80819. */
  80820. interface IMaterial extends IChildRootProperty {
  80821. /**
  80822. * 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
  80823. */
  80824. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80825. /**
  80826. * The normal map texture
  80827. */
  80828. normalTexture?: IMaterialNormalTextureInfo;
  80829. /**
  80830. * The occlusion map texture
  80831. */
  80832. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80833. /**
  80834. * The emissive map texture
  80835. */
  80836. emissiveTexture?: ITextureInfo;
  80837. /**
  80838. * 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
  80839. */
  80840. emissiveFactor?: number[];
  80841. /**
  80842. * The alpha rendering mode of the material
  80843. */
  80844. alphaMode?: MaterialAlphaMode;
  80845. /**
  80846. * The alpha cutoff value of the material
  80847. */
  80848. alphaCutoff?: number;
  80849. /**
  80850. * Specifies whether the material is double sided
  80851. */
  80852. doubleSided?: boolean;
  80853. }
  80854. /**
  80855. * Geometry to be rendered with the given material
  80856. */
  80857. interface IMeshPrimitive extends IProperty {
  80858. /**
  80859. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  80860. */
  80861. attributes: {
  80862. [name: string]: number;
  80863. };
  80864. /**
  80865. * The index of the accessor that contains the indices
  80866. */
  80867. indices?: number;
  80868. /**
  80869. * The index of the material to apply to this primitive when rendering
  80870. */
  80871. material?: number;
  80872. /**
  80873. * The type of primitives to render. All valid values correspond to WebGL enums
  80874. */
  80875. mode?: MeshPrimitiveMode;
  80876. /**
  80877. * 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
  80878. */
  80879. targets?: {
  80880. [name: string]: number;
  80881. }[];
  80882. }
  80883. /**
  80884. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  80885. */
  80886. interface IMesh extends IChildRootProperty {
  80887. /**
  80888. * An array of primitives, each defining geometry to be rendered with a material
  80889. */
  80890. primitives: IMeshPrimitive[];
  80891. /**
  80892. * Array of weights to be applied to the Morph Targets
  80893. */
  80894. weights?: number[];
  80895. }
  80896. /**
  80897. * A node in the node hierarchy
  80898. */
  80899. interface INode extends IChildRootProperty {
  80900. /**
  80901. * The index of the camera referenced by this node
  80902. */
  80903. camera?: number;
  80904. /**
  80905. * The indices of this node's children
  80906. */
  80907. children?: number[];
  80908. /**
  80909. * The index of the skin referenced by this node
  80910. */
  80911. skin?: number;
  80912. /**
  80913. * A floating-point 4x4 transformation matrix stored in column-major order
  80914. */
  80915. matrix?: number[];
  80916. /**
  80917. * The index of the mesh in this node
  80918. */
  80919. mesh?: number;
  80920. /**
  80921. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  80922. */
  80923. rotation?: number[];
  80924. /**
  80925. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  80926. */
  80927. scale?: number[];
  80928. /**
  80929. * The node's translation along the x, y, and z axes
  80930. */
  80931. translation?: number[];
  80932. /**
  80933. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  80934. */
  80935. weights?: number[];
  80936. }
  80937. /**
  80938. * Texture sampler properties for filtering and wrapping modes
  80939. */
  80940. interface ISampler extends IChildRootProperty {
  80941. /**
  80942. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80943. */
  80944. magFilter?: TextureMagFilter;
  80945. /**
  80946. * Minification filter. All valid values correspond to WebGL enums
  80947. */
  80948. minFilter?: TextureMinFilter;
  80949. /**
  80950. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80951. */
  80952. wrapS?: TextureWrapMode;
  80953. /**
  80954. * T (V) wrapping mode. All valid values correspond to WebGL enums
  80955. */
  80956. wrapT?: TextureWrapMode;
  80957. }
  80958. /**
  80959. * The root nodes of a scene
  80960. */
  80961. interface IScene extends IChildRootProperty {
  80962. /**
  80963. * The indices of each root node
  80964. */
  80965. nodes: number[];
  80966. }
  80967. /**
  80968. * Joints and matrices defining a skin
  80969. */
  80970. interface ISkin extends IChildRootProperty {
  80971. /**
  80972. * 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
  80973. */
  80974. inverseBindMatrices?: number;
  80975. /**
  80976. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  80977. */
  80978. skeleton?: number;
  80979. /**
  80980. * 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)
  80981. */
  80982. joints: number[];
  80983. }
  80984. /**
  80985. * A texture and its sampler
  80986. */
  80987. interface ITexture extends IChildRootProperty {
  80988. /**
  80989. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  80990. */
  80991. sampler?: number;
  80992. /**
  80993. * The index of the image used by this texture
  80994. */
  80995. source: number;
  80996. }
  80997. /**
  80998. * Reference to a texture
  80999. */
  81000. interface ITextureInfo extends IProperty {
  81001. /**
  81002. * The index of the texture
  81003. */
  81004. index: number;
  81005. /**
  81006. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81007. */
  81008. texCoord?: number;
  81009. }
  81010. /**
  81011. * The root object for a glTF asset
  81012. */
  81013. interface IGLTF extends IProperty {
  81014. /**
  81015. * An array of accessors. An accessor is a typed view into a bufferView
  81016. */
  81017. accessors?: IAccessor[];
  81018. /**
  81019. * An array of keyframe animations
  81020. */
  81021. animations?: IAnimation[];
  81022. /**
  81023. * Metadata about the glTF asset
  81024. */
  81025. asset: IAsset;
  81026. /**
  81027. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81028. */
  81029. buffers?: IBuffer[];
  81030. /**
  81031. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81032. */
  81033. bufferViews?: IBufferView[];
  81034. /**
  81035. * An array of cameras
  81036. */
  81037. cameras?: ICamera[];
  81038. /**
  81039. * Names of glTF extensions used somewhere in this asset
  81040. */
  81041. extensionsUsed?: string[];
  81042. /**
  81043. * Names of glTF extensions required to properly load this asset
  81044. */
  81045. extensionsRequired?: string[];
  81046. /**
  81047. * An array of images. An image defines data used to create a texture
  81048. */
  81049. images?: IImage[];
  81050. /**
  81051. * An array of materials. A material defines the appearance of a primitive
  81052. */
  81053. materials?: IMaterial[];
  81054. /**
  81055. * An array of meshes. A mesh is a set of primitives to be rendered
  81056. */
  81057. meshes?: IMesh[];
  81058. /**
  81059. * An array of nodes
  81060. */
  81061. nodes?: INode[];
  81062. /**
  81063. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81064. */
  81065. samplers?: ISampler[];
  81066. /**
  81067. * The index of the default scene
  81068. */
  81069. scene?: number;
  81070. /**
  81071. * An array of scenes
  81072. */
  81073. scenes?: IScene[];
  81074. /**
  81075. * An array of skins. A skin is defined by joints and matrices
  81076. */
  81077. skins?: ISkin[];
  81078. /**
  81079. * An array of textures
  81080. */
  81081. textures?: ITexture[];
  81082. }
  81083. /**
  81084. * The glTF validation results
  81085. * @ignore
  81086. */
  81087. interface IGLTFValidationResults {
  81088. info: {
  81089. generator: string;
  81090. hasAnimations: boolean;
  81091. hasDefaultScene: boolean;
  81092. hasMaterials: boolean;
  81093. hasMorphTargets: boolean;
  81094. hasSkins: boolean;
  81095. hasTextures: boolean;
  81096. maxAttributesUsed: number;
  81097. primitivesCount: number
  81098. };
  81099. issues: {
  81100. messages: Array<string>;
  81101. numErrors: number;
  81102. numHints: number;
  81103. numInfos: number;
  81104. numWarnings: number;
  81105. truncated: boolean
  81106. };
  81107. mimeType: string;
  81108. uri: string;
  81109. validatedAt: string;
  81110. validatorVersion: string;
  81111. }
  81112. /**
  81113. * The glTF validation options
  81114. */
  81115. interface IGLTFValidationOptions {
  81116. /** Uri to use */
  81117. uri?: string;
  81118. /** Function used to load external resources */
  81119. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81120. /** Boolean indicating that we need to validate accessor data */
  81121. validateAccessorData?: boolean;
  81122. /** max number of issues allowed */
  81123. maxIssues?: number;
  81124. /** Ignored issues */
  81125. ignoredIssues?: Array<string>;
  81126. /** Value to override severy settings */
  81127. severityOverrides?: Object;
  81128. }
  81129. /**
  81130. * The glTF validator object
  81131. * @ignore
  81132. */
  81133. interface IGLTFValidator {
  81134. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81135. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81136. }
  81137. }
  81138. declare module BABYLON {
  81139. /** @hidden */
  81140. export var cellPixelShader: {
  81141. name: string;
  81142. shader: string;
  81143. };
  81144. }
  81145. declare module BABYLON {
  81146. /** @hidden */
  81147. export var cellVertexShader: {
  81148. name: string;
  81149. shader: string;
  81150. };
  81151. }
  81152. declare module BABYLON {
  81153. export class CellMaterial extends BABYLON.PushMaterial {
  81154. private _diffuseTexture;
  81155. diffuseTexture: BABYLON.BaseTexture;
  81156. diffuseColor: BABYLON.Color3;
  81157. _computeHighLevel: boolean;
  81158. computeHighLevel: boolean;
  81159. private _disableLighting;
  81160. disableLighting: boolean;
  81161. private _maxSimultaneousLights;
  81162. maxSimultaneousLights: number;
  81163. constructor(name: string, scene: BABYLON.Scene);
  81164. needAlphaBlending(): boolean;
  81165. needAlphaTesting(): boolean;
  81166. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81167. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81168. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81169. getAnimatables(): BABYLON.IAnimatable[];
  81170. getActiveTextures(): BABYLON.BaseTexture[];
  81171. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81172. dispose(forceDisposeEffect?: boolean): void;
  81173. getClassName(): string;
  81174. clone(name: string): CellMaterial;
  81175. serialize(): any;
  81176. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  81177. }
  81178. }
  81179. declare module BABYLON {
  81180. export class CustomShaderStructure {
  81181. FragmentStore: string;
  81182. VertexStore: string;
  81183. constructor();
  81184. }
  81185. export class ShaderSpecialParts {
  81186. constructor();
  81187. Fragment_Begin: string;
  81188. Fragment_Definitions: string;
  81189. Fragment_MainBegin: string;
  81190. Fragment_Custom_Diffuse: string;
  81191. Fragment_Before_Lights: string;
  81192. Fragment_Before_Fog: string;
  81193. Fragment_Custom_Alpha: string;
  81194. Fragment_Before_FragColor: string;
  81195. Vertex_Begin: string;
  81196. Vertex_Definitions: string;
  81197. Vertex_MainBegin: string;
  81198. Vertex_Before_PositionUpdated: string;
  81199. Vertex_Before_NormalUpdated: string;
  81200. Vertex_After_WorldPosComputed: string;
  81201. Vertex_MainEnd: string;
  81202. }
  81203. export class CustomMaterial extends BABYLON.StandardMaterial {
  81204. static ShaderIndexer: number;
  81205. CustomParts: ShaderSpecialParts;
  81206. _isCreatedShader: boolean;
  81207. _createdShaderName: string;
  81208. _customUniform: string[];
  81209. _newUniforms: string[];
  81210. _newUniformInstances: {
  81211. [name: string]: any;
  81212. };
  81213. _newSamplerInstances: {
  81214. [name: string]: BABYLON.Texture;
  81215. };
  81216. _customAttributes: string[];
  81217. FragmentShader: string;
  81218. VertexShader: string;
  81219. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81220. ReviewUniform(name: string, arr: string[]): string[];
  81221. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81222. constructor(name: string, scene: BABYLON.Scene);
  81223. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81224. AddAttribute(name: string): CustomMaterial;
  81225. Fragment_Begin(shaderPart: string): CustomMaterial;
  81226. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81227. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81228. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81229. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81230. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81231. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81232. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81233. Vertex_Begin(shaderPart: string): CustomMaterial;
  81234. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81235. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81236. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81237. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81238. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81239. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81240. }
  81241. }
  81242. declare module BABYLON {
  81243. export class ShaderAlebdoParts {
  81244. constructor();
  81245. Fragment_Begin: string;
  81246. Fragment_Definitions: string;
  81247. Fragment_MainBegin: string;
  81248. Fragment_Custom_Albedo: string;
  81249. Fragment_Before_Lights: string;
  81250. Fragment_Custom_MetallicRoughness: string;
  81251. Fragment_Custom_MicroSurface: string;
  81252. Fragment_Before_Fog: string;
  81253. Fragment_Custom_Alpha: string;
  81254. Fragment_Before_FragColor: string;
  81255. Vertex_Begin: string;
  81256. Vertex_Definitions: string;
  81257. Vertex_MainBegin: string;
  81258. Vertex_Before_PositionUpdated: string;
  81259. Vertex_Before_NormalUpdated: string;
  81260. Vertex_After_WorldPosComputed: string;
  81261. Vertex_MainEnd: string;
  81262. }
  81263. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81264. static ShaderIndexer: number;
  81265. CustomParts: ShaderAlebdoParts;
  81266. _isCreatedShader: boolean;
  81267. _createdShaderName: string;
  81268. _customUniform: string[];
  81269. _newUniforms: string[];
  81270. _newUniformInstances: {
  81271. [name: string]: any;
  81272. };
  81273. _newSamplerInstances: {
  81274. [name: string]: BABYLON.Texture;
  81275. };
  81276. _customAttributes: string[];
  81277. FragmentShader: string;
  81278. VertexShader: string;
  81279. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81280. ReviewUniform(name: string, arr: string[]): string[];
  81281. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81282. constructor(name: string, scene: BABYLON.Scene);
  81283. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81284. AddAttribute(name: string): PBRCustomMaterial;
  81285. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81286. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81287. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81288. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81289. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81290. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81291. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81292. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81293. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81294. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81295. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81296. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81297. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81298. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81299. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81300. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81301. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81302. }
  81303. }
  81304. declare module BABYLON {
  81305. /** @hidden */
  81306. export var firePixelShader: {
  81307. name: string;
  81308. shader: string;
  81309. };
  81310. }
  81311. declare module BABYLON {
  81312. /** @hidden */
  81313. export var fireVertexShader: {
  81314. name: string;
  81315. shader: string;
  81316. };
  81317. }
  81318. declare module BABYLON {
  81319. export class FireMaterial extends BABYLON.PushMaterial {
  81320. private _diffuseTexture;
  81321. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81322. private _distortionTexture;
  81323. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81324. private _opacityTexture;
  81325. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81326. diffuseColor: BABYLON.Color3;
  81327. speed: number;
  81328. private _scaledDiffuse;
  81329. private _lastTime;
  81330. constructor(name: string, scene: BABYLON.Scene);
  81331. needAlphaBlending(): boolean;
  81332. needAlphaTesting(): boolean;
  81333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81336. getAnimatables(): BABYLON.IAnimatable[];
  81337. getActiveTextures(): BABYLON.BaseTexture[];
  81338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81339. getClassName(): string;
  81340. dispose(forceDisposeEffect?: boolean): void;
  81341. clone(name: string): FireMaterial;
  81342. serialize(): any;
  81343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81344. }
  81345. }
  81346. declare module BABYLON {
  81347. /** @hidden */
  81348. export var furPixelShader: {
  81349. name: string;
  81350. shader: string;
  81351. };
  81352. }
  81353. declare module BABYLON {
  81354. /** @hidden */
  81355. export var furVertexShader: {
  81356. name: string;
  81357. shader: string;
  81358. };
  81359. }
  81360. declare module BABYLON {
  81361. export class FurMaterial extends BABYLON.PushMaterial {
  81362. private _diffuseTexture;
  81363. diffuseTexture: BABYLON.BaseTexture;
  81364. private _heightTexture;
  81365. heightTexture: BABYLON.BaseTexture;
  81366. diffuseColor: BABYLON.Color3;
  81367. furLength: number;
  81368. furAngle: number;
  81369. furColor: BABYLON.Color3;
  81370. furOffset: number;
  81371. furSpacing: number;
  81372. furGravity: BABYLON.Vector3;
  81373. furSpeed: number;
  81374. furDensity: number;
  81375. furOcclusion: number;
  81376. furTexture: BABYLON.DynamicTexture;
  81377. private _disableLighting;
  81378. disableLighting: boolean;
  81379. private _maxSimultaneousLights;
  81380. maxSimultaneousLights: number;
  81381. highLevelFur: boolean;
  81382. _meshes: BABYLON.AbstractMesh[];
  81383. private _furTime;
  81384. constructor(name: string, scene: BABYLON.Scene);
  81385. get furTime(): number;
  81386. set furTime(furTime: number);
  81387. needAlphaBlending(): boolean;
  81388. needAlphaTesting(): boolean;
  81389. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81390. updateFur(): void;
  81391. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81392. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81393. getAnimatables(): BABYLON.IAnimatable[];
  81394. getActiveTextures(): BABYLON.BaseTexture[];
  81395. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81396. dispose(forceDisposeEffect?: boolean): void;
  81397. clone(name: string): FurMaterial;
  81398. serialize(): any;
  81399. getClassName(): string;
  81400. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81401. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81402. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81403. }
  81404. }
  81405. declare module BABYLON {
  81406. /** @hidden */
  81407. export var gradientPixelShader: {
  81408. name: string;
  81409. shader: string;
  81410. };
  81411. }
  81412. declare module BABYLON {
  81413. /** @hidden */
  81414. export var gradientVertexShader: {
  81415. name: string;
  81416. shader: string;
  81417. };
  81418. }
  81419. declare module BABYLON {
  81420. export class GradientMaterial extends BABYLON.PushMaterial {
  81421. private _maxSimultaneousLights;
  81422. maxSimultaneousLights: number;
  81423. topColor: BABYLON.Color3;
  81424. topColorAlpha: number;
  81425. bottomColor: BABYLON.Color3;
  81426. bottomColorAlpha: number;
  81427. offset: number;
  81428. scale: number;
  81429. smoothness: number;
  81430. private _disableLighting;
  81431. disableLighting: boolean;
  81432. constructor(name: string, scene: BABYLON.Scene);
  81433. needAlphaBlending(): boolean;
  81434. needAlphaTesting(): boolean;
  81435. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81436. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81437. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81438. getAnimatables(): BABYLON.IAnimatable[];
  81439. dispose(forceDisposeEffect?: boolean): void;
  81440. clone(name: string): GradientMaterial;
  81441. serialize(): any;
  81442. getClassName(): string;
  81443. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81444. }
  81445. }
  81446. declare module BABYLON {
  81447. /** @hidden */
  81448. export var gridPixelShader: {
  81449. name: string;
  81450. shader: string;
  81451. };
  81452. }
  81453. declare module BABYLON {
  81454. /** @hidden */
  81455. export var gridVertexShader: {
  81456. name: string;
  81457. shader: string;
  81458. };
  81459. }
  81460. declare module BABYLON {
  81461. /**
  81462. * The grid materials allows you to wrap any shape with a grid.
  81463. * Colors are customizable.
  81464. */
  81465. export class GridMaterial extends BABYLON.PushMaterial {
  81466. /**
  81467. * Main color of the grid (e.g. between lines)
  81468. */
  81469. mainColor: BABYLON.Color3;
  81470. /**
  81471. * Color of the grid lines.
  81472. */
  81473. lineColor: BABYLON.Color3;
  81474. /**
  81475. * The scale of the grid compared to unit.
  81476. */
  81477. gridRatio: number;
  81478. /**
  81479. * Allows setting an offset for the grid lines.
  81480. */
  81481. gridOffset: BABYLON.Vector3;
  81482. /**
  81483. * The frequency of thicker lines.
  81484. */
  81485. majorUnitFrequency: number;
  81486. /**
  81487. * The visibility of minor units in the grid.
  81488. */
  81489. minorUnitVisibility: number;
  81490. /**
  81491. * The grid opacity outside of the lines.
  81492. */
  81493. opacity: number;
  81494. /**
  81495. * Determine RBG output is premultiplied by alpha value.
  81496. */
  81497. preMultiplyAlpha: boolean;
  81498. private _opacityTexture;
  81499. opacityTexture: BABYLON.BaseTexture;
  81500. private _gridControl;
  81501. /**
  81502. * constructor
  81503. * @param name The name given to the material in order to identify it afterwards.
  81504. * @param scene The scene the material is used in.
  81505. */
  81506. constructor(name: string, scene: BABYLON.Scene);
  81507. /**
  81508. * Returns wehter or not the grid requires alpha blending.
  81509. */
  81510. needAlphaBlending(): boolean;
  81511. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81512. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81513. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81514. /**
  81515. * Dispose the material and its associated resources.
  81516. * @param forceDisposeEffect will also dispose the used effect when true
  81517. */
  81518. dispose(forceDisposeEffect?: boolean): void;
  81519. clone(name: string): GridMaterial;
  81520. serialize(): any;
  81521. getClassName(): string;
  81522. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  81523. }
  81524. }
  81525. declare module BABYLON {
  81526. /** @hidden */
  81527. export var lavaPixelShader: {
  81528. name: string;
  81529. shader: string;
  81530. };
  81531. }
  81532. declare module BABYLON {
  81533. /** @hidden */
  81534. export var lavaVertexShader: {
  81535. name: string;
  81536. shader: string;
  81537. };
  81538. }
  81539. declare module BABYLON {
  81540. export class LavaMaterial extends BABYLON.PushMaterial {
  81541. private _diffuseTexture;
  81542. diffuseTexture: BABYLON.BaseTexture;
  81543. noiseTexture: BABYLON.BaseTexture;
  81544. fogColor: BABYLON.Color3;
  81545. speed: number;
  81546. movingSpeed: number;
  81547. lowFrequencySpeed: number;
  81548. fogDensity: number;
  81549. private _lastTime;
  81550. diffuseColor: BABYLON.Color3;
  81551. private _disableLighting;
  81552. disableLighting: boolean;
  81553. private _unlit;
  81554. unlit: boolean;
  81555. private _maxSimultaneousLights;
  81556. maxSimultaneousLights: number;
  81557. private _scaledDiffuse;
  81558. constructor(name: string, scene: BABYLON.Scene);
  81559. needAlphaBlending(): boolean;
  81560. needAlphaTesting(): boolean;
  81561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81564. getAnimatables(): BABYLON.IAnimatable[];
  81565. getActiveTextures(): BABYLON.BaseTexture[];
  81566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81567. dispose(forceDisposeEffect?: boolean): void;
  81568. clone(name: string): LavaMaterial;
  81569. serialize(): any;
  81570. getClassName(): string;
  81571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  81572. }
  81573. }
  81574. declare module BABYLON {
  81575. /** @hidden */
  81576. export var mixPixelShader: {
  81577. name: string;
  81578. shader: string;
  81579. };
  81580. }
  81581. declare module BABYLON {
  81582. /** @hidden */
  81583. export var mixVertexShader: {
  81584. name: string;
  81585. shader: string;
  81586. };
  81587. }
  81588. declare module BABYLON {
  81589. export class MixMaterial extends BABYLON.PushMaterial {
  81590. /**
  81591. * Mix textures
  81592. */
  81593. private _mixTexture1;
  81594. mixTexture1: BABYLON.BaseTexture;
  81595. private _mixTexture2;
  81596. mixTexture2: BABYLON.BaseTexture;
  81597. /**
  81598. * Diffuse textures
  81599. */
  81600. private _diffuseTexture1;
  81601. diffuseTexture1: BABYLON.Texture;
  81602. private _diffuseTexture2;
  81603. diffuseTexture2: BABYLON.Texture;
  81604. private _diffuseTexture3;
  81605. diffuseTexture3: BABYLON.Texture;
  81606. private _diffuseTexture4;
  81607. diffuseTexture4: BABYLON.Texture;
  81608. private _diffuseTexture5;
  81609. diffuseTexture5: BABYLON.Texture;
  81610. private _diffuseTexture6;
  81611. diffuseTexture6: BABYLON.Texture;
  81612. private _diffuseTexture7;
  81613. diffuseTexture7: BABYLON.Texture;
  81614. private _diffuseTexture8;
  81615. diffuseTexture8: BABYLON.Texture;
  81616. /**
  81617. * Uniforms
  81618. */
  81619. diffuseColor: BABYLON.Color3;
  81620. specularColor: BABYLON.Color3;
  81621. specularPower: number;
  81622. private _disableLighting;
  81623. disableLighting: boolean;
  81624. private _maxSimultaneousLights;
  81625. maxSimultaneousLights: number;
  81626. constructor(name: string, scene: BABYLON.Scene);
  81627. needAlphaBlending(): boolean;
  81628. needAlphaTesting(): boolean;
  81629. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81630. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81631. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81632. getAnimatables(): BABYLON.IAnimatable[];
  81633. getActiveTextures(): BABYLON.BaseTexture[];
  81634. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81635. dispose(forceDisposeEffect?: boolean): void;
  81636. clone(name: string): MixMaterial;
  81637. serialize(): any;
  81638. getClassName(): string;
  81639. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  81640. }
  81641. }
  81642. declare module BABYLON {
  81643. /** @hidden */
  81644. export var normalPixelShader: {
  81645. name: string;
  81646. shader: string;
  81647. };
  81648. }
  81649. declare module BABYLON {
  81650. /** @hidden */
  81651. export var normalVertexShader: {
  81652. name: string;
  81653. shader: string;
  81654. };
  81655. }
  81656. declare module BABYLON {
  81657. export class NormalMaterial extends BABYLON.PushMaterial {
  81658. private _diffuseTexture;
  81659. diffuseTexture: BABYLON.BaseTexture;
  81660. diffuseColor: BABYLON.Color3;
  81661. private _disableLighting;
  81662. disableLighting: boolean;
  81663. private _maxSimultaneousLights;
  81664. maxSimultaneousLights: number;
  81665. constructor(name: string, scene: BABYLON.Scene);
  81666. needAlphaBlending(): boolean;
  81667. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81668. needAlphaTesting(): boolean;
  81669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81672. getAnimatables(): BABYLON.IAnimatable[];
  81673. getActiveTextures(): BABYLON.BaseTexture[];
  81674. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81675. dispose(forceDisposeEffect?: boolean): void;
  81676. clone(name: string): NormalMaterial;
  81677. serialize(): any;
  81678. getClassName(): string;
  81679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  81680. }
  81681. }
  81682. declare module BABYLON {
  81683. /** @hidden */
  81684. export var shadowOnlyPixelShader: {
  81685. name: string;
  81686. shader: string;
  81687. };
  81688. }
  81689. declare module BABYLON {
  81690. /** @hidden */
  81691. export var shadowOnlyVertexShader: {
  81692. name: string;
  81693. shader: string;
  81694. };
  81695. }
  81696. declare module BABYLON {
  81697. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  81698. private _activeLight;
  81699. constructor(name: string, scene: BABYLON.Scene);
  81700. shadowColor: BABYLON.Color3;
  81701. needAlphaBlending(): boolean;
  81702. needAlphaTesting(): boolean;
  81703. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81704. get activeLight(): BABYLON.IShadowLight;
  81705. set activeLight(light: BABYLON.IShadowLight);
  81706. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81707. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81708. clone(name: string): ShadowOnlyMaterial;
  81709. serialize(): any;
  81710. getClassName(): string;
  81711. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  81712. }
  81713. }
  81714. declare module BABYLON {
  81715. /** @hidden */
  81716. export var simplePixelShader: {
  81717. name: string;
  81718. shader: string;
  81719. };
  81720. }
  81721. declare module BABYLON {
  81722. /** @hidden */
  81723. export var simpleVertexShader: {
  81724. name: string;
  81725. shader: string;
  81726. };
  81727. }
  81728. declare module BABYLON {
  81729. export class SimpleMaterial extends BABYLON.PushMaterial {
  81730. private _diffuseTexture;
  81731. diffuseTexture: BABYLON.BaseTexture;
  81732. diffuseColor: BABYLON.Color3;
  81733. private _disableLighting;
  81734. disableLighting: boolean;
  81735. private _maxSimultaneousLights;
  81736. maxSimultaneousLights: number;
  81737. constructor(name: string, scene: BABYLON.Scene);
  81738. needAlphaBlending(): boolean;
  81739. needAlphaTesting(): boolean;
  81740. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81741. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81742. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81743. getAnimatables(): BABYLON.IAnimatable[];
  81744. getActiveTextures(): BABYLON.BaseTexture[];
  81745. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81746. dispose(forceDisposeEffect?: boolean): void;
  81747. clone(name: string): SimpleMaterial;
  81748. serialize(): any;
  81749. getClassName(): string;
  81750. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  81751. }
  81752. }
  81753. declare module BABYLON {
  81754. /** @hidden */
  81755. export var skyPixelShader: {
  81756. name: string;
  81757. shader: string;
  81758. };
  81759. }
  81760. declare module BABYLON {
  81761. /** @hidden */
  81762. export var skyVertexShader: {
  81763. name: string;
  81764. shader: string;
  81765. };
  81766. }
  81767. declare module BABYLON {
  81768. /**
  81769. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  81770. * @see https://doc.babylonjs.com/extensions/sky
  81771. */
  81772. export class SkyMaterial extends BABYLON.PushMaterial {
  81773. /**
  81774. * Defines the overall luminance of sky in interval ]0, 1[.
  81775. */
  81776. luminance: number;
  81777. /**
  81778. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  81779. */
  81780. turbidity: number;
  81781. /**
  81782. * Defines the sky appearance (light intensity).
  81783. */
  81784. rayleigh: number;
  81785. /**
  81786. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  81787. */
  81788. mieCoefficient: number;
  81789. /**
  81790. * Defines the amount of haze particles following the Mie scattering theory.
  81791. */
  81792. mieDirectionalG: number;
  81793. /**
  81794. * Defines the distance of the sun according to the active scene camera.
  81795. */
  81796. distance: number;
  81797. /**
  81798. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  81799. * "inclined".
  81800. */
  81801. inclination: number;
  81802. /**
  81803. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  81804. * an object direction and a reference direction.
  81805. */
  81806. azimuth: number;
  81807. /**
  81808. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  81809. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  81810. */
  81811. sunPosition: BABYLON.Vector3;
  81812. /**
  81813. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  81814. * .sunPosition property.
  81815. */
  81816. useSunPosition: boolean;
  81817. /**
  81818. * Defines an offset vector used to get a horizon offset.
  81819. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  81820. */
  81821. cameraOffset: BABYLON.Vector3;
  81822. private _cameraPosition;
  81823. /**
  81824. * Instantiates a new sky material.
  81825. * This material allows to create dynamic and texture free
  81826. * effects for skyboxes by taking care of the atmosphere state.
  81827. * @see https://doc.babylonjs.com/extensions/sky
  81828. * @param name Define the name of the material in the scene
  81829. * @param scene Define the scene the material belong to
  81830. */
  81831. constructor(name: string, scene: BABYLON.Scene);
  81832. /**
  81833. * Specifies if the material will require alpha blending
  81834. * @returns a boolean specifying if alpha blending is needed
  81835. */
  81836. needAlphaBlending(): boolean;
  81837. /**
  81838. * Specifies if this material should be rendered in alpha test mode
  81839. * @returns false as the sky material doesn't need alpha testing.
  81840. */
  81841. needAlphaTesting(): boolean;
  81842. /**
  81843. * Get the texture used for alpha test purpose.
  81844. * @returns null as the sky material has no texture.
  81845. */
  81846. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81847. /**
  81848. * Get if the submesh is ready to be used and all its information available.
  81849. * Child classes can use it to update shaders
  81850. * @param mesh defines the mesh to check
  81851. * @param subMesh defines which submesh to check
  81852. * @param useInstances specifies that instances should be used
  81853. * @returns a boolean indicating that the submesh is ready or not
  81854. */
  81855. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81856. /**
  81857. * Binds the submesh to this material by preparing the effect and shader to draw
  81858. * @param world defines the world transformation matrix
  81859. * @param mesh defines the mesh containing the submesh
  81860. * @param subMesh defines the submesh to bind the material to
  81861. */
  81862. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81863. /**
  81864. * Get the list of animatables in the material.
  81865. * @returns the list of animatables object used in the material
  81866. */
  81867. getAnimatables(): BABYLON.IAnimatable[];
  81868. /**
  81869. * Disposes the material
  81870. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81871. */
  81872. dispose(forceDisposeEffect?: boolean): void;
  81873. /**
  81874. * Makes a duplicate of the material, and gives it a new name
  81875. * @param name defines the new name for the duplicated material
  81876. * @returns the cloned material
  81877. */
  81878. clone(name: string): SkyMaterial;
  81879. /**
  81880. * Serializes this material in a JSON representation
  81881. * @returns the serialized material object
  81882. */
  81883. serialize(): any;
  81884. /**
  81885. * Gets the current class name of the material e.g. "SkyMaterial"
  81886. * Mainly use in serialization.
  81887. * @returns the class name
  81888. */
  81889. getClassName(): string;
  81890. /**
  81891. * Creates a sky material from parsed material data
  81892. * @param source defines the JSON representation of the material
  81893. * @param scene defines the hosting scene
  81894. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  81895. * @returns a new sky material
  81896. */
  81897. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  81898. }
  81899. }
  81900. declare module BABYLON {
  81901. /** @hidden */
  81902. export var terrainPixelShader: {
  81903. name: string;
  81904. shader: string;
  81905. };
  81906. }
  81907. declare module BABYLON {
  81908. /** @hidden */
  81909. export var terrainVertexShader: {
  81910. name: string;
  81911. shader: string;
  81912. };
  81913. }
  81914. declare module BABYLON {
  81915. export class TerrainMaterial extends BABYLON.PushMaterial {
  81916. private _mixTexture;
  81917. mixTexture: BABYLON.BaseTexture;
  81918. private _diffuseTexture1;
  81919. diffuseTexture1: BABYLON.Texture;
  81920. private _diffuseTexture2;
  81921. diffuseTexture2: BABYLON.Texture;
  81922. private _diffuseTexture3;
  81923. diffuseTexture3: BABYLON.Texture;
  81924. private _bumpTexture1;
  81925. bumpTexture1: BABYLON.Texture;
  81926. private _bumpTexture2;
  81927. bumpTexture2: BABYLON.Texture;
  81928. private _bumpTexture3;
  81929. bumpTexture3: BABYLON.Texture;
  81930. diffuseColor: BABYLON.Color3;
  81931. specularColor: BABYLON.Color3;
  81932. specularPower: number;
  81933. private _disableLighting;
  81934. disableLighting: boolean;
  81935. private _maxSimultaneousLights;
  81936. maxSimultaneousLights: number;
  81937. constructor(name: string, scene: BABYLON.Scene);
  81938. needAlphaBlending(): boolean;
  81939. needAlphaTesting(): boolean;
  81940. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81941. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81942. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81943. getAnimatables(): BABYLON.IAnimatable[];
  81944. getActiveTextures(): BABYLON.BaseTexture[];
  81945. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81946. dispose(forceDisposeEffect?: boolean): void;
  81947. clone(name: string): TerrainMaterial;
  81948. serialize(): any;
  81949. getClassName(): string;
  81950. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  81951. }
  81952. }
  81953. declare module BABYLON {
  81954. /** @hidden */
  81955. export var triplanarPixelShader: {
  81956. name: string;
  81957. shader: string;
  81958. };
  81959. }
  81960. declare module BABYLON {
  81961. /** @hidden */
  81962. export var triplanarVertexShader: {
  81963. name: string;
  81964. shader: string;
  81965. };
  81966. }
  81967. declare module BABYLON {
  81968. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  81969. mixTexture: BABYLON.BaseTexture;
  81970. private _diffuseTextureX;
  81971. diffuseTextureX: BABYLON.BaseTexture;
  81972. private _diffuseTextureY;
  81973. diffuseTextureY: BABYLON.BaseTexture;
  81974. private _diffuseTextureZ;
  81975. diffuseTextureZ: BABYLON.BaseTexture;
  81976. private _normalTextureX;
  81977. normalTextureX: BABYLON.BaseTexture;
  81978. private _normalTextureY;
  81979. normalTextureY: BABYLON.BaseTexture;
  81980. private _normalTextureZ;
  81981. normalTextureZ: BABYLON.BaseTexture;
  81982. tileSize: number;
  81983. diffuseColor: BABYLON.Color3;
  81984. specularColor: BABYLON.Color3;
  81985. specularPower: number;
  81986. private _disableLighting;
  81987. disableLighting: boolean;
  81988. private _maxSimultaneousLights;
  81989. maxSimultaneousLights: number;
  81990. constructor(name: string, scene: BABYLON.Scene);
  81991. needAlphaBlending(): boolean;
  81992. needAlphaTesting(): boolean;
  81993. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81994. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81995. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81996. getAnimatables(): BABYLON.IAnimatable[];
  81997. getActiveTextures(): BABYLON.BaseTexture[];
  81998. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81999. dispose(forceDisposeEffect?: boolean): void;
  82000. clone(name: string): TriPlanarMaterial;
  82001. serialize(): any;
  82002. getClassName(): string;
  82003. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82004. }
  82005. }
  82006. declare module BABYLON {
  82007. /** @hidden */
  82008. export var waterPixelShader: {
  82009. name: string;
  82010. shader: string;
  82011. };
  82012. }
  82013. declare module BABYLON {
  82014. /** @hidden */
  82015. export var waterVertexShader: {
  82016. name: string;
  82017. shader: string;
  82018. };
  82019. }
  82020. declare module BABYLON {
  82021. export class WaterMaterial extends BABYLON.PushMaterial {
  82022. renderTargetSize: BABYLON.Vector2;
  82023. private _bumpTexture;
  82024. bumpTexture: BABYLON.BaseTexture;
  82025. diffuseColor: BABYLON.Color3;
  82026. specularColor: BABYLON.Color3;
  82027. specularPower: number;
  82028. private _disableLighting;
  82029. disableLighting: boolean;
  82030. private _maxSimultaneousLights;
  82031. maxSimultaneousLights: number;
  82032. /**
  82033. * @param {number}: Represents the wind force
  82034. */
  82035. windForce: number;
  82036. /**
  82037. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82038. */
  82039. windDirection: BABYLON.Vector2;
  82040. /**
  82041. * @param {number}: Wave height, represents the height of the waves
  82042. */
  82043. waveHeight: number;
  82044. /**
  82045. * @param {number}: Bump height, represents the bump height related to the bump map
  82046. */
  82047. bumpHeight: number;
  82048. /**
  82049. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82050. */
  82051. private _bumpSuperimpose;
  82052. bumpSuperimpose: boolean;
  82053. /**
  82054. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82055. */
  82056. private _fresnelSeparate;
  82057. fresnelSeparate: boolean;
  82058. /**
  82059. * @param {boolean}: bump Waves modify the reflection.
  82060. */
  82061. private _bumpAffectsReflection;
  82062. bumpAffectsReflection: boolean;
  82063. /**
  82064. * @param {number}: The water color blended with the refraction (near)
  82065. */
  82066. waterColor: BABYLON.Color3;
  82067. /**
  82068. * @param {number}: The blend factor related to the water color
  82069. */
  82070. colorBlendFactor: number;
  82071. /**
  82072. * @param {number}: The water color blended with the reflection (far)
  82073. */
  82074. waterColor2: BABYLON.Color3;
  82075. /**
  82076. * @param {number}: The blend factor related to the water color (reflection, far)
  82077. */
  82078. colorBlendFactor2: number;
  82079. /**
  82080. * @param {number}: Represents the maximum length of a wave
  82081. */
  82082. waveLength: number;
  82083. /**
  82084. * @param {number}: Defines the waves speed
  82085. */
  82086. waveSpeed: number;
  82087. /**
  82088. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82089. * will avoid calculating useless pixels in the pixel shader of the water material.
  82090. */
  82091. disableClipPlane: boolean;
  82092. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82093. private _mesh;
  82094. private _refractionRTT;
  82095. private _reflectionRTT;
  82096. private _reflectionTransform;
  82097. private _lastTime;
  82098. private _lastDeltaTime;
  82099. private _useLogarithmicDepth;
  82100. private _waitingRenderList;
  82101. private _imageProcessingConfiguration;
  82102. private _imageProcessingObserver;
  82103. /**
  82104. * Gets a boolean indicating that current material needs to register RTT
  82105. */
  82106. get hasRenderTargetTextures(): boolean;
  82107. /**
  82108. * Constructor
  82109. */
  82110. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82111. get useLogarithmicDepth(): boolean;
  82112. set useLogarithmicDepth(value: boolean);
  82113. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82114. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82115. addToRenderList(node: any): void;
  82116. enableRenderTargets(enable: boolean): void;
  82117. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82118. get renderTargetsEnabled(): boolean;
  82119. needAlphaBlending(): boolean;
  82120. needAlphaTesting(): boolean;
  82121. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82122. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82123. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82124. private _createRenderTargets;
  82125. getAnimatables(): BABYLON.IAnimatable[];
  82126. getActiveTextures(): BABYLON.BaseTexture[];
  82127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82128. dispose(forceDisposeEffect?: boolean): void;
  82129. clone(name: string): WaterMaterial;
  82130. serialize(): any;
  82131. getClassName(): string;
  82132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  82133. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  82134. }
  82135. }
  82136. declare module BABYLON {
  82137. /** @hidden */
  82138. export var asciiartPixelShader: {
  82139. name: string;
  82140. shader: string;
  82141. };
  82142. }
  82143. declare module BABYLON {
  82144. /**
  82145. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  82146. *
  82147. * It basically takes care rendering the font front the given font size to a texture.
  82148. * This is used later on in the postprocess.
  82149. */
  82150. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  82151. private _font;
  82152. private _text;
  82153. private _charSize;
  82154. /**
  82155. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82156. */
  82157. get charSize(): number;
  82158. /**
  82159. * Create a new instance of the Ascii Art FontTexture class
  82160. * @param name the name of the texture
  82161. * @param font the font to use, use the W3C CSS notation
  82162. * @param text the caracter set to use in the rendering.
  82163. * @param scene the scene that owns the texture
  82164. */
  82165. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82166. /**
  82167. * Gets the max char width of a font.
  82168. * @param font the font to use, use the W3C CSS notation
  82169. * @return the max char width
  82170. */
  82171. private getFontWidth;
  82172. /**
  82173. * Gets the max char height of a font.
  82174. * @param font the font to use, use the W3C CSS notation
  82175. * @return the max char height
  82176. */
  82177. private getFontHeight;
  82178. /**
  82179. * Clones the current AsciiArtTexture.
  82180. * @return the clone of the texture.
  82181. */
  82182. clone(): AsciiArtFontTexture;
  82183. /**
  82184. * Parses a json object representing the texture and returns an instance of it.
  82185. * @param source the source JSON representation
  82186. * @param scene the scene to create the texture for
  82187. * @return the parsed texture
  82188. */
  82189. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82190. }
  82191. /**
  82192. * Option available in the Ascii Art Post Process.
  82193. */
  82194. export interface IAsciiArtPostProcessOptions {
  82195. /**
  82196. * The font to use following the w3c font definition.
  82197. */
  82198. font?: string;
  82199. /**
  82200. * The character set to use in the postprocess.
  82201. */
  82202. characterSet?: string;
  82203. /**
  82204. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82205. * This number is defined between 0 and 1;
  82206. */
  82207. mixToTile?: number;
  82208. /**
  82209. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82210. * This number is defined between 0 and 1;
  82211. */
  82212. mixToNormal?: number;
  82213. }
  82214. /**
  82215. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82216. *
  82217. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82218. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82219. */
  82220. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82221. /**
  82222. * The font texture used to render the char in the post process.
  82223. */
  82224. private _asciiArtFontTexture;
  82225. /**
  82226. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82227. * This number is defined between 0 and 1;
  82228. */
  82229. mixToTile: number;
  82230. /**
  82231. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82232. * This number is defined between 0 and 1;
  82233. */
  82234. mixToNormal: number;
  82235. /**
  82236. * Instantiates a new Ascii Art Post Process.
  82237. * @param name the name to give to the postprocess
  82238. * @camera the camera to apply the post process to.
  82239. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82240. */
  82241. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82242. }
  82243. }
  82244. declare module BABYLON {
  82245. /** @hidden */
  82246. export var digitalrainPixelShader: {
  82247. name: string;
  82248. shader: string;
  82249. };
  82250. }
  82251. declare module BABYLON {
  82252. /**
  82253. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82254. *
  82255. * It basically takes care rendering the font front the given font size to a texture.
  82256. * This is used later on in the postprocess.
  82257. */
  82258. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82259. private _font;
  82260. private _text;
  82261. private _charSize;
  82262. /**
  82263. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82264. */
  82265. get charSize(): number;
  82266. /**
  82267. * Create a new instance of the Digital Rain FontTexture class
  82268. * @param name the name of the texture
  82269. * @param font the font to use, use the W3C CSS notation
  82270. * @param text the caracter set to use in the rendering.
  82271. * @param scene the scene that owns the texture
  82272. */
  82273. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82274. /**
  82275. * Gets the max char width of a font.
  82276. * @param font the font to use, use the W3C CSS notation
  82277. * @return the max char width
  82278. */
  82279. private getFontWidth;
  82280. /**
  82281. * Gets the max char height of a font.
  82282. * @param font the font to use, use the W3C CSS notation
  82283. * @return the max char height
  82284. */
  82285. private getFontHeight;
  82286. /**
  82287. * Clones the current DigitalRainFontTexture.
  82288. * @return the clone of the texture.
  82289. */
  82290. clone(): DigitalRainFontTexture;
  82291. /**
  82292. * Parses a json object representing the texture and returns an instance of it.
  82293. * @param source the source JSON representation
  82294. * @param scene the scene to create the texture for
  82295. * @return the parsed texture
  82296. */
  82297. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82298. }
  82299. /**
  82300. * Option available in the Digital Rain Post Process.
  82301. */
  82302. export interface IDigitalRainPostProcessOptions {
  82303. /**
  82304. * The font to use following the w3c font definition.
  82305. */
  82306. font?: string;
  82307. /**
  82308. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82309. * This number is defined between 0 and 1;
  82310. */
  82311. mixToTile?: number;
  82312. /**
  82313. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82314. * This number is defined between 0 and 1;
  82315. */
  82316. mixToNormal?: number;
  82317. }
  82318. /**
  82319. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82320. *
  82321. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82322. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82323. */
  82324. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82325. /**
  82326. * The font texture used to render the char in the post process.
  82327. */
  82328. private _digitalRainFontTexture;
  82329. /**
  82330. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82331. * This number is defined between 0 and 1;
  82332. */
  82333. mixToTile: number;
  82334. /**
  82335. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82336. * This number is defined between 0 and 1;
  82337. */
  82338. mixToNormal: number;
  82339. /**
  82340. * Instantiates a new Digital Rain Post Process.
  82341. * @param name the name to give to the postprocess
  82342. * @camera the camera to apply the post process to.
  82343. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82344. */
  82345. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82346. }
  82347. }
  82348. declare module BABYLON {
  82349. /** @hidden */
  82350. export var brickProceduralTexturePixelShader: {
  82351. name: string;
  82352. shader: string;
  82353. };
  82354. }
  82355. declare module BABYLON {
  82356. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82357. private _numberOfBricksHeight;
  82358. private _numberOfBricksWidth;
  82359. private _jointColor;
  82360. private _brickColor;
  82361. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82362. updateShaderUniforms(): void;
  82363. get numberOfBricksHeight(): number;
  82364. set numberOfBricksHeight(value: number);
  82365. get numberOfBricksWidth(): number;
  82366. set numberOfBricksWidth(value: number);
  82367. get jointColor(): BABYLON.Color3;
  82368. set jointColor(value: BABYLON.Color3);
  82369. get brickColor(): BABYLON.Color3;
  82370. set brickColor(value: BABYLON.Color3);
  82371. /**
  82372. * Serializes this brick procedural texture
  82373. * @returns a serialized brick procedural texture object
  82374. */
  82375. serialize(): any;
  82376. /**
  82377. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82378. * @param parsedTexture defines parsed texture data
  82379. * @param scene defines the current scene
  82380. * @param rootUrl defines the root URL containing brick procedural texture information
  82381. * @returns a parsed Brick Procedural BABYLON.Texture
  82382. */
  82383. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82384. }
  82385. }
  82386. declare module BABYLON {
  82387. /** @hidden */
  82388. export var cloudProceduralTexturePixelShader: {
  82389. name: string;
  82390. shader: string;
  82391. };
  82392. }
  82393. declare module BABYLON {
  82394. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82395. private _skyColor;
  82396. private _cloudColor;
  82397. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82398. updateShaderUniforms(): void;
  82399. get skyColor(): BABYLON.Color4;
  82400. set skyColor(value: BABYLON.Color4);
  82401. get cloudColor(): BABYLON.Color4;
  82402. set cloudColor(value: BABYLON.Color4);
  82403. /**
  82404. * Serializes this cloud procedural texture
  82405. * @returns a serialized cloud procedural texture object
  82406. */
  82407. serialize(): any;
  82408. /**
  82409. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82410. * @param parsedTexture defines parsed texture data
  82411. * @param scene defines the current scene
  82412. * @param rootUrl defines the root URL containing cloud procedural texture information
  82413. * @returns a parsed Cloud Procedural BABYLON.Texture
  82414. */
  82415. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82416. }
  82417. }
  82418. declare module BABYLON {
  82419. /** @hidden */
  82420. export var fireProceduralTexturePixelShader: {
  82421. name: string;
  82422. shader: string;
  82423. };
  82424. }
  82425. declare module BABYLON {
  82426. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82427. private _time;
  82428. private _speed;
  82429. private _autoGenerateTime;
  82430. private _fireColors;
  82431. private _alphaThreshold;
  82432. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82433. updateShaderUniforms(): void;
  82434. render(useCameraPostProcess?: boolean): void;
  82435. static get PurpleFireColors(): BABYLON.Color3[];
  82436. static get GreenFireColors(): BABYLON.Color3[];
  82437. static get RedFireColors(): BABYLON.Color3[];
  82438. static get BlueFireColors(): BABYLON.Color3[];
  82439. get autoGenerateTime(): boolean;
  82440. set autoGenerateTime(value: boolean);
  82441. get fireColors(): BABYLON.Color3[];
  82442. set fireColors(value: BABYLON.Color3[]);
  82443. get time(): number;
  82444. set time(value: number);
  82445. get speed(): BABYLON.Vector2;
  82446. set speed(value: BABYLON.Vector2);
  82447. get alphaThreshold(): number;
  82448. set alphaThreshold(value: number);
  82449. /**
  82450. * Serializes this fire procedural texture
  82451. * @returns a serialized fire procedural texture object
  82452. */
  82453. serialize(): any;
  82454. /**
  82455. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82456. * @param parsedTexture defines parsed texture data
  82457. * @param scene defines the current scene
  82458. * @param rootUrl defines the root URL containing fire procedural texture information
  82459. * @returns a parsed Fire Procedural BABYLON.Texture
  82460. */
  82461. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82462. }
  82463. }
  82464. declare module BABYLON {
  82465. /** @hidden */
  82466. export var grassProceduralTexturePixelShader: {
  82467. name: string;
  82468. shader: string;
  82469. };
  82470. }
  82471. declare module BABYLON {
  82472. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82473. private _grassColors;
  82474. private _groundColor;
  82475. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82476. updateShaderUniforms(): void;
  82477. get grassColors(): BABYLON.Color3[];
  82478. set grassColors(value: BABYLON.Color3[]);
  82479. get groundColor(): BABYLON.Color3;
  82480. set groundColor(value: BABYLON.Color3);
  82481. /**
  82482. * Serializes this grass procedural texture
  82483. * @returns a serialized grass procedural texture object
  82484. */
  82485. serialize(): any;
  82486. /**
  82487. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  82488. * @param parsedTexture defines parsed texture data
  82489. * @param scene defines the current scene
  82490. * @param rootUrl defines the root URL containing grass procedural texture information
  82491. * @returns a parsed Grass Procedural BABYLON.Texture
  82492. */
  82493. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  82494. }
  82495. }
  82496. declare module BABYLON {
  82497. /** @hidden */
  82498. export var marbleProceduralTexturePixelShader: {
  82499. name: string;
  82500. shader: string;
  82501. };
  82502. }
  82503. declare module BABYLON {
  82504. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  82505. private _numberOfTilesHeight;
  82506. private _numberOfTilesWidth;
  82507. private _amplitude;
  82508. private _jointColor;
  82509. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82510. updateShaderUniforms(): void;
  82511. get numberOfTilesHeight(): number;
  82512. set numberOfTilesHeight(value: number);
  82513. get amplitude(): number;
  82514. set amplitude(value: number);
  82515. get numberOfTilesWidth(): number;
  82516. set numberOfTilesWidth(value: number);
  82517. get jointColor(): BABYLON.Color3;
  82518. set jointColor(value: BABYLON.Color3);
  82519. /**
  82520. * Serializes this marble procedural texture
  82521. * @returns a serialized marble procedural texture object
  82522. */
  82523. serialize(): any;
  82524. /**
  82525. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  82526. * @param parsedTexture defines parsed texture data
  82527. * @param scene defines the current scene
  82528. * @param rootUrl defines the root URL containing marble procedural texture information
  82529. * @returns a parsed Marble Procedural BABYLON.Texture
  82530. */
  82531. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  82532. }
  82533. }
  82534. declare module BABYLON {
  82535. /** @hidden */
  82536. export var normalMapProceduralTexturePixelShader: {
  82537. name: string;
  82538. shader: string;
  82539. };
  82540. }
  82541. declare module BABYLON {
  82542. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  82543. private _baseTexture;
  82544. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82545. updateShaderUniforms(): void;
  82546. render(useCameraPostProcess?: boolean): void;
  82547. resize(size: any, generateMipMaps: any): void;
  82548. get baseTexture(): BABYLON.Texture;
  82549. set baseTexture(texture: BABYLON.Texture);
  82550. /**
  82551. * Serializes this normal map procedural texture
  82552. * @returns a serialized normal map procedural texture object
  82553. */
  82554. serialize(): any;
  82555. /**
  82556. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  82557. * @param parsedTexture defines parsed texture data
  82558. * @param scene defines the current scene
  82559. * @param rootUrl defines the root URL containing normal map procedural texture information
  82560. * @returns a parsed Normal Map Procedural BABYLON.Texture
  82561. */
  82562. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  82563. }
  82564. }
  82565. declare module BABYLON {
  82566. /** @hidden */
  82567. export var perlinNoiseProceduralTexturePixelShader: {
  82568. name: string;
  82569. shader: string;
  82570. };
  82571. }
  82572. declare module BABYLON {
  82573. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  82574. time: number;
  82575. timeScale: number;
  82576. translationSpeed: number;
  82577. private _currentTranslation;
  82578. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82579. updateShaderUniforms(): void;
  82580. render(useCameraPostProcess?: boolean): void;
  82581. resize(size: any, generateMipMaps: any): void;
  82582. /**
  82583. * Serializes this perlin noise procedural texture
  82584. * @returns a serialized perlin noise procedural texture object
  82585. */
  82586. serialize(): any;
  82587. /**
  82588. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  82589. * @param parsedTexture defines parsed texture data
  82590. * @param scene defines the current scene
  82591. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  82592. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  82593. */
  82594. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  82595. }
  82596. }
  82597. declare module BABYLON {
  82598. /** @hidden */
  82599. export var roadProceduralTexturePixelShader: {
  82600. name: string;
  82601. shader: string;
  82602. };
  82603. }
  82604. declare module BABYLON {
  82605. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  82606. private _roadColor;
  82607. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82608. updateShaderUniforms(): void;
  82609. get roadColor(): BABYLON.Color3;
  82610. set roadColor(value: BABYLON.Color3);
  82611. /**
  82612. * Serializes this road procedural texture
  82613. * @returns a serialized road procedural texture object
  82614. */
  82615. serialize(): any;
  82616. /**
  82617. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  82618. * @param parsedTexture defines parsed texture data
  82619. * @param scene defines the current scene
  82620. * @param rootUrl defines the root URL containing road procedural texture information
  82621. * @returns a parsed Road Procedural BABYLON.Texture
  82622. */
  82623. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  82624. }
  82625. }
  82626. declare module BABYLON {
  82627. /** @hidden */
  82628. export var starfieldProceduralTexturePixelShader: {
  82629. name: string;
  82630. shader: string;
  82631. };
  82632. }
  82633. declare module BABYLON {
  82634. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  82635. private _time;
  82636. private _alpha;
  82637. private _beta;
  82638. private _zoom;
  82639. private _formuparam;
  82640. private _stepsize;
  82641. private _tile;
  82642. private _brightness;
  82643. private _darkmatter;
  82644. private _distfading;
  82645. private _saturation;
  82646. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82647. updateShaderUniforms(): void;
  82648. get time(): number;
  82649. set time(value: number);
  82650. get alpha(): number;
  82651. set alpha(value: number);
  82652. get beta(): number;
  82653. set beta(value: number);
  82654. get formuparam(): number;
  82655. set formuparam(value: number);
  82656. get stepsize(): number;
  82657. set stepsize(value: number);
  82658. get zoom(): number;
  82659. set zoom(value: number);
  82660. get tile(): number;
  82661. set tile(value: number);
  82662. get brightness(): number;
  82663. set brightness(value: number);
  82664. get darkmatter(): number;
  82665. set darkmatter(value: number);
  82666. get distfading(): number;
  82667. set distfading(value: number);
  82668. get saturation(): number;
  82669. set saturation(value: number);
  82670. /**
  82671. * Serializes this starfield procedural texture
  82672. * @returns a serialized starfield procedural texture object
  82673. */
  82674. serialize(): any;
  82675. /**
  82676. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  82677. * @param parsedTexture defines parsed texture data
  82678. * @param scene defines the current scene
  82679. * @param rootUrl defines the root URL containing startfield procedural texture information
  82680. * @returns a parsed Starfield Procedural BABYLON.Texture
  82681. */
  82682. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  82683. }
  82684. }
  82685. declare module BABYLON {
  82686. /** @hidden */
  82687. export var woodProceduralTexturePixelShader: {
  82688. name: string;
  82689. shader: string;
  82690. };
  82691. }
  82692. declare module BABYLON {
  82693. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  82694. private _ampScale;
  82695. private _woodColor;
  82696. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82697. updateShaderUniforms(): void;
  82698. get ampScale(): number;
  82699. set ampScale(value: number);
  82700. get woodColor(): BABYLON.Color3;
  82701. set woodColor(value: BABYLON.Color3);
  82702. /**
  82703. * Serializes this wood procedural texture
  82704. * @returns a serialized wood procedural texture object
  82705. */
  82706. serialize(): any;
  82707. /**
  82708. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  82709. * @param parsedTexture defines parsed texture data
  82710. * @param scene defines the current scene
  82711. * @param rootUrl defines the root URL containing wood procedural texture information
  82712. * @returns a parsed Wood Procedural BABYLON.Texture
  82713. */
  82714. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  82715. }
  82716. }